]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm32: entry: Consolidate DEFINE_TRAP_ENTRY*() macros
authorJulien Grall <julien.grall@arm.com>
Tue, 1 Oct 2019 12:07:53 +0000 (13:07 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 Nov 2019 14:20:29 +0000 (15:20 +0100)
The only difference between the two macros DEFINE_TRAP_ENTRY() and
DEFINE_TRAP_ENTRY_NOIRQ() is the list of interrupts to be unmasked.

While the macros are fairly small today, it will be necessary to add the
same code twice in follow-up patches.

To prevent too much duplication, a new assembly macros is introduced to
generate the body of a trap.

This is part of XSA-303.

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

index 3e320dc8acf20ed7cbaae1c84985153500edc186..f6ba5a2082c22e279c6637ddb093d7db0587bcee 100644 (file)
@@ -116,30 +116,37 @@ abort_guest_exit_end:
 
         mov pc, lr
 
+
+        /*
+         * Macro to define a trap entry. The iflags is optional and
+         * corresponds to alist of interrupts (Asynchronous Abort, IRQ, FIQ)
+         * to unmask.
+         */
+        .macro vector trap, iflags=n
+        SAVE_ALL
+        .if \iflags != n
+        cpsie   \iflags
+        .endif
+        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)                                         \
         ALIGN;                                                          \
 trap_##trap:                                                            \
-        SAVE_ALL;                                                       \
-        cpsie i;        /* local_irq_enable */                          \
-        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=i                                           \
 
 #define DEFINE_TRAP_ENTRY_NOIRQ(trap)                                   \
         ALIGN;                                                          \
 trap_##trap:                                                            \
-        SAVE_ALL;                                                       \
-        adr lr, return_from_trap;                                       \
-        mov r0, sp;                                                     \
-        mov r11, sp;                                                    \
-        bic sp, #7; /* Align the stack pointer (noop on guest trap) */  \
-        b do_trap_##trap
+        vector trap
 
         .align 5
 GLOBAL(hyp_traps_vector)