On 17.12.18 17:36, Jan Kiszka wrote:
On 06.11.18 00:01, Ralf Ramsauer wrote:
Similar to 6b02cd08a506 ("inmates: arm64: save registers on irq entry"), use
immediate values to address the absolute offset within the stack when storing
registers.

This is a bit more efficient that the previous push-decrement stack pattern.

Can you provide a pointer why? KVM is doing the same, but it would still be better to document that if possible.


This patch also reverses the order of registers when being pushed. We will
later utilise this.

Signed-off-by: Ralf Ramsauer <ralf.ramsa...@oth-regensburg.de>
---
  hypervisor/arch/arm64/entry.S | 66 ++++++++++++++++++-----------------
  1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S
index d6280484..0aa8fed8 100644
--- a/hypervisor/arch/arm64/entry.S
+++ b/hypervisor/arch/arm64/entry.S
@@ -270,24 +270,25 @@ bootstrap_vectors:
  .macro handle_vmexit exit_reason
      .align    7
      /* Fill the union registers. Should comply with NUM_USR_REGS */
-    stp    x29, x30, [sp, #-16]!
-    stp    x27, x28, [sp, #-16]!
-    stp    x25, x26, [sp, #-16]!
-    stp    x23, x24, [sp, #-16]!
-    stp    x21, x22, [sp, #-16]!
-    stp    x19, x20, [sp, #-16]!
-    stp    x17, x18, [sp, #-16]!
-    stp    x15, x16, [sp, #-16]!
-    stp    x13, x14, [sp, #-16]!
-    stp    x11, x12, [sp, #-16]!
-    stp    x9, x10, [sp, #-16]!
-    stp    x7, x8, [sp, #-16]!
-    stp    x5, x6, [sp, #-16]!
-    stp    x3, x4, [sp, #-16]!
-    stp    x1, x2, [sp, #-16]!
+    sub    sp, sp, #(16 * 16)
+    stp    x1, x2, [sp, #(1 * 16)]
+    stp    x3, x4, [sp, #(2 * 16)]
+    stp    x5, x6, [sp, #(3 * 16)]
+    stp    x7, x8, [sp, #(4 * 16)]
+    stp    x9, x10, [sp, #(5 * 16)]
+    stp    x11, x12, [sp, #(6 * 16)]
+    stp    x13, x14, [sp, #(7 * 16)]
+    stp    x15, x16, [sp, #(8 * 16)]
+    stp    x17, x18, [sp, #(9 * 16)]
+    stp    x19, x20, [sp, #(10 * 16)]
+    stp    x21, x22, [sp, #(11 * 16)]
+    stp    x23, x24, [sp, #(12 * 16)]
+    stp    x25, x26, [sp, #(13 * 16)]
+    stp    x27, x28, [sp, #(14 * 16)]
+    stp    x29, x30, [sp, #(15 * 16)]
      mov    x1, #\exit_reason
-    stp    x1, x0, [sp, #-16]!
+    stp    x1, x0, [sp, #(0 * 16)]
      mov    x29, xzr    /* reset fp,lr */
      mov    x30, xzr
@@ -391,21 +392,22 @@ shutdown_el2:
  vmreturn:
      /* x0: union registers* */
      mov    sp, x0
-    ldp    x1, x0, [sp], #16    /* x1 is the exit_reason */
-    ldp    x1, x2, [sp], #16
-    ldp    x3, x4, [sp], #16
-    ldp    x5, x6, [sp], #16
-    ldp    x7, x8, [sp], #16
-    ldp    x9, x10, [sp], #16
-    ldp    x11, x12, [sp], #16
-    ldp    x13, x14, [sp], #16
-    ldp    x15, x16, [sp], #16
-    ldp    x17, x18, [sp], #16
-    ldp    x19, x20, [sp], #16
-    ldp    x21, x22, [sp], #16
-    ldp    x23, x24, [sp], #16
-    ldp    x25, x26, [sp], #16
-    ldp    x27, x28, [sp], #16
-    ldp    x29, x30, [sp], #16
+    ldp    x29, x30, [sp, #(15 * 16)]
+    ldp    x27, x28, [sp, #(14 * 16)]
+    ldp    x25, x26, [sp, #(13 * 16)]
+    ldp    x23, x24, [sp, #(12 * 16)]
+    ldp    x21, x22, [sp, #(11 * 16)]
+    ldp    x19, x20, [sp, #(10 * 16)]
+    ldp    x17, x18, [sp, #(9 * 16)]
+    ldp    x15, x16, [sp, #(8 * 16)]
+    ldp    x13, x14, [sp, #(7 * 16)]
+    ldp    x11, x12, [sp, #(6 * 16)]
+    ldp    x9, x10, [sp, #(5 * 16)]
+    ldp    x7, x8, [sp, #(4 * 16)]
+    ldp    x5, x6, [sp, #(3 * 16)]
+    ldp    x3, x4, [sp, #(2 * 16)]
+    ldp    x1, x0, [sp, #(0 * 16)]    /* x1 is the exit_reason */

Maybe use the change make the comment clearer:
"x1 consumes orginal exit_reason" or so.

...or maybe only pull x0? I see no reason for reading the irrelevant 
exit_reason.

Jan


+    ldp    x1, x2, [sp, #(1 * 16)]
+    add    sp, sp, #(16 * 16)
      eret
      .popsection


Jan


--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

--
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to