xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: re-add stack alignment check
@ 2016-11-14 13:25 Jan Beulich
  2016-11-14 13:45 ` Andrew Cooper
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Beulich @ 2016-11-14 13:25 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

Commit 279840d5ea ("x86/boot: install trap handlers much earlier on
boot"), perhaps not really intentionally, removed this check. Add it
back,
- preventing it to trigger before any output is set up,
- accompanying it with a (weaker, due to its open coding of what
  get_stack_bottom() does) build time check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
While not strictly needed for 4.8, I thought I'd still submit it as a
possible candidate.

--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -643,6 +643,11 @@ 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;




[-- Attachment #2: x86-stack-bottom-check.patch --]
[-- Type: text/plain, Size: 1035 bytes --]

x86: re-add stack alignment check

Commit 279840d5ea ("x86/boot: install trap handlers much earlier on
boot"), perhaps not really intentionally, removed this check. Add it
back,
- preventing it to trigger before any output is set up,
- accompanying it with a (weaker, due to its open coding of what
  get_stack_bottom() does) build time check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
While not strictly needed for 4.8, I thought I'd still submit it as a
possible candidate.

--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -643,6 +643,11 @@ 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;

[-- Attachment #3: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-11-25 13:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-14 13:25 [PATCH] x86: re-add stack alignment check Jan Beulich
2016-11-14 13:45 ` Andrew Cooper
2016-11-14 14:24   ` Jan Beulich
2016-11-14 14:33     ` Jan Beulich
2016-11-14 14:38     ` Andrew Cooper
2016-11-14 15:02       ` Jan Beulich
2016-11-14 16:38         ` Andrew Cooper
2016-11-14 16:54           ` Jan Beulich
2016-11-15 10:26             ` Andrew Cooper
2016-11-15 10:46               ` Jan Beulich
2016-11-22 10:14                 ` Ping: " Jan Beulich
2016-11-25 10:34                   ` Andrew Cooper
2016-11-25 13:12                     ` Wei Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).