lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu,  1 Feb 2024 20:57:03 -0800
From: Reinette Chatre <reinette.chatre@...el.com>
To: jgg@...dia.com,
	yishaih@...dia.com,
	shameerali.kolothum.thodi@...wei.com,
	kevin.tian@...el.com,
	alex.williamson@...hat.com
Cc: kvm@...r.kernel.org,
	dave.jiang@...el.com,
	ashok.raj@...el.com,
	reinette.chatre@...el.com,
	linux-kernel@...r.kernel.org,
	patches@...ts.linux.dev
Subject: [PATCH 09/17] vfio/pci: Converge similar code flows

vfio_intx_set_signal() and vfio_msi_set_vector_signal() have similar
code flows that can be shared.

Modify vfio_intx_set_signal()'s signature to resemble that of
vfio_msi_set_vector_signal() by also providing the vector and interrupt
type as parameters. For vfio_intx_set_signal() these two additional
parameters are redundant and unused since the vector is always 0 and
the interrupt type is always INTx. Adding these parameters make it
possible to refactor vfio_intx_set_signal() to call INTx specific
functions with the same signature as the MSI/MSI-X specific functions
in preparation for these interrupt type specific functions to be called
by shared code.

Signed-off-by: Reinette Chatre <reinette.chatre@...el.com>
---
 drivers/vfio/pci/vfio_pci_intrs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 70f2382c9c0c..98b099f58b2b 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -260,7 +260,9 @@ static int vfio_intx_enable(struct vfio_pci_core_device *vdev)
 	return 0;
 }
 
-static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev, int fd)
+static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev,
+				unsigned int vector, int fd,
+				unsigned int index)
 {
 	struct pci_dev *pdev = vdev->pdev;
 	unsigned long irqflags = IRQF_SHARED;
@@ -330,7 +332,7 @@ static void vfio_intx_disable(struct vfio_pci_core_device *vdev)
 		vfio_virqfd_disable(&ctx->unmask);
 		vfio_virqfd_disable(&ctx->mask);
 	}
-	vfio_intx_set_signal(vdev, -1);
+	vfio_intx_set_signal(vdev, 0, -1, VFIO_PCI_INTX_IRQ_INDEX);
 	vdev->irq_type = VFIO_PCI_NUM_IRQS;
 	vfio_irq_ctx_free(vdev, ctx, 0);
 }
@@ -674,13 +676,13 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
 		int ret;
 
 		if (is_intx(vdev))
-			return vfio_intx_set_signal(vdev, fd);
+			return vfio_intx_set_signal(vdev, start, fd, index);
 
 		ret = vfio_intx_enable(vdev);
 		if (ret)
 			return ret;
 
-		ret = vfio_intx_set_signal(vdev, fd);
+		ret = vfio_intx_set_signal(vdev, start, fd, index);
 		if (ret)
 			vfio_intx_disable(vdev);
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ