[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/25] 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 | 3 +++ xen/common/viommu.c | 43 +++++++++++++++++++++++++++++++++++++++++++ xen/include/public/domctl.h | 40 ++++++++++++++++++++++++++++++++++++++++ xen/include/xen/viommu.h | 6 ++++++ 4 files changed, 92 insertions(+) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 951a5dc..a178544 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -1141,6 +1141,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) if ( !ret ) copyback = 1; break; + case XEN_DOMCTL_viommu_op: + ret = viommu_domctl(d, &op->u.viommu_op, ©back); + break; default: ret = arch_do_domctl(op, d, u_domctl); diff --git a/xen/common/viommu.c b/xen/common/viommu.c index 19ba529..ffb2118 100644 --- a/xen/common/viommu.c +++ b/xen/common/viommu.c @@ -146,6 +146,49 @@ static u64 viommu_query_caps(struct domain *d, u64 type) return viommu_type->ops->query_caps(d); } +int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, + bool *need_copy) +{ + int rc = -EINVAL, ret; + + if ( !viommu_enabled() ) + return rc; + + switch ( op->cmd ) + { + case XEN_DOMCTL_create_viommu: + ret = viommu_create(d, op->u.create_viommu.viommu_type, + op->u.create_viommu.base_address, + op->u.create_viommu.length, + op->u.create_viommu.capabilities); + if ( ret >= 0 ) { + op->u.create_viommu.viommu_id = ret; + *need_copy = true; + rc = 0; /* return 0 if success */ + } + break; + + case XEN_DOMCTL_destroy_viommu: + rc = viommu_destroy(d, op->u.destroy_viommu.viommu_id); + break; + + case XEN_DOMCTL_query_viommu_caps: + ret = viommu_query_caps(d, op->u.query_caps.viommu_type); + if ( ret >= 0 ) + { + op->u.query_caps.caps = ret; + rc = 0; + } + *need_copy = true; + break; + + default: + break; + } + + return rc; +} + int __init viommu_setup(void) { INIT_LIST_HEAD(&type_list); diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index f7cbc0a..7581df3 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1141,6 +1141,44 @@ 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); +struct xen_domctl_viommu_op { + uint32_t cmd; +#define XEN_DOMCTL_create_viommu 0 +#define XEN_DOMCTL_destroy_viommu 1 +#define XEN_DOMCTL_query_viommu_caps 2 + 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 and length. + */ + uint64_t base_address; + /* IN - Length of MMIO region */ + uint64_t length; + /* IN - Capabilities with which we want to create */ + uint64_t capabilities; + /* OUT - vIOMMU identity */ + uint32_t viommu_id; + } create_viommu; + + struct { + /* IN - vIOMMU identity */ + uint32_t viommu_id; + } destroy_viommu; + + struct { + /* IN - vIOMMU type */ + uint64_t viommu_type; + /* OUT - vIOMMU Capabilities */ + uint64_t caps; + } query_caps; + } 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 @@ -1218,6 +1256,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 @@ -1280,6 +1319,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 0a93aa4..bce6825 100644 --- a/xen/include/xen/viommu.h +++ b/xen/include/xen/viommu.h @@ -49,6 +49,8 @@ extern bool_t opt_viommu; static inline bool_t viommu_enabled(void) { return opt_viommu; } int viommu_init_domain(struct domain *d); int viommu_register_type(u64 type, struct viommu_ops * ops); +int viommu_domctl(struct domain *d, struct xen_domctl_viommu_op *op, + bool_t *need_copy); int viommu_setup(void); #else static inline int viommu_init_domain(struct domain *d) { return 0; } @@ -56,6 +58,10 @@ static inline int viommu_register_type(u64 type, struct viommu_ops * ops) { return 0; } static inline int __init viommu_setup(void) { return 0; } static inline bool_t viommu_enabled(void) { return 0; } +static inline int viommu_domctl(struct domain *d, + struct xen_domctl_viommu_op *op, + bool_t *need_copy) +{ return -ENODEV }; #endif #endif /* __XEN_VIOMMU_H__ */ -- 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 |