]> xenbits.xensource.com Git - xen.git/commit
xen/arm: Save ESR_EL2 to avoid using mismatched value in syndrome check
authorWei Chen <Wei.Chen@arm.com>
Wed, 5 Apr 2017 09:09:03 +0000 (17:09 +0800)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 5 Apr 2017 19:11:57 +0000 (12:11 -0700)
commit90dbcd749103c35609370e7b11d26690d4ca4f40
tree56231bb14f013bdd65ade23c0b8ee0f90149bd70
parentd641c24e7cd24f41580399e85d3f1b7ee745a63f
xen/arm: Save ESR_EL2 to avoid using mismatched value in syndrome check

Xen will do exception syndrome check while some types of exception
take place in EL2. The syndrome check code read the ESR_EL2 register
directly, but in some situation this register maybe overridden by
nested exception.

For example, if we re-enable IRQ before reading ESR_EL2 which means
Xen may enter in IRQ exception mode and return the processor with
clobbered ESR_EL2 (See ARM ARM DDI 0487A.j D7.2.25)

In this case the guest exception syndrome has been overridden, we will
check the syndrome for guest sync exception with an incorrect ESR_EL2
value. So we want to save ESR_EL2 to cpu_user_regs as soon as the
exception takes place in EL2 to avoid using an incorrect syndrome value.

In order to save ESR_EL2, we added a 32-bit member hsr to cpu_user_regs.
But while saving registers in trap entry, we use stp to save ELR and
CPSR at the same time through 64-bit general registers. If we keep this
code, the hsr will be overridden by upper 32-bit of CPSR. So adjust the
code to use str to save ELR in a separate instruction and use stp to
save CPSR and HSR at the same time through 32-bit general registers.
This change affects the registers restore in trap exit, we can't use the
ldp to restore ELR and CPSR from stack at the same time. We have to use
ldr to restore them separately.

Signed-off-by: Wei Chen <Wei.Chen@arm.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/arm32/asm-offsets.c
xen/arch/arm/arm32/entry.S
xen/arch/arm/arm64/asm-offsets.c
xen/arch/arm/arm64/entry.S
xen/arch/arm/arm64/traps.c
xen/arch/arm/traps.c
xen/include/asm-arm/arm32/processor.h
xen/include/asm-arm/arm64/processor.h