[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 21/20] arch/arm: replace rcu_lock_target_domain_by_id with XSM
Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> --- xen/arch/arm/hvm.c | 12 +++++++++--- xen/arch/arm/mm.c | 11 +++++++++-- xen/include/xsm/dummy.h | 29 +++++++++++++++-------------- xen/include/xsm/xsm.h | 25 +++++++++++++------------ 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index c11378d..3cb8eec 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -4,6 +4,7 @@ #include <xen/errno.h> #include <xen/guest_access.h> #include <xen/sched.h> +#include <xsm/xsm.h> #include <public/xen.h> #include <public/hvm/params.h> @@ -30,9 +31,13 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) if ( a.index >= HVM_NR_PARAMS ) return -EINVAL; - rc = rcu_lock_target_domain_by_id(a.domid, &d); - if ( rc != 0 ) - return rc; + d = rcu_lock_domain_by_any_id(a.domid); + if ( d == NULL ) + return -ESRCH; + + rc = xsm_hvm_param(d, op); + if ( rc ) + goto param_fail; if ( op == HVMOP_set_param ) { @@ -44,6 +49,7 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) rc = copy_to_guest(arg, &a, 1) ? -EFAULT : 0; } + param_fail: rcu_unlock_domain(d); break; } diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 40ac176..ffef978 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -31,6 +31,7 @@ #include <asm/current.h> #include <public/memory.h> #include <xen/sched.h> +#include <xsm/xsm.h> struct domain *dom_xen, *dom_io; @@ -508,9 +509,15 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) if ( copy_from_guest(&xatp, arg, 1) ) return -EFAULT; - rc = rcu_lock_target_domain_by_id(xatp.domid, &d); - if ( rc != 0 ) + d = rcu_lock_domain_by_any_id(xatp.domid); + if ( d == NULL ) + return -ESRCH; + rc = xsm_add_to_physmap(current->domain, d); + if ( rc ) + { + rcu_unlock_domain(d); return rc; + } rc = xenmem_add_to_physmap(d, &xatp); diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 16ad33a..d2a8879 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -568,6 +568,21 @@ static XSM_DEFAULT(int, pci_config_permission) (struct domain *d, uint32_t machi return 0; } +static XSM_DEFAULT(int, hvm_param) (struct domain *d, unsigned long op) +{ + if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) ) + return -EPERM; + return 0; +} + +static XSM_DEFAULT(int, add_to_physmap) (struct domain *d1, struct domain *d2) +{ + if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) ) + return -EPERM; + return 0; +} + + #ifdef CONFIG_X86 static XSM_DEFAULT(int, shadow_control) (struct domain *d, uint32_t op) { @@ -639,13 +654,6 @@ static XSM_DEFAULT(int, machine_address_size) (struct domain *d, uint32_t cmd) return 0; } -static XSM_DEFAULT(int, hvm_param) (struct domain *d, unsigned long op) -{ - if ( current->domain != d && !IS_PRIV_FOR(current->domain, d) ) - return -EPERM; - return 0; -} - static XSM_DEFAULT(int, hvm_set_pci_intx_level) (struct domain *d) { if ( !IS_PRIV_FOR(current->domain, d) ) @@ -840,13 +848,6 @@ static XSM_DEFAULT(int, update_va_mapping) (struct domain *d, struct domain *f, return 0; } -static XSM_DEFAULT(int, add_to_physmap) (struct domain *d1, struct domain *d2) -{ - if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) ) - return -EPERM; - return 0; -} - static XSM_DEFAULT(int, remove_from_physmap) (struct domain *d1, struct domain *d2) { if ( d1 != d2 && !IS_PRIV_FOR(d1, d2) ) diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 8c11172..d0538b4 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -140,6 +140,9 @@ struct xsm_operations { long (*__do_xsm_op) (XEN_GUEST_HANDLE(xsm_op_t) op); + int (*hvm_param) (struct domain *d, unsigned long op); + int (*add_to_physmap) (struct domain *d1, struct domain *d2); + #ifdef CONFIG_X86 int (*shadow_control) (struct domain *d, uint32_t op); int (*getpageframeinfo) (struct domain *d); @@ -151,7 +154,6 @@ struct xsm_operations { int (*hvmcontext) (struct domain *d, uint32_t op); int (*address_size) (struct domain *d, uint32_t op); int (*machine_address_size) (struct domain *d, uint32_t op); - int (*hvm_param) (struct domain *d, unsigned long op); int (*hvm_set_pci_intx_level) (struct domain *d); int (*hvm_set_isa_irq_level) (struct domain *d); int (*hvm_set_pci_link_route) (struct domain *d); @@ -180,7 +182,6 @@ struct xsm_operations { int (*mmu_machphys_update) (struct domain *d1, struct domain *d2, unsigned long mfn); int (*mmuext_op) (struct domain *d, struct domain *f); int (*update_va_mapping) (struct domain *d, struct domain *f, l1_pgentry_t pte); - int (*add_to_physmap) (struct domain *d1, struct domain *d2); int (*sendtrigger) (struct domain *d); int (*bind_pt_irq) (struct domain *d, struct xen_domctl_bind_pt_irq *bind); int (*unbind_pt_irq) (struct domain *d, struct xen_domctl_bind_pt_irq *bind); @@ -621,6 +622,16 @@ static inline long xsm___do_xsm_op (XEN_GUEST_HANDLE(xsm_op_t) op) return xsm_ops->__do_xsm_op(op); } +static inline int xsm_hvm_param (struct domain *d, unsigned long op) +{ + return xsm_ops->hvm_param(d, op); +} + +static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2) +{ + return xsm_ops->add_to_physmap(d1, d2); +} + #ifdef CONFIG_X86 static inline int xsm_shadow_control (struct domain *d, uint32_t op) { @@ -672,11 +683,6 @@ static inline int xsm_machine_address_size (struct domain *d, uint32_t cmd) return xsm_ops->machine_address_size(d, cmd); } -static inline int xsm_hvm_param (struct domain *d, unsigned long op) -{ - return xsm_ops->hvm_param(d, op); -} - static inline int xsm_hvm_set_pci_intx_level (struct domain *d) { return xsm_ops->hvm_set_pci_intx_level(d); @@ -815,11 +821,6 @@ static inline int xsm_update_va_mapping(struct domain *d, struct domain *f, return xsm_ops->update_va_mapping(d, f, pte); } -static inline int xsm_add_to_physmap(struct domain *d1, struct domain *d2) -{ - return xsm_ops->add_to_physmap(d1, d2); -} - static inline int xsm_sendtrigger(struct domain *d) { return xsm_ops->sendtrigger(d); -- 1.7.11.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |