xen/arm64: ensure that the correct SP is used for exceptions
PATCH 1/1 xen/arm64: ensure that the correct SP is used for exceptions
From: "Kyle J. Temkin" <[email protected]>
The ARMv8 architecture has a SPSel ("stack pointer selection") machine register that allows us to determine which exception level's stack pointer is loaded when an exception occurs. As we don't want to use the non-priveleged SP_EL0 stack pointer -- or even assume that SP_EL0 points to a valid address in the hypervisor context-- we'll need to ensure that our EL2 code sets the SPSel to SP_ELn mode, so exceptions that trap to EL2 use the EL2 stack pointer.
This corrects an issue that can manifest as a hang-on-IRQ on some arm64 cores if the firmware/bootloader has previously initialized SPSel to 0; in which case Xen's exceptions will incorrectly use an invalid SP_EL0, and will endlessly spin on the synchronous abort handler.
--- xen/arch/arm/arm64/head.S | 5 +++++ 1 file changed, 5 insertions(+)
xen/arch/arm/arm64/head.S +5 -0
@@ -361,6 +361,11 @@ skip_bss: ldr x0, =(HSCTLR_BASE) msr SCTLR_EL2, x0 + /* Ensure that any exceptions encountered at EL2 + * are handled using the EL2 stack pointer, rather + * than SP_EL0. */ + msr spsel, #1 + /* Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. *
Signature · 7 lines
2.7.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
(CC Wei for release-ack)
Hello Kyle,
Quoted 6 lines · Kyle Temkin
From: "Kyle J. Temkin" <[email protected]>
The ARMv8 architecture has a SPSel ("stack pointer selection") machine register that allows us to determine which exception level's stack pointer is loaded when an exception occurs. As we don't want to use the non-priveleged
SP_EL0stack pointer -- or even assume thatSP_EL0
NIT: s/priveleged/privileged/
Quoted 10 lines
points to a valid address in the hypervisor context-- we'll need to ensure that our EL2 code sets the SPSel to
SP_ELnmode, so exceptions that trap to EL2 use the EL2 stack pointer.This corrects an issue that can manifest as a hang-on-IRQ on some arm64 cores if the
firmware/bootloaderhas previously initialized SPSel to 0; in which case Xen's exceptions will incorrectly use an invalidSP_EL0, and will endlessly spin on the synchronous abort handler.Signed-off-by Kyle Temkin <[email protected]>
Wei, this is a bug-fix and I think it should go to Xen 4.7.
We would also need to backport this patch on Xen 4.4 -> Xen 4.6.
Regards,
Quoted 21 lines
--- xen/arch/arm/arm64/head.S | 5 +++++ 1 file changed, 5 insertions(+)xen/arch/arm/arm64/head.S +5
-0@@ -361,6 +361,11 @@ skip_bss: ldr x0, =(HSCTLR_BASE) msr SCTLR_EL2, x0 + /* Ensure that any exceptions encountered at EL2 + * are handled using the EL2 stack pointer, rather + * than SP_EL0. */ + msr spsel, #1 + /* Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. *
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 23 lines · Julien Grall
(CC Wei for release-ack)
Hello Kyle,
Quoted 6 lines · Kyle Temkin
From: "Kyle J. Temkin" <[email protected]>
The ARMv8 architecture has a SPSel ("stack pointer selection") machine register that allows us to determine which exception level's stack pointer is loaded when an exception occurs. As we don't want to use the non-priveleged
SP_EL0stack pointer -- or even assume thatSP_EL0NIT: s/priveleged/privileged/
Quoted 9 lines
points to a valid address in the hypervisor context-- we'll need to ensure that our EL2 code sets the SPSel to
SP_ELnmode, so exceptions that trap to EL2 use the EL2 stack pointer.This corrects an issue that can manifest as a hang-on-IRQ on some arm64 cores if the
firmware/bootloaderhas previously initialized SPSel to 0; in which case Xen's exceptions will incorrectly use an invalidSP_EL0, and will endlessly spin on the synchronous abort handler.
Quoted 6 lines
Quoted 1 line
Signed-off-by Kyle Temkin <[email protected]>Reviewed-by Julien Grall <[email protected]>Wei, this is a bug-fix and I think it should go to Xen 4.7.
Quoted 16 lines
We would also need to backport this patch on Xen 4.4 -> Xen 4.6.
Regards,
Quoted 12 lines
--- xen/arch/arm/arm64/head.S | 5 +++++ 1 file changed, 5 insertions(+)xen/arch/arm/arm64/head.S +0
-0@@ -361,6 +361,11 @@ skip_bss: ldr x0, =(HSCTLR_BASE) msr SCTLR_EL2, x0
Quoted 12 lines
Quoted 9 lines
xen/arch/arm/arm64/head.S +5
-0+ /* Ensure that any exceptions encountered at EL2 + * are handled using the EL2 stack pointer, rather + * than SP_EL0. */ + msr spsel, #1 + /* Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. *Signature · 1 line
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel