[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH v4 08/11] xen: arm: implement platform hypercall
This patch enables xsm_platform_op hook for all architectures and implements platform hypercall for ARM. Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@xxxxxxxxxxxxxxx> --- xen/arch/arm/Makefile | 1 + xen/arch/arm/platform_hypercall.c | 84 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/traps.c | 1 + xen/include/xsm/dummy.h | 12 +++--- xen/include/xsm/xsm.h | 10 ++--- xen/xsm/flask/hooks.c | 3 +- 6 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 xen/arch/arm/platform_hypercall.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index d70f6d5..54d8258 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -32,6 +32,7 @@ obj-y += vuart.o obj-y += hvm.o obj-y += device.o obj-y += decode.o +obj-y += platform_hypercall.o #obj-bin-y += ....o diff --git a/xen/arch/arm/platform_hypercall.c b/xen/arch/arm/platform_hypercall.c new file mode 100644 index 0000000..f14641b --- /dev/null +++ b/xen/arch/arm/platform_hypercall.c @@ -0,0 +1,84 @@ +/****************************************************************************** + * platform_hypercall.c + * + * Hardware platform operations. Intended for use by domain-0 kernel. + * + * Copyright (c) 2014 GlobalLogic Inc. + */ + +#include <xen/config.h> +#include <xen/types.h> +#include <xen/sched.h> +#include <xen/event.h> +#include <xen/guest_access.h> +#include <xen/pmstat.h> +#include <xen/irq.h> +#include <public/platform.h> +#include <xsm/xsm.h> + +static DEFINE_SPINLOCK(xenpf_lock); + +long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op) +{ + long ret = 0; + struct xen_platform_op curop, *op = &curop; + + if ( copy_from_guest(op, u_xenpf_op, 1) ) + return -EFAULT; + + if ( op->interface_version != XENPF_INTERFACE_VERSION ) + return -EACCES; + + ret = xsm_platform_op(XSM_PRIV, op->cmd); + if ( ret ) + return ret; + + /* + * Trylock here avoids deadlock with an existing platform critical section + * which might (for some current or future reason) want to synchronise + * with this vcpu. + */ + while ( !spin_trylock(&xenpf_lock) ) + if ( hypercall_preempt_check() ) + return hypercall_create_continuation( + __HYPERVISOR_platform_op, "h", u_xenpf_op); + + switch ( op->cmd ) + { + case XENPF_set_processor_pminfo: + switch ( op->u.set_pminfo.type ) + { + case XEN_PM_PX: + if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) ) + { + ret = -ENOSYS; + break; + } +#ifdef HAS_CPUFREQ + ret = set_px_pminfo(op->u.set_pminfo.id, &op->u.set_pminfo.u.perf); +#else + ret = -EINVAL; +#endif + break; + + default: + ret = -EINVAL; + break; + } + break; + } + + spin_unlock(&xenpf_lock); + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 21c7b26..d1b0014 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1012,6 +1012,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL(hvm_op, 2), HYPERCALL(grant_table_op, 3), HYPERCALL_ARM(vcpu_op, 3), + HYPERCALL(platform_op, 1), }; typedef int (*arm_psci_fn_t)(uint32_t, register_t); diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index eb9e1a1..911fb5d 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -491,6 +491,12 @@ static XSM_INLINE int xsm_hvm_param_nested(XSM_DEFAULT_ARG struct domain *d) return xsm_default_action(action, current->domain, d); } +static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op) +{ + XSM_ASSERT_ACTION(XSM_PRIV); + return xsm_default_action(action, current->domain, NULL); +} + #ifdef CONFIG_X86 static XSM_INLINE int xsm_shadow_control(XSM_DEFAULT_ARG struct domain *d, uint32_t op) { @@ -546,12 +552,6 @@ static XSM_INLINE int xsm_apic(XSM_DEFAULT_ARG struct domain *d, int cmd) return xsm_default_action(action, d, NULL); } -static XSM_INLINE int xsm_platform_op(XSM_DEFAULT_ARG uint32_t op) -{ - XSM_ASSERT_ACTION(XSM_PRIV); - return xsm_default_action(action, current->domain, NULL); -} - static XSM_INLINE int xsm_machine_memory_map(XSM_DEFAULT_VOID) { XSM_ASSERT_ACTION(XSM_PRIV); diff --git a/xen/include/xsm/xsm.h b/xen/include/xsm/xsm.h index 1939453..5cb1e0d 100644 --- a/xen/include/xsm/xsm.h +++ b/xen/include/xsm/xsm.h @@ -509,6 +509,11 @@ static inline int xsm_hvm_param_nested (xsm_default_t def, struct domain *d) return xsm_ops->hvm_param_nested(d); } +static inline int xsm_platform_op (xsm_default_t def, uint32_t op) +{ + return xsm_ops->platform_op(op); +} + #ifdef CONFIG_X86 static inline int xsm_shadow_control (xsm_default_t def, struct domain *d, uint32_t op) { @@ -560,11 +565,6 @@ static inline int xsm_memtype (xsm_default_t def, uint32_t access) return xsm_ops->memtype(access); } -static inline int xsm_platform_op (xsm_default_t def, uint32_t op) -{ - return xsm_ops->platform_op(op); -} - static inline int xsm_machine_memory_map(xsm_default_t def) { return xsm_ops->machine_memory_map(); diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c index d94ab77..29126ec 100644 --- a/xen/xsm/flask/hooks.c +++ b/xen/xsm/flask/hooks.c @@ -1542,6 +1542,8 @@ static struct xsm_operations flask_ops = { .add_to_physmap = flask_add_to_physmap, .remove_from_physmap = flask_remove_from_physmap, + .platform_op = flask_platform_op, + #ifdef CONFIG_X86 .shadow_control = flask_shadow_control, .hvm_set_pci_intx_level = flask_hvm_set_pci_intx_level, @@ -1552,7 +1554,6 @@ static struct xsm_operations flask_ops = { .mem_event_op = flask_mem_event_op, .mem_sharing_op = flask_mem_sharing_op, .apic = flask_apic, - .platform_op = flask_platform_op, .machine_memory_map = flask_machine_memory_map, .domain_memory_map = flask_domain_memory_map, .mmu_update = flask_mmu_update, -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |