xen/arm32: entry: Fold the macro SAVE_ALL in the macro vector

Follow-up rework will require the macro vector to distinguish between
a trap from a guest vs while in the hypervisor.

The macro SAVE_ALL already has code to distinguish between the two and
it is only called by the vector macro. So fold the former into the
latter. This will help to avoid duplicating the check.

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>
This commit is contained in:
Julien Grall authored and Jan Beulich committed 2019-10-31 16:21:33 +01:00
1 parent 6eeef7ecae
commit a7b81b021e
1 file changed
+23 -23
+23 -23
View File
@@ -13,27 +13,6 @@
#define RESTORE_BANKED(mode) \
RESTORE_ONE_BANKED(SP_##mode) ; RESTORE_ONE_BANKED(LR_##mode) ; RESTORE_ONE_BANKED(SPSR_##mode)
#define SAVE_ALL \
sub sp, #(UREGS_SP_usr - UREGS_sp); /* SP, LR, SPSR, PC */ \
push {r0-r12}; /* Save R0-R12 */ \
\
mrs r11, ELR_hyp; /* ELR_hyp is return address. */\
str r11, [sp, #UREGS_pc]; \
\
str lr, [sp, #UREGS_lr]; \
\
add r11, sp, #UREGS_kernel_sizeof+4; \
str r11, [sp, #UREGS_sp]; \
\
mrc CP32(r11, HSR); /* Save exception syndrome */ \
str r11, [sp, #UREGS_hsr]; \
\
mrs r11, SPSR_hyp; \
str r11, [sp, #UREGS_cpsr]; \
and r11, #PSR_MODE_MASK; \
cmp r11, #PSR_MODE_HYP; \
blne save_guest_regs
save_guest_regs:
#ifdef CONFIG_ARM32_HARDEN_BRANCH_PREDICTOR
/*
@@ -52,7 +31,7 @@ save_guest_regs:
ldr r11, =0xffffffff /* Clobber SP which is only valid for hypervisor frames. */
str r11, [sp, #UREGS_sp]
SAVE_ONE_BANKED(SP_usr)
/* LR_usr is the same physical register as lr and is saved in SAVE_ALL */
/* LR_usr is the same physical register as lr and is saved by the caller */
SAVE_BANKED(svc)
SAVE_BANKED(abt)
SAVE_BANKED(und)
@@ -131,7 +110,28 @@ skip_check:
* interrupts (Asynchronous Abort, IRQ, FIQ) to unmask.
*/
.macro vector trap, iflags
SAVE_ALL
/* Save registers in the stack */
sub sp, #(UREGS_SP_usr - UREGS_sp) /* SP, LR, SPSR, PC */
push {r0-r12} /* Save R0-R12 */
mrs r11, ELR_hyp /* ELR_hyp is return address */
str r11, [sp, #UREGS_pc]
str lr, [sp, #UREGS_lr]
add r11, sp, #(UREGS_kernel_sizeof + 4)
str r11, [sp, #UREGS_sp]
mrc CP32(r11, HSR) /* Save exception syndrome */
str r11, [sp, #UREGS_hsr]
mrs r11, SPSR_hyp
str r11, [sp, #UREGS_cpsr]
and r11, #PSR_MODE_MASK
cmp r11, #PSR_MODE_HYP
blne save_guest_regs
/* We are ready to handle the trap, setup the registers and jump. */
cpsie \iflags
adr lr, return_from_trap
mov r0, sp
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.