[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 02/18] arm/altp2m: Add first altp2m HVMOP stubs.
This commit moves the altp2m-related code from x86 to ARM. Functions that are no yet supported notify the caller or print a BUG message stating their absence. Also, the struct arch_domain is extended with the altp2m_active attribute, represeting the current altp2m activity configuration of the domain. Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx> --- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxx> --- xen/arch/arm/hvm.c | 82 ++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/altp2m.h | 22 ++++++++++-- xen/include/asm-arm/domain.h | 3 ++ 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c index 3615036..1118f22 100644 --- a/xen/arch/arm/hvm.c +++ b/xen/arch/arm/hvm.c @@ -32,6 +32,7 @@ #include <asm/hypercall.h> +#include <asm/altp2m.h> #include <asm/hvm/hvm.h> /* Xen command-line option enabling altp2m */ @@ -54,6 +55,83 @@ static int __init hvm_enable(void) } presmp_initcall(hvm_enable); +static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg) +{ + struct xen_hvm_altp2m_op a; + struct domain *d = NULL; + int rc = 0; + + if ( !hvm_altp2m_supported() ) + return -EOPNOTSUPP; + + if ( copy_from_guest(&a, arg, 1) ) + return -EFAULT; + + if ( a.pad1 || a.pad2 || + (a.version != HVMOP_ALTP2M_INTERFACE_VERSION) || + (a.cmd < HVMOP_altp2m_get_domain_state) || + (a.cmd > HVMOP_altp2m_change_gfn) ) + return -EINVAL; + + d = (a.cmd != HVMOP_altp2m_vcpu_enable_notify) ? + rcu_lock_domain_by_any_id(a.domain) : rcu_lock_current_domain(); + + if ( d == NULL ) + return -ESRCH; + + if ( (a.cmd != HVMOP_altp2m_get_domain_state) && + (a.cmd != HVMOP_altp2m_set_domain_state) && + !d->arch.altp2m_active ) + { + rc = -EOPNOTSUPP; + goto out; + } + + if ( (rc = xsm_hvm_altp2mhvm_op(XSM_TARGET, d)) ) + goto out; + + switch ( a.cmd ) + { + case HVMOP_altp2m_get_domain_state: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_set_domain_state: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_vcpu_enable_notify: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_create_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_destroy_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_switch_p2m: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_set_mem_access: + rc = -EOPNOTSUPP; + break; + + case HVMOP_altp2m_change_gfn: + rc = -EOPNOTSUPP; + break; + } + +out: + rcu_unlock_domain(d); + + return rc; +} + + long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { long rc = 0; @@ -102,6 +180,10 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) rc = -EINVAL; break; + case HVMOP_altp2m: + rc = do_altp2m_op(arg); + break; + default: { gdprintk(XENLOG_DEBUG, "HVMOP op=%lu: not implemented\n", op); diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h index a87747a..16ae9d6 100644 --- a/xen/include/asm-arm/altp2m.h +++ b/xen/include/asm-arm/altp2m.h @@ -2,6 +2,7 @@ * Alternate p2m * * Copyright (c) 2014, Intel Corporation. + * Copyright (c) 2016, Sergej Proskurin <proskurin@xxxxxxxxxxxxx>. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -24,8 +25,7 @@ /* Alternate p2m on/off per domain */ static inline bool_t altp2m_active(const struct domain *d) { - /* Not implemented on ARM. */ - return 0; + return d->arch.altp2m_active; } /* Alternate p2m VCPU */ @@ -36,4 +36,22 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v) return 0; } +static inline void altp2m_vcpu_initialise(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + +static inline void altp2m_vcpu_destroy(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + +static inline void altp2m_vcpu_reset(struct vcpu *v) +{ + /* Not implemented on ARM, should not be reached. */ + BUG(); +} + #endif /* __ASM_ARM_ALTP2M_H */ diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 979f7de..2039f16 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -127,6 +127,9 @@ struct arch_domain paddr_t efi_acpi_gpa; paddr_t efi_acpi_len; #endif + + /* altp2m: allow multiple copies of host p2m */ + bool_t altp2m_active; } __cacheline_aligned; struct arch_vcpu -- 2.8.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |