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-next>] [day] [month] [year] [list]
Message-Id: <20231120031752.522139-1-chunfu.jian@shingroup.cn>
Date:   Mon, 20 Nov 2023 11:17:52 +0800
From:   JianChunfu <chunfu.jian@...ngroup.cn>
To:     alex.williamson@...hat.com, cohuck@...hat.com
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        shenghui.qu@...ngroup.cn, JianChunfu <chunfu.jian@...ngroup.cn>
Subject: [PATCH] vfio/pci: Separate INTx-enabled vfio_pci_device from unenabled to make the code logic clearer.

It seems a little unclear when dealing with vfio_intx_set_signal()
because of vfio_pci_device which is irq_none,
so separate the two situations.

Signed-off-by: JianChunfu <chunfu.jian@...ngroup.cn>
---
 drivers/vfio/pci/vfio_pci_intrs.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 6069a11fb51a..b6d126c48393 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -468,6 +468,8 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
 				     unsigned index, unsigned start,
 				     unsigned count, uint32_t flags, void *data)
 {
+	int32_t fd = *(int32_t *)data;
+
 	if (is_intx(vdev) && !count && (flags & VFIO_IRQ_SET_DATA_NONE)) {
 		vfio_intx_disable(vdev);
 		return 0;
@@ -476,28 +478,25 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
 	if (!(is_intx(vdev) || is_irq_none(vdev)) || start != 0 || count != 1)
 		return -EINVAL;
 
-	if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
-		int32_t fd = *(int32_t *)data;
+	if (!is_intx(vdev)) {
 		int ret;
+		if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
+			ret = vfio_intx_enable(vdev);
+			if (ret)
+				return ret;
 
-		if (is_intx(vdev))
-			return vfio_intx_set_signal(vdev, fd);
+			ret = vfio_intx_set_signal(vdev, fd);
+			if (ret)
+				vfio_intx_disable(vdev);
 
-		ret = vfio_intx_enable(vdev);
-		if (ret)
 			return ret;
-
-		ret = vfio_intx_set_signal(vdev, fd);
-		if (ret)
-			vfio_intx_disable(vdev);
-
-		return ret;
+		} else
+			return -EINVAL;
 	}
 
-	if (!is_intx(vdev))
-		return -EINVAL;
-
-	if (flags & VFIO_IRQ_SET_DATA_NONE) {
+	if (flags & VFIO_IRQ_SET_DATA_EVENTFD) {
+		return vfio_intx_set_signal(vdev, fd);
+	} else if (flags & VFIO_IRQ_SET_DATA_NONE) {
 		vfio_send_intx_eventfd(vdev, NULL);
 	} else if (flags & VFIO_IRQ_SET_DATA_BOOL) {
 		uint8_t trigger = *(uint8_t *)data;
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ