[xen stable-4.6] xen/arm32: entry: Document the purpose of r11 in the traps handler

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen stable-4.6] xen/arm32: entry: Document the purpose of r11 in the traps handler

patchbot
commit 9d534c12bf71babb76f1338029841f757191f729
Author:     Julien Grall <[hidden email]>
AuthorDate: Fri Feb 2 14:19:25 2018 +0000
Commit:     Stefano Stabellini <[hidden email]>
CommitDate: Mon Feb 19 14:16:40 2018 -0800

    xen/arm32: entry: Document the purpose of r11 in the traps handler
   
    It took me a bit of time to understand why __DEFINE_TRAP_ENTRY is
    storing the original stack pointer in r11. It is working in pair with
    return_traps_entry where sp will be restored from r11.
   
    This is fine because per the AAPCS r11 must be preserved by the
    subroutine. So in return_from_trap, r11 will still contain the original
    stack pointer.
   
    Add some documentation in the code to point the 2 sides to each other.
   
    Signed-off-by: Julien Grall <[hidden email]>
    Reviewed-by: Stefano Stabellini <[hidden email]>
    (cherry picked from commit dd855aa430f2da9b677c145f0c625a82aaa97110)
---
 xen/arch/arm/arm32/entry.S | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S
index 3e48ba18d8..b66705ff50 100644
--- a/xen/arch/arm/arm32/entry.S
+++ b/xen/arch/arm/arm32/entry.S
@@ -127,6 +127,10 @@ trap_##trap:                                                            \
         cpsie iflags;                                                   \
         adr lr, return_from_trap;                                       \
         mov r0, sp;                                                     \
+        /*                                                              \
+         * Save the stack pointer in r11. It will be restored after the \
+         * trap has been handled (see return_from_trap).                \
+         */                                                             \
         mov r11, sp;                                                    \
         bic sp, #7; /* Align the stack pointer (noop on guest trap) */  \
         b do_trap_##trap
@@ -217,6 +221,10 @@ DEFINE_TRAP_ENTRY_NOIRQ(irq)
 DEFINE_TRAP_ENTRY_NOIRQ(fiq)
 
 return_from_trap:
+        /*
+         * Restore the stack pointer from r11. It was saved on exception
+         * entry (see __DEFINE_TRAP_ENTRY).
+         */
         mov sp, r11
 ENTRY(return_to_new_vcpu32)
         ldr r11, [sp, #UREGS_cpsr]
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.6

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog