[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] arm: clobber only argument registers
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1343234360 -3600 # Node ID 7118869c9cbee6d8bd850aa58ebec00e6486fb16 # Parent 2859b79fbbc7bf09f3113a36789826a732b0fdca arm: clobber only argument registers Previously it was declared that r1..r4 would all be clobbered by all hypercalls. Instead declare that only actually used hypercall argument registers are clobbered. This is more inline with generally expected conventions and allows for more optimal code in the caller in some cases. This is an ABI change, although an older guest which expects more things to be clobbered than we do now won't be adversely impacted. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- diff -r 2859b79fbbc7 -r 7118869c9cbe xen/arch/arm/traps.c --- a/xen/arch/arm/traps.c Wed Jul 25 17:39:19 2012 +0100 +++ b/xen/arch/arm/traps.c Wed Jul 25 17:39:20 2012 +0100 @@ -413,24 +413,31 @@ unsigned long do_arch_0(unsigned int cmd return 0; } -typedef unsigned long arm_hypercall_t( +typedef unsigned long (*arm_hypercall_fn_t)( unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); -#define HYPERCALL(x) \ - [ __HYPERVISOR_ ## x ] = (arm_hypercall_t *) do_ ## x +typedef struct { + arm_hypercall_fn_t fn; + int nr_args; +} arm_hypercall_t; -static arm_hypercall_t *arm_hypercall_table[] = { - HYPERCALL(memory_op), - HYPERCALL(domctl), - HYPERCALL(arch_0), - HYPERCALL(sched_op), - HYPERCALL(console_io), - HYPERCALL(xen_version), - HYPERCALL(event_channel_op), - HYPERCALL(memory_op), - HYPERCALL(physdev_op), - HYPERCALL(sysctl), - HYPERCALL(hvm_op), +#define HYPERCALL(_name, _nr_args) \ + [ __HYPERVISOR_ ## _name ] = { \ + .fn = (arm_hypercall_fn_t) &do_ ## _name, \ + .nr_args = _nr_args, \ + } + +static arm_hypercall_t arm_hypercall_table[] = { + HYPERCALL(memory_op, 2), + HYPERCALL(domctl, 1), + HYPERCALL(arch_0, 2), + HYPERCALL(sched_op, 2), + HYPERCALL(console_io, 3), + HYPERCALL(xen_version, 2), + HYPERCALL(event_channel_op, 2), + HYPERCALL(physdev_op, 2), + HYPERCALL(sysctl, 2), + HYPERCALL(hvm_op, 2), }; static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) @@ -462,7 +469,7 @@ static void do_debug_trap(struct cpu_use static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss) { - arm_hypercall_t *call = NULL; + arm_hypercall_fn_t call = NULL; if ( iss != XEN_HYPERCALL_TAG ) { @@ -472,7 +479,7 @@ static void do_trap_hypercall(struct cpu return; } - call = arm_hypercall_table[regs->r12]; + call = arm_hypercall_table[regs->r12].fn; if ( call == NULL ) { regs->r0 = -ENOSYS; @@ -482,8 +489,17 @@ static void do_trap_hypercall(struct cpu regs->r0 = call(regs->r0, regs->r1, regs->r2, regs->r3, regs->r4); #ifndef NDEBUG - /* clobber registers */ - regs->r1 = regs->r2 = regs->r3 = regs->r4 = regs->r12 = 0xDEADBEEF; + /* Clobber argument registers */ + switch ( arm_hypercall_table[regs->r12].nr_args ) { + case 5: regs->r4 = 0xDEADBEEF; + case 4: regs->r3 = 0xDEADBEEF; + case 3: regs->r2 = 0xDEADBEEF; + case 2: regs->r1 = 0xDEADBEEF; + case 1: /* Don't clobber r0 -- it's the return value */ + break; + default: BUG(); + } + regs->r12 = 0xDEADBEEF; #endif } diff -r 2859b79fbbc7 -r 7118869c9cbe xen/include/public/arch-arm.h --- a/xen/include/public/arch-arm.h Wed Jul 25 17:39:19 2012 +0100 +++ b/xen/include/public/arch-arm.h Wed Jul 25 17:39:20 2012 +0100 @@ -42,8 +42,10 @@ * * The return value is in r0. * - * The hypercall will always clobber r0, r1, r2, r3, r4 and r12, - * regardless of how many arguments the particular hypercall takes. + * The hypercall will clobber r12 and the argument registers used by + * that hypercall (except r0 which is the return value) i.e. a 2 + * argument hypercall will clobber r1 and a 4 argument hypercall will + * clobber r1, r2 and r3. * */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |