From: Jeremy Fitzhardinge Date: Wed, 25 Jun 2008 04:19:30 +0000 (-0400) Subject: x86, 64-bit: swapgs pvop with a user-stack can never be called X-Git-Tag: v2.6.27-rc1~1106^2~122 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a00394f81f419beb6fb9f7023bd4d15913dc625d;p=linux-2.6 x86, 64-bit: swapgs pvop with a user-stack can never be called It's never safe to call a swapgs pvop when the user stack is current - it must be inline replaced. Rather than making a call, the SWAPGS_UNSAFE_STACK pvop always just puts "swapgs" as a placeholder, which must either be replaced inline or trap'n'emulated (somehow). Signed-off-by: Jeremy Fitzhardinge Cc: xen-devel Cc: Stephen Tweedie Cc: Eduardo Habkost Cc: Mark McLoughlin Signed-off-by: Ingo Molnar --- diff --git a/include/asm-x86/irqflags.h b/include/asm-x86/irqflags.h index ea9bd2635d..d17e1f623d 100644 --- a/include/asm-x86/irqflags.h +++ b/include/asm-x86/irqflags.h @@ -111,6 +111,7 @@ static inline unsigned long __raw_local_irq_save(void) #define DISABLE_INTERRUPTS(x) cli #ifdef CONFIG_X86_64 +#define SWAPGS_UNSAFE_STACK swapgs #define INTERRUPT_RETURN iretq #define USERGS_SYSRET64 \ swapgs; \ @@ -185,7 +186,6 @@ static inline void trace_hardirqs_fixup(void) * Either way, this is a good way to document that we don't * have a reliable stack. x86_64 only. */ -#define SWAPGS_UNSAFE_STACK swapgs #define ARCH_TRACE_IRQS_ON call trace_hardirqs_on_thunk #define ARCH_TRACE_IRQS_OFF call trace_hardirqs_off_thunk #define ARCH_LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h index 33f72f8fe7..3286a0c63b 100644 --- a/include/asm-x86/paravirt.h +++ b/include/asm-x86/paravirt.h @@ -1522,6 +1522,16 @@ static inline unsigned long __raw_local_irq_save(void) #else /* !CONFIG_X86_32 */ + +/* + * If swapgs is used while the userspace stack is still current, + * there's no way to call a pvop. The PV replacement *must* be + * inlined, or the swapgs instruction must be trapped and emulated. + */ +#define SWAPGS_UNSAFE_STACK \ + PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_swapgs), CLBR_NONE, \ + swapgs) + #define SWAPGS \ PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_swapgs), CLBR_NONE, \ PV_SAVE_REGS; \