Skip to contentSkip to conversation

xen: arm: correct guest PSCI handling on 64-bit hypervisor.

PATCH In review Ian Campbell 2 participants 3 messages Jan 14, 2014 – Jan 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: arm: correct guest PSCI handling on 64-bit hypervisor.

Using ->rN truncates the 64-bit registers to 32-bits, which on X-gene chops off the top bit of the entry address for PSCI_UP.

Follow the pattern established in do_trap_hypercall.

---

Release argument: Only supporting single vcpu guests on arm64 would be unfortunate. There is no risk to arm32 since the ifdef ensures the code remains the same.

---
 xen/arch/arm/traps.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/arm/traps.c +14 -3
index fdf9440..62c9df2 100644
@@ -1065,23 +1065,34 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
 }
 #endif
 
+#ifdef CONFIG_ARM_64
+#define PSCI_OP_REG(r) (r)->x0
+#define PSCI_RESULT_REG(r) (r)->x0
+#define PSCI_ARGS(r) (r)->x1, (r)->x2
+#else
+#define PSCI_OP_REG(r) (r)->r0
+#define PSCI_RESULT_REG(r) (r)->r0
+#define PSCI_ARGS(r) (r)->r1, (r)->r2
+#endif
+
 static void do_trap_psci(struct cpu_user_regs *regs)
 {
     arm_psci_fn_t psci_call = NULL;
 
-    if ( regs->r0 >= ARRAY_SIZE(arm_psci_table) )
+    if ( PSCI_OP_REG(regs) >= ARRAY_SIZE(arm_psci_table) )
     {
         domain_crash_synchronous();
         return;
     }
 
-    psci_call = arm_psci_table[regs->r0].fn;
+    psci_call = arm_psci_table[PSCI_OP_REG(regs)].fn;
     if ( psci_call == NULL )
     {
         domain_crash_synchronous();
         return;
     }
-    regs->r0 = psci_call(regs->r1, regs->r2);
+
+    PSCI_RESULT_REG(regs) = psci_call(PSCI_ARGS(regs));
 }
 
 #ifdef CONFIG_ARM_64
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ian Campbell

Using ->rN truncates the 64-bit registers to 32-bits, which on X-gene chops off the top bit of the entry address for PSCI_UP.

Follow the pattern established in do_trap_hypercall.

Quoted 52 lines

---

Release argument: Only supporting single vcpu guests on arm64 would be unfortunate. There is no risk to arm32 since the ifdef ensures the code remains the same.

---
 xen/arch/arm/traps.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/arm/traps.c +14 -3
index fdf9440..62c9df2 100644
@@ -1065,23 +1065,34 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
 }
 #endif
 
+#ifdef CONFIG_ARM_64
+#define PSCI_OP_REG(r) (r)->x0
+#define PSCI_RESULT_REG(r) (r)->x0
+#define PSCI_ARGS(r) (r)->x1, (r)->x2
+#else
+#define PSCI_OP_REG(r) (r)->r0
+#define PSCI_RESULT_REG(r) (r)->r0
+#define PSCI_ARGS(r) (r)->r1, (r)->r2
+#endif
+
 static void do_trap_psci(struct cpu_user_regs *regs)
 {
     arm_psci_fn_t psci_call = NULL;
 
-    if ( regs->r0 >= ARRAY_SIZE(arm_psci_table) )
+    if ( PSCI_OP_REG(regs) >= ARRAY_SIZE(arm_psci_table) )
     {
         domain_crash_synchronous();
         return;
     }
 
-    psci_call = arm_psci_table[regs->r0].fn;
+    psci_call = arm_psci_table[PSCI_OP_REG(regs)].fn;
     if ( psci_call == NULL )
     {
         domain_crash_synchronous();
         return;
     }
-    regs->r0 = psci_call(regs->r1, regs->r2);
+
+    PSCI_RESULT_REG(regs) = psci_call(PSCI_ARGS(regs));
 }
 
 #ifdef CONFIG_ARM_64
Signature · 1 line
Julien Grall
#2 lore raw
Quoted 9 lines · Julien Grall
Quoted 6 lines · Ian Campbell

Using ->rN truncates the 64-bit registers to 32-bits, which on X-gene chops off the top bit of the entry address for PSCI_UP.

Follow the pattern established in do_trap_hypercall.

Applied thanks.

Quoted 54 lines
Quoted 52 lines

---

Release argument: Only supporting single vcpu guests on arm64 would be unfortunate. There is no risk to arm32 since the ifdef ensures the code remains the same.

---
 xen/arch/arm/traps.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
xen/arch/arm/traps.c +14 -3
index fdf9440..62c9df2 100644
@@ -1065,23 +1065,34 @@ static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
 }
 #endif
 
+#ifdef CONFIG_ARM_64
+#define PSCI_OP_REG(r) (r)->x0
+#define PSCI_RESULT_REG(r) (r)->x0
+#define PSCI_ARGS(r) (r)->x1, (r)->x2
+#else
+#define PSCI_OP_REG(r) (r)->r0
+#define PSCI_RESULT_REG(r) (r)->r0
+#define PSCI_ARGS(r) (r)->r1, (r)->r2
+#endif
+
 static void do_trap_psci(struct cpu_user_regs *regs)
 {
     arm_psci_fn_t psci_call = NULL;
 
-    if ( regs->r0 >= ARRAY_SIZE(arm_psci_table) )
+    if ( PSCI_OP_REG(regs) >= ARRAY_SIZE(arm_psci_table) )
     {
         domain_crash_synchronous();
         return;
     }
 
-    psci_call = arm_psci_table[regs->r0].fn;
+    psci_call = arm_psci_table[PSCI_OP_REG(regs)].fn;
     if ( psci_call == NULL )
     {
         domain_crash_synchronous();
         return;
     }
-    regs->r0 = psci_call(regs->r1, regs->r2);
+
+    PSCI_RESULT_REG(regs) = psci_call(PSCI_ARGS(regs));
 }
 
 #ifdef CONFIG_ARM_64