]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
xen/arm32: entry: Split __DEFINE_ENTRY_TRAP in two
authorJulien Grall <julien.grall@arm.com>
Tue, 1 Oct 2019 12:07:53 +0000 (13:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Oct 2019 15:20:58 +0000 (16:20 +0100)
The preprocessing macro __DEFINE_ENTRY_TRAP is used to generate trap
entry function. While the macro is fairly small today, follow-up patches
will increase the size signicantly.

In general, assembly macros are more readable as they allow you to name
parameters and avoid '\'. So the actual implementation of the trap is
now switched to an assembly macro.

This is part of XSA-303.

Reported-by: Julien Grall <Julien.Grall@arm.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
xen/arch/arm/arm32/entry.S

index 0b4cd19abde1a300fc975a319fa5f6f862e05b21..4a762e04f15ec94e562c5155f814e8c0a8706fbc 100644 (file)
@@ -126,24 +126,28 @@ abort_guest_exit_end:
 skip_check:
         mov pc, lr
 
-/*
- * Macro to define trap entry. The iflags corresponds to the list of
- * interrupts (Asynchronous Abort, IRQ, FIQ) to unmask.
- */
+        /*
+         * Macro to define trap entry. The iflags corresponds to the list of
+         * interrupts (Asynchronous Abort, IRQ, FIQ) to unmask.
+         */
+        .macro vector trap, iflags
+        SAVE_ALL
+        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
+        .endm
+
 #define __DEFINE_TRAP_ENTRY(trap, iflags)                               \
         ALIGN;                                                          \
 trap_##trap:                                                            \
-        SAVE_ALL;                                                       \
-        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
+        vector trap, iflags
 
 /* Trap handler which unmask IRQ/Abort, keep FIQ masked */
 #define DEFINE_TRAP_ENTRY(trap) __DEFINE_TRAP_ENTRY(trap, ai)