From 94513ab724e429504da3ae2ae348900a0a342df4 Mon Sep 17 00:00:00 2001 From: Shuo Liu Date: Fri, 13 Jul 2018 15:47:18 +0800 Subject: [PATCH] dm: Add vhm ioeventfd and irqfd interfaces ioeventfd and irqfd support for vhm was introduced in kernel vhm module. We provide the interfaces of them for DM users. Tracked-On: #1329 Signed-off-by: Shuo Liu Acked-by: Yu Wang --- devicemodel/core/vmmapi.c | 12 +++++++++++ devicemodel/include/public/vhm_ioctl_defs.h | 23 +++++++++++++++++++++ devicemodel/include/vmmapi.h | 3 +++ 3 files changed, 38 insertions(+) diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 70439e5a8..63a426914 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -657,3 +657,15 @@ vm_intr_monitor(struct vmctx *ctx, void *intr_buf) { return ioctl(ctx->fd, IC_VM_INTR_MONITOR, intr_buf); } + +int +vm_ioeventfd(struct vmctx *ctx, struct acrn_ioeventfd *args) +{ + return ioctl(ctx->fd, IC_EVENT_IOEVENTFD, args); +} + +int +vm_irqfd(struct vmctx *ctx, struct acrn_irqfd *args) +{ + return ioctl(ctx->fd, IC_EVENT_IRQFD, args); +} diff --git a/devicemodel/include/public/vhm_ioctl_defs.h b/devicemodel/include/public/vhm_ioctl_defs.h index a0c2e3590..29a7e166a 100644 --- a/devicemodel/include/public/vhm_ioctl_defs.h +++ b/devicemodel/include/public/vhm_ioctl_defs.h @@ -112,6 +112,11 @@ #define VM_MEMMAP_SYSMEM 0 #define VM_MMIO 1 +/* VHM eventfd */ +#define IC_ID_EVENT_BASE 0x70UL +#define IC_EVENT_IOEVENTFD _IC_ID(IC_ID, IC_ID_EVENT_BASE + 0x00) +#define IC_EVENT_IRQFD _IC_ID(IC_ID, IC_ID_EVENT_BASE + 0x01) + /** * struct vm_memmap - EPT memory mapping info for guest */ @@ -204,4 +209,22 @@ struct api_version { uint32_t minor_version; }; +#define ACRN_IOEVENTFD_FLAG_PIO 0x01 +#define ACRN_IOEVENTFD_FLAG_DATAMATCH 0x02 +#define ACRN_IOEVENTFD_FLAG_DEASSIGN 0x04 +struct acrn_ioeventfd { + int32_t fd; + uint32_t flags; + uint64_t addr; + uint32_t len; + uint32_t reserved; + uint64_t data; +}; + +#define ACRN_IRQFD_FLAG_DEASSIGN 0x01 +struct acrn_irqfd { + int32_t fd; + uint32_t flags; + struct acrn_msi_entry msi; +}; #endif /* VHM_IOCTL_DEFS_H */ diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index 15dbd6cd6..299c5a8ad 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -155,4 +155,7 @@ int vm_get_cpu_state(struct vmctx *ctx, void *state_buf); int vm_intr_monitor(struct vmctx *ctx, void *intr_buf); void vm_stop_watchdog(struct vmctx *ctx); void vm_reset_watchdog(struct vmctx *ctx); + +int vm_ioeventfd(struct vmctx *ctx, struct acrn_ioeventfd *args); +int vm_irqfd(struct vmctx *ctx, struct acrn_irqfd *args); #endif /* _VMMAPI_H_ */