From: JunBin Li lijunbin4@huawei.com
virtCCA feature
JunBin Li (1): vfio struct modify
drivers/vfio/pci/vfio_pci_rdwr.c | 27 +++++++++++++++++++++++++-- include/linux/vfio.h | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-)
From: JunBin Li lijunbin4@huawei.com
virtcca inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IADD42
--------------------------------
virtCCA feature
Signed-off-by: JunBin Li lijunbin4@huawei.com --- drivers/vfio/pci/vfio_pci_rdwr.c | 27 +++++++++++++++++++++++++-- include/linux/vfio.h | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c index e27de61ac9..c71c058b71 100644 --- a/drivers/vfio/pci/vfio_pci_rdwr.c +++ b/drivers/vfio/pci/vfio_pci_rdwr.c @@ -18,6 +18,9 @@ #include <linux/vgaarb.h>
#include "vfio_pci_priv.h" +#ifdef CONFIG_HISI_VIRTCCA_HOST +#include <asm/kvm_tmi.h> +#endif
#ifdef __LITTLE_ENDIAN #define vfio_ioread64 ioread64 @@ -41,6 +44,11 @@ static int vfio_pci_iowrite##size(struct vfio_pci_core_device *vdev, \ bool test_mem, u##size val, void __iomem *io) \ { \ +#ifdef CONFIG_HISI_VIRTCCA_HOST \ + struct pci_dev *pdev = vdev->pdev; \ + bool cc_dev = pdev == NULL ? false : is_cc_dev(pci_dev_id(pdev)); \ + \ +#endif \ if (test_mem) { \ down_read(&vdev->memory_lock); \ if (!__vfio_pci_memory_enabled(vdev)) { \ @@ -49,7 +57,12 @@ static int vfio_pci_iowrite##size(struct vfio_pci_core_device *vdev, \ } \ } \ \ - vfio_iowrite##size(val, io); \ +#ifdef CONFIG_HISI_VIRTCCA_HOST \ + if (cc_dev) { \ + WARN_ON(tmi_mmio_write(va_to_pa(io), val, size, pci_dev_id(pdev))); \ + else \ +#endif \ + vfio_iowrite##size(val, io); \ \ if (test_mem) \ up_read(&vdev->memory_lock); \ @@ -68,6 +81,11 @@ VFIO_IOWRITE(64) static int vfio_pci_ioread##size(struct vfio_pci_core_device *vdev, \ bool test_mem, u##size *val, void __iomem *io) \ { \ +#ifdef CONFIG_HISI_VIRTCCA_HOST \ + struct pci_dev *pdev = vdev->pdev; \ + bool cc_dev = pdev == NULL ? false : is_cc_dev(pci_dev_id(pdev)); \ + \ +#endif \ if (test_mem) { \ down_read(&vdev->memory_lock); \ if (!__vfio_pci_memory_enabled(vdev)) { \ @@ -76,7 +94,12 @@ static int vfio_pci_ioread##size(struct vfio_pci_core_device *vdev, \ } \ } \ \ - *val = vfio_ioread##size(io); \ +#ifdef CONFIG_HISI_VIRTCCA_HOST \ + if (cc_dev) { \ + *val = tmi_mmio_read(va_to_pa(io), size, pci_dev_id(pdev)); \ + else \ +#endif \ + *val = vfio_ioread##size(io); \ \ if (test_mem) \ up_read(&vdev->memory_lock); \ diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 5ac5f182ce..d231eb5bf7 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -123,6 +123,11 @@ struct vfio_device_ops { void __user *arg, size_t argsz); };
+#ifdef CONFIG_HISI_VIRTCCA_HOST +extern bool vfio_iommu_group(struct vfio_group *vfio_group, struct iommu_group *iommu_group); +extern struct iommu_group *vfio_get_iommu_group(struct vfio_group *vfio_group); +#endif + #if IS_ENABLED(CONFIG_IOMMUFD) struct iommufd_ctx *vfio_iommufd_device_ictx(struct vfio_device *vdev); int vfio_iommufd_get_dev_id(struct vfio_device *vdev, struct iommufd_ctx *ictx);
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/10668 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/H...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/10668 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/H...