|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] don't pass r12/x16 as reference
Hi Stefano, On 01/13/2018 12:07 AM, Stefano Stabellini wrote: r12 and x16 are of different sizes; when passing r12 as a reference to do_trap_hypercall on arm64, we end up dereferencing it as a pointer to a 64bit value, but actually it isn't. Instead, pass r12/x16 as values and explicitly overwrite them when necessary, using the pointer name. CID: 1457708 Signed-off-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 013c160..3b31917 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1453,6 +1453,7 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)#ifdef CONFIG_ARM_64#define HYPERCALL_RESULT_REG(r) (r)->x0 +#define HYPERCALL_NR(r) (r)->x16 #define HYPERCALL_ARG1(r) (r)->x0 #define HYPERCALL_ARG2(r) (r)->x1 #define HYPERCALL_ARG3(r) (r)->x2 @@ -1461,6 +1462,7 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) #define HYPERCALL_ARGS(r) (r)->x0, (r)->x1, (r)->x2, (r)->x3, (r)->x4 #else #define HYPERCALL_RESULT_REG(r) (r)->r0 +#define HYPERCALL_NR(r) (r)->r12 #define HYPERCALL_ARG1(r) (r)->r0 #define HYPERCALL_ARG2(r) (r)->r1 #define HYPERCALL_ARG3(r) (r)->r2 @@ -1469,7 +1471,7 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code) #define HYPERCALL_ARGS(r) (r)->r0, (r)->r1, (r)->r2, (r)->r3, (r)->r4 #endif-static void do_trap_hypercall(struct cpu_user_regs *regs, register_t *nr, This change is not correct. You don't take into account the fact that on 32-bit domain, the result register will be r12 and 64-bit domain x16.
IHMO it would be better to avoid modify do_trap_hypercall and just save r12 in a temporary variable, use that variable as 2 second argument and write-back the variable in r12. This would make do_trap_hypercall future proof. Cheers, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |