From 158f3d17a26daafc8719ebcec4e40e9b15d78885 Mon Sep 17 00:00:00 2001 From: Li Fei1 Date: Thu, 16 Jul 2020 13:56:21 +0800 Subject: [PATCH] dm: mmio_dev: add hypercall to support mmio device pass through Add two hypercalls to support MMIO device pass through. Tracked-On: #5053 Signed-off-by: Li Fei1 Reviewed-by: Eddie Dong --- devicemodel/core/vmmapi.c | 12 ++++++++++++ devicemodel/include/public/vhm_ioctl_defs.h | 20 ++++++++++++++++++++ devicemodel/include/vmmapi.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index f7903207b..5365610f1 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -572,6 +572,18 @@ vm_deassign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev) return ioctl(ctx->fd, IC_DEASSIGN_PCIDEV, pcidev); } +int +vm_assign_mmiodev(struct vmctx *ctx, struct acrn_mmiodev *mmiodev) +{ + return ioctl(ctx->fd, IC_ASSIGN_MMIODEV, mmiodev); +} + +int +vm_deassign_mmiodev(struct vmctx *ctx, struct acrn_mmiodev *mmiodev) +{ + return ioctl(ctx->fd, IC_DEASSIGN_MMIODEV, mmiodev); +} + int vm_map_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func, vm_paddr_t gpa, size_t len, vm_paddr_t hpa) diff --git a/devicemodel/include/public/vhm_ioctl_defs.h b/devicemodel/include/public/vhm_ioctl_defs.h index 1e6571164..dcf8d028d 100644 --- a/devicemodel/include/public/vhm_ioctl_defs.h +++ b/devicemodel/include/public/vhm_ioctl_defs.h @@ -107,6 +107,8 @@ #define IC_RESET_PTDEV_INTR_INFO _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x04) #define IC_ASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x05) #define IC_DEASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x06) +#define IC_ASSIGN_MMIODEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x07) +#define IC_DEASSIGN_MMIODEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x08) /* Power management */ #define IC_ID_PM_BASE 0x60UL @@ -182,6 +184,24 @@ struct acrn_assign_pcidev { } __attribute__((aligned(8))); +/** + * @brief Info to assign or deassign a MMIO device for a VM + */ +struct acrn_mmiodev { + /** the gpa of the MMIO region for the MMIO device */ + uint64_t base_gpa; + + /** the hpa of the MMIO region for the MMIO device */ + uint64_t base_hpa; + + /** the size of the MMIO region for the MMIO device */ + uint64_t size; + + /** reserved for extension */ + uint64_t reserved[13]; + +} __attribute__((aligned(8))); + /** * @brief pass thru device irq data structure */ diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index f3ba7a047..99dce96e4 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -126,6 +126,8 @@ int vm_lapic_msi(struct vmctx *ctx, uint64_t addr, uint64_t msg); int vm_set_gsi_irq(struct vmctx *ctx, int gsi, uint32_t operation); int vm_assign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev); int vm_deassign_pcidev(struct vmctx *ctx, struct acrn_assign_pcidev *pcidev); +int vm_assign_mmiodev(struct vmctx *ctx, struct acrn_mmiodev *mmiodev); +int vm_deassign_mmiodev(struct vmctx *ctx, struct acrn_mmiodev *mmiodev); int vm_map_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func, vm_paddr_t gpa, size_t len, vm_paddr_t hpa); int vm_unmap_ptdev_mmio(struct vmctx *ctx, int bus, int slot, int func,