Skip to content

Commit

Permalink
x86, 64-bit: swapgs pvop with a user-stack can never be called
Browse files Browse the repository at this point in the history
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 <jeremy.fitzhardinge@citrix.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Cc: Stephen Tweedie <sct@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Jeremy Fitzhardinge authored and Ingo Molnar committed Jul 8, 2008
1 parent 6680415 commit a00394f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/asm-x86/irqflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions include/asm-x86/paravirt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down

0 comments on commit a00394f

Please sign in to comment.