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]
Message-Id: <2e293a866f071d6a116cad8c9b725298b8217f43.1692892275.git.reinette.chatre@intel.com>
Date:   Thu, 24 Aug 2023 09:15:22 -0700
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, jing2.liu@...el.com,
        ashok.raj@...el.com, fenghua.yu@...el.com,
        tom.zanussi@...ux.intel.com, reinette.chatre@...el.com,
        linux-kernel@...r.kernel.org
Subject: [RFC PATCH 3/3] vfio/ims: Add helper that returns IMS index

A virtual device driver needs to facilitate translation between
the guest's MSI-X interrupt and the backing IMS interrupt with
which the physical device is programmed. For example, the
guest may need to obtain the IMS index from the virtual device driver
that it needs to program into descriptors submitted to the device
to ensure that the completion interrupts are generated correctly.

Introduce vfio_pci_ims_hwirq() to VFIO PCI IMS as a helper that
returns the IMS interrupt index backing a provided MSI-X
interrupt index belonging to a guest.

Originally-by: Dave Jiang <dave.jiang@...el.com>
Signed-off-by: Reinette Chatre <reinette.chatre@...el.com>
---
 drivers/vfio/pci/vfio_pci_ims.c | 21 +++++++++++++++++++++
 include/linux/vfio.h            |  7 +++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_ims.c b/drivers/vfio/pci/vfio_pci_ims.c
index fe5b3484ad34..27711bc7a6c2 100644
--- a/drivers/vfio/pci/vfio_pci_ims.c
+++ b/drivers/vfio/pci/vfio_pci_ims.c
@@ -37,6 +37,27 @@ struct vfio_pci_ims_ctx {
 	union msi_instance_cookie	icookie;
 };
 
+/*
+ * Return IMS index of IMS interrupt backing MSI-X interrupt @vector
+ */
+int vfio_pci_ims_hwirq(struct vfio_device *vdev, unsigned int vector)
+{
+	struct vfio_pci_ims *ims = &vdev->ims;
+	struct vfio_pci_ims_ctx *ctx;
+	int id;
+
+	mutex_lock(&ims->ctx_mutex);
+	ctx = xa_load(&ims->ctx, vector);
+	if (!ctx || ctx->emulated)
+		id = -EINVAL;
+	else
+		id = ctx->ims_id;
+	mutex_unlock(&ims->ctx_mutex);
+
+	return id;
+}
+EXPORT_SYMBOL_GPL(vfio_pci_ims_hwirq);
+
 /*
  * Send signal to the eventfd.
  * @vdev:	VFIO device
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 906220002ff4..1c0e1bddd95b 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -339,6 +339,7 @@ int vfio_pci_ims_set_emulated(struct vfio_device *vdev, unsigned int start,
 void vfio_pci_ims_send_signal(struct vfio_device *vdev, unsigned int vector);
 int vfio_pci_ims_set_cookie(struct vfio_device *vdev, unsigned int vector,
 			    union msi_instance_cookie *icookie);
+int vfio_pci_ims_hwirq(struct vfio_device *vdev, unsigned int vector);
 #else
 static inline int vfio_pci_set_ims_trigger(struct vfio_device *vdev,
 					   unsigned int index,
@@ -374,6 +375,12 @@ static inline int vfio_pci_ims_set_cookie(struct vfio_device *vdev,
 	return -EOPNOTSUPP;
 }
 
+static inline int vfio_pci_ims_hwirq(struct vfio_device *vdev,
+				     unsigned int index)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif /* CONFIG_VFIO_PCI_IMS */
 
 #endif /* VFIO_H */
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ