[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V3 3/29] DOMCTL: Introduce new DOMCTL commands for vIOMMU support
This patch is to introduce create, destroy and query capabilities command for vIOMMU. vIOMMU layer will deal with requests and call arch vIOMMU ops. Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx> --- xen/common/domctl.c | 6 ++++++ xen/common/viommu.c | 30 ++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 42 ++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/viommu.h | 2 ++ 4 files changed, 80 insertions(+) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 42658e5..7e28237 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -1149,6 +1149,12 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) copyback = 1; break; +#ifdef CONFIG_VIOMMU + case XEN_DOMCTL_viommu_op: + ret = viommu_domctl(d, &op->u.viommu_op, ©back); + break; +#endif + default: ret = arch_do_domctl(op, d, u_domctl); break; diff --git a/xen/common/viommu.c b/xen/common/viommu.c index 64d91e6..55feb5d 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -133,6 +133,36 @@ static int viommu_create(struct domain *d, uint64_t type, return 0; } +int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, + bool *need_copy) +{ + int rc = -EINVAL; + + if ( !viommu_enabled() ) + return -ENODEV; + + switch ( op->cmd ) + { + case XEN_DOMCTL_create_viommu: + rc = viommu_create(d, op->u.create.viommu_type, + op->u.create.base_address, + op->u.create.capabilities, + &op->u.create.viommu_id); + if ( !rc ) + *need_copy = true; + break; + + case XEN_DOMCTL_destroy_viommu: + rc = viommu_destroy_domain(d); + break; + + default: + return -ENOSYS; + } + + return rc; +} + /* * Local variables: * mode: C diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 50ff58f..68854b6 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1163,6 +1163,46 @@ struct xen_domctl_psr_cat_op { typedef struct xen_domctl_psr_cat_op xen_domctl_psr_cat_op_t; DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cat_op_t); +/* vIOMMU helper + * + * vIOMMU interface can be used to create/destroy vIOMMU and + * query vIOMMU capabilities. + */ + +/* vIOMMU type - specify vendor vIOMMU device model */ +#define VIOMMU_TYPE_INTEL_VTD 0 + +/* vIOMMU capabilities */ +#define VIOMMU_CAP_IRQ_REMAPPING (1u << 0) + +struct xen_domctl_viommu_op { + uint32_t cmd; +#define XEN_DOMCTL_create_viommu 0 +#define XEN_DOMCTL_destroy_viommu 1 + union { + struct { + /* IN - vIOMMU type */ + uint64_t viommu_type; + /* + * IN - MMIO base address of vIOMMU. vIOMMU device models + * are in charge of to check base_address. + */ + uint64_t base_address; + /* IN - Capabilities with which we want to create */ + uint64_t capabilities; + /* OUT - vIOMMU identity */ + uint32_t viommu_id; + } create; + + struct { + /* IN - vIOMMU identity */ + uint32_t viommu_id; + } destroy; + } u; +}; +typedef struct xen_domctl_viommu_op xen_domctl_viommu_op; +DEFINE_XEN_GUEST_HANDLE(xen_domctl_viommu_op); + struct xen_domctl { uint32_t cmd; #define XEN_DOMCTL_createdomain 1 @@ -1240,6 +1280,7 @@ struct xen_domctl { #define XEN_DOMCTL_monitor_op 77 #define XEN_DOMCTL_psr_cat_op 78 #define XEN_DOMCTL_soft_reset 79 +#define XEN_DOMCTL_viommu_op 80 #define XEN_DOMCTL_gdbsx_guestmemio 1000 #define XEN_DOMCTL_gdbsx_pausevcpu 1001 #define XEN_DOMCTL_gdbsx_unpausevcpu 1002 @@ -1302,6 +1343,7 @@ struct xen_domctl { struct xen_domctl_psr_cmt_op psr_cmt_op; struct xen_domctl_monitor_op monitor_op; struct xen_domctl_psr_cat_op psr_cat_op; + struct xen_domctl_viommu_op viommu_op; uint8_t pad[128]; } u; }; diff --git a/xen/include/xen/viommu.h b/xen/include/xen/viommu.h index 636a2a3..baa8ab7 100644 --- a/xen/include/xen/viommu.h +++ b/xen/include/xen/viommu.h @@ -43,6 +43,8 @@ static inline bool viommu_enabled(void) int viommu_register_type(uint64_t type, struct viommu_ops *ops); int viommu_destroy_domain(struct domain *d); +int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, + bool_t *need_copy); #else static inline int viommu_register_type(uint64_t type, struct viommu_ops *ops) { -- 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |