diff mbox series

[Xen-devel,1/7] xen/arm32: entry: Consolidate DEFINE_TRAP_ENTRY_* macros

Message ID 20180119134103.3390-2-julien.grall@linaro.org
State Superseded
Headers show
Series xen/arm32: Branch predictor hardening (XSA-254 variant 2) | expand

Commit Message

Julien Grall Jan. 19, 2018, 1:40 p.m. UTC
The only difference between all the DEFINE_TRAP_ENTRY_* macros  are the
interrupts (Asynchronous Abort, IRQ, FIQ) unmasked.

Rather than duplicating the code, introduce __DEFINE_TRAP_ENTRY macro
that will take the list of interrupts to unmask.

This is part of XSA-254.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/arm32/entry.S | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

Comments

Stefano Stabellini Jan. 24, 2018, 11:03 p.m. UTC | #1
On Fri, 19 Jan 2018, Julien Grall wrote:
> The only difference between all the DEFINE_TRAP_ENTRY_* macros  are the
> interrupts (Asynchronous Abort, IRQ, FIQ) unmasked.
> 
> Rather than duplicating the code, introduce __DEFINE_TRAP_ENTRY macro
> that will take the list of interrupts to unmask.
> 
> This is part of XSA-254.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/arm32/entry.S | 36 +++++++++++++-----------------------
>  1 file changed, 13 insertions(+), 23 deletions(-)
> 
> diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S
> index 120922e64e..c6490d2847 100644
> --- a/xen/arch/arm/arm32/entry.S
> +++ b/xen/arch/arm/arm32/entry.S
> @@ -111,39 +111,29 @@ abort_guest_exit_end:
>  skip_check:
>          mov pc, lr
>  
> -#define DEFINE_TRAP_ENTRY(trap)                                         \
> +/*
> + * Macro to define trap entry. The iflags corresponds to the list of
> + * interrupts (Asynchronous Abort, IRQ, FIQ) to unmask.
> + */
> +#define __DEFINE_TRAP_ENTRY(trap, iflags)                               \
>          ALIGN;                                                          \
>  trap_##trap:                                                            \
>          SAVE_ALL;                                                       \
> -        cpsie i;        /* local_irq_enable */                          \
> -        cpsie a;        /* asynchronous abort enable */                 \
> +        cpsie iflags;                                                   \
>          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
>  
> -#define DEFINE_TRAP_ENTRY_NOIRQ(trap)                                   \
> -        ALIGN;                                                          \
> -trap_##trap:                                                            \
> -        SAVE_ALL;                                                       \
> -        cpsie a;        /* asynchronous abort enable */                 \
> -        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
> +/* Trap handler which unmask IRQ/Abort, keep FIQ masked */
> +#define DEFINE_TRAP_ENTRY(trap) __DEFINE_TRAP_ENTRY(trap, ai)
>  
> -#define DEFINE_TRAP_ENTRY_NOABORT(trap)                                 \
> -        ALIGN;                                                          \
> -trap_##trap:                                                            \
> -        SAVE_ALL;                                                       \
> -        cpsie i;        /* local_irq_enable */                          \
> -        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
> +/* Trap handler which unmask Abort, keep IRQ/FIQ masked */
> +#define DEFINE_TRAP_ENTRY_NOIRQ(trap) __DEFINE_TRAP_ENTRY(trap, a)
> +
> +/* Trap handler which unmask IRQ, keep Abort/FIQ masked */
> +#define DEFINE_TRAP_ENTRY_NOABORT(trap) __DEFINE_TRAP_ENTRY(trap, i)
>  
>          .align 5
>  GLOBAL(hyp_traps_vector)
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S
index 120922e64e..c6490d2847 100644
--- a/xen/arch/arm/arm32/entry.S
+++ b/xen/arch/arm/arm32/entry.S
@@ -111,39 +111,29 @@  abort_guest_exit_end:
 skip_check:
         mov pc, lr
 
-#define DEFINE_TRAP_ENTRY(trap)                                         \
+/*
+ * Macro to define trap entry. The iflags corresponds to the list of
+ * interrupts (Asynchronous Abort, IRQ, FIQ) to unmask.
+ */
+#define __DEFINE_TRAP_ENTRY(trap, iflags)                               \
         ALIGN;                                                          \
 trap_##trap:                                                            \
         SAVE_ALL;                                                       \
-        cpsie i;        /* local_irq_enable */                          \
-        cpsie a;        /* asynchronous abort enable */                 \
+        cpsie iflags;                                                   \
         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
 
-#define DEFINE_TRAP_ENTRY_NOIRQ(trap)                                   \
-        ALIGN;                                                          \
-trap_##trap:                                                            \
-        SAVE_ALL;                                                       \
-        cpsie a;        /* asynchronous abort enable */                 \
-        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
+/* Trap handler which unmask IRQ/Abort, keep FIQ masked */
+#define DEFINE_TRAP_ENTRY(trap) __DEFINE_TRAP_ENTRY(trap, ai)
 
-#define DEFINE_TRAP_ENTRY_NOABORT(trap)                                 \
-        ALIGN;                                                          \
-trap_##trap:                                                            \
-        SAVE_ALL;                                                       \
-        cpsie i;        /* local_irq_enable */                          \
-        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
+/* Trap handler which unmask Abort, keep IRQ/FIQ masked */
+#define DEFINE_TRAP_ENTRY_NOIRQ(trap) __DEFINE_TRAP_ENTRY(trap, a)
+
+/* Trap handler which unmask IRQ, keep Abort/FIQ masked */
+#define DEFINE_TRAP_ENTRY_NOABORT(trap) __DEFINE_TRAP_ENTRY(trap, i)
 
         .align 5
 GLOBAL(hyp_traps_vector)