x86/cpu: Reposition stack alignment check
PATCH 1/1 x86/cpu: Reposition stack alignment check
As identified during review, using BUG_ON() before lidt will result in a triple fault, even on APs.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/cpu/common.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
xen/arch/x86/cpu/common.c +9 -5
@@ -643,11 +643,6 @@ void load_system_tables(void) .limit = (IDT_ENTRIES * sizeof(idt_entry_t)) - 1, }; -/* Bottom-of-stack must be 16-byte aligned! */ -BUILD_BUG_ON ((sizeof (struct cpu_info ) - - offsetof(struct cpu_info, guest_cpu_user_regs.es)) & 0xf); -BUG_ON (system_state != SYS_STATE_early_boot && (stack_bottom &0xf )); -/* Main stack for interrupts/exceptions. */ tss->rsp0 = stack_bottom; tss->bitmap =IOBMP_INVALID_OFFSET ;
@@ -672,6 +667,15 @@ void load_system_tables(void) asmvolatile ("lidt %0" : :"m" (idtr) ); asmvolatile ("ltr %w0" : :"rm" (TSS_ENTRY <<3 ) ); asmvolatile ("lldt %w0" : :"rm" (0 ) ); + +/* +* Bottom-of-stack must be 16-byte aligned! +* +* Defer checks until exception support is sufficiently set up. +*/ +BUILD_BUG_ON ((sizeof (struct cpu_info ) - + offsetof(struct cpu_info, guest_cpu_user_regs.es)) & 0xf); +BUG_ON (system_state != SYS_STATE_early_boot && (stack_bottom &0xf )); }/*
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 7 lines · Andrew Cooper
As identified during review, using
BUG_ON()beforelidtwill result in a triple fault, even on APs.Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
On the basis that this is a critical bug fix:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 25.11.16 at 20:04, <[email protected]> wrote:
As identified during review, using
BUG_ON()beforelidtwill result in a triple fault, even on APs.
Oh, I did commit v1 instead of v2, sorry.
Quoted 1 line
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
xen/arch/x86/cpu/common.c void load_system_tables(void) · line 675
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 25.11.16 at 20:04, <[email protected]> wrote:
xen/arch/x86/cpu/common.c +6
-0@@ -672,6 +667,15 @@ void load_system_tables(void) asmvolatile ("lidt %0" : :"m" (idtr) ); asmvolatile ("ltr %w0" : :"rm" (TSS_ENTRY <<3 ) ); asmvolatile ("lldt %w0" : :"rm" (0 ) ); + +/* +* Bottom-of-stack must be 16-byte aligned! +* +* Defer checks until exception support is sufficiently set up. +*/
I've applied this right away, correcting the indentation issue here.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel