]> err.no Git - linux-2.6/commitdiff
x86: adds paravirt hook for swapgs
authorGlauber de Oliveira Costa <gcosta@redhat.com>
Wed, 30 Jan 2008 12:32:08 +0000 (13:32 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:32:08 +0000 (13:32 +0100)
This patch adds paravirt hook for swapgs operation, which is a privileged
operation in x86_64.

Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/paravirt.c
include/asm-x86/paravirt.h
include/asm-x86/processor.h

index 072c1a08efe6b134330a0786837fdd91be7de15b..e7c17cc4a99e15fb7d25638332b4a44affbc028a 100644 (file)
@@ -390,6 +390,7 @@ struct pv_cpu_ops pv_cpu_ops = {
 
        .irq_enable_syscall_ret = native_irq_enable_syscall_ret,
        .iret = native_iret,
+       .swapgs = native_swapgs,
 
        .set_iopl_mask = native_set_iopl_mask,
        .io_delay = native_io_delay,
index 7d1c126e2249f0d75d4f2ecadf96b0fd7cc9adff..e8fbf742d42567e02b489f1a4ec0c5d61a260e65 100644 (file)
@@ -127,6 +127,8 @@ struct pv_cpu_ops {
        void (*irq_enable_syscall_ret)(void);
        void (*iret)(void);
 
+       void (*swapgs)(void);
+
        struct pv_lazy_ops lazy_mode;
 };
 
@@ -1228,6 +1230,13 @@ static inline unsigned long __raw_local_irq_save(void)
        call *pv_cpu_ops+PV_CPU_read_cr0;       \
        pop %edx; pop %ecx
 #else
+#define SWAPGS                                                         \
+       PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_swapgs), CLBR_NONE,     \
+                 PV_SAVE_REGS;                                         \
+                 call *pv_cpu_ops+PV_CPU_swapgs;                       \
+                 PV_RESTORE_REGS                                       \
+                )
+
 #define GET_CR2_INTO_RCX                       \
        call *pv_mmu_ops+PV_MMU_read_cr2;       \
        movq %rax, %rcx;                        \
index e6fa06fee72ab7fbe79a1813bc9a88d5f7a64c3c..72740c6f110903380b6b526b826b224bd03eb729 100644 (file)
@@ -435,6 +435,13 @@ static inline void native_load_sp0(struct tss_struct *tss,
 #endif
 }
 
+static inline void native_swapgs(void)
+{
+#ifdef CONFIG_X86_64
+       asm volatile("swapgs" ::: "memory");
+#endif
+}
+
 #ifdef CONFIG_PARAVIRT
 #include <asm/paravirt.h>
 #else
@@ -456,6 +463,7 @@ static inline void load_sp0(struct tss_struct *tss,
 }
 
 #define set_iopl_mask native_set_iopl_mask
+#define SWAPGS swapgs
 #endif /* CONFIG_PARAVIRT */
 
 /*