From 3b35a673e6b8e83f2f51b49e6c7ebd91a2c61eeb Mon Sep 17 00:00:00 2001 From: yichongt Date: Fri, 28 Jun 2024 11:08:00 +0800 Subject: [PATCH] dm: pio_region: add support for pio device pass through Add two vmmapi vm_assign_pio_region and vm_deassign_pio_region to support PIO device pass through. Tracked-On: #8635 Signed-off-by: Yichong Tang Reviewed-by: Jian Jun Chen --- devicemodel/core/vmmapi.c | 22 +++++++++++++++++++++ devicemodel/include/public/hsm_ioctl_defs.h | 4 ++++ devicemodel/include/vmmapi.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 0dbc1286e..637e04844 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -592,6 +592,28 @@ vm_deassign_mmiodev(struct vmctx *ctx, struct acrn_mmiodev *mmiodev) return error; } +int +vm_assign_pio_region(struct vmctx *ctx, struct acrn_pio_region *pio_region) +{ + int error; + error = ioctl(ctx->fd, ACRN_IOCTL_ASSIGN_PIO_REGION, pio_region); + if (error) { + pr_err("ACRN_IOCTL_ASSIGN_PIO_REGION ioctl() returned an error: %s\n", errormsg(errno)); + } + return error; +} + +int +vm_deassign_pio_region(struct vmctx *ctx, struct acrn_pio_region *pio_region) +{ + int error; + error = ioctl(ctx->fd, ACRN_IOCTL_DEASSIGN_PIO_REGION, pio_region); + if (error) { + pr_err("ACRN_IOCTL_DEASSIGN_PIO_REGION ioctl() returned an error: %s\n", errormsg(errno)); + } + return error; +} + 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/hsm_ioctl_defs.h b/devicemodel/include/public/hsm_ioctl_defs.h index 4e7968bef..b8e41936c 100644 --- a/devicemodel/include/public/hsm_ioctl_defs.h +++ b/devicemodel/include/public/hsm_ioctl_defs.h @@ -125,6 +125,10 @@ _IOW(ACRN_IOCTL_TYPE, 0x59, struct acrn_vdev) #define ACRN_IOCTL_DESTROY_VDEV \ _IOW(ACRN_IOCTL_TYPE, 0x5A, struct acrn_vdev) +#define ACRN_IOCTL_ASSIGN_PIO_REGION \ + _IOW(ACRN_IOCTL_TYPE, 0x5B, struct acrn_pio_region) +#define ACRN_IOCTL_DEASSIGN_PIO_REGION \ + _IOW(ACRN_IOCTL_TYPE, 0x5C, struct acrn_pio_region) /* Power management */ #define ACRN_IOCTL_PM_GET_CPU_STATE \ diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index 3109adc7f..4abd410d0 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -137,6 +137,8 @@ int vm_assign_pcidev(struct vmctx *ctx, struct acrn_pcidev *pcidev); int vm_deassign_pcidev(struct vmctx *ctx, struct acrn_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_assign_pio_region(struct vmctx *ctx, struct acrn_pio_region *pio_region); +int vm_deassign_pio_region(struct vmctx *ctx, struct acrn_pio_region *pio_region); 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,