提交 e801f864 编写于 作者: G Glauber de Oliveira Costa 提交者: Ingo Molnar

x86: adds paravirt hook for swapgs

This patch adds paravirt hook for swapgs operation, which is a privileged
operation in x86_64.
Signed-off-by: NGlauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 4a8c4c4e
...@@ -390,6 +390,7 @@ struct pv_cpu_ops pv_cpu_ops = { ...@@ -390,6 +390,7 @@ struct pv_cpu_ops pv_cpu_ops = {
.irq_enable_syscall_ret = native_irq_enable_syscall_ret, .irq_enable_syscall_ret = native_irq_enable_syscall_ret,
.iret = native_iret, .iret = native_iret,
.swapgs = native_swapgs,
.set_iopl_mask = native_set_iopl_mask, .set_iopl_mask = native_set_iopl_mask,
.io_delay = native_io_delay, .io_delay = native_io_delay,
......
...@@ -127,6 +127,8 @@ struct pv_cpu_ops { ...@@ -127,6 +127,8 @@ struct pv_cpu_ops {
void (*irq_enable_syscall_ret)(void); void (*irq_enable_syscall_ret)(void);
void (*iret)(void); void (*iret)(void);
void (*swapgs)(void);
struct pv_lazy_ops lazy_mode; struct pv_lazy_ops lazy_mode;
}; };
...@@ -1228,6 +1230,13 @@ static inline unsigned long __raw_local_irq_save(void) ...@@ -1228,6 +1230,13 @@ static inline unsigned long __raw_local_irq_save(void)
call *pv_cpu_ops+PV_CPU_read_cr0; \ call *pv_cpu_ops+PV_CPU_read_cr0; \
pop %edx; pop %ecx pop %edx; pop %ecx
#else #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 \ #define GET_CR2_INTO_RCX \
call *pv_mmu_ops+PV_MMU_read_cr2; \ call *pv_mmu_ops+PV_MMU_read_cr2; \
movq %rax, %rcx; \ movq %rax, %rcx; \
......
...@@ -435,6 +435,13 @@ static inline void native_load_sp0(struct tss_struct *tss, ...@@ -435,6 +435,13 @@ static inline void native_load_sp0(struct tss_struct *tss,
#endif #endif
} }
static inline void native_swapgs(void)
{
#ifdef CONFIG_X86_64
asm volatile("swapgs" ::: "memory");
#endif
}
#ifdef CONFIG_PARAVIRT #ifdef CONFIG_PARAVIRT
#include <asm/paravirt.h> #include <asm/paravirt.h>
#else #else
...@@ -456,6 +463,7 @@ static inline void load_sp0(struct tss_struct *tss, ...@@ -456,6 +463,7 @@ static inline void load_sp0(struct tss_struct *tss,
} }
#define set_iopl_mask native_set_iopl_mask #define set_iopl_mask native_set_iopl_mask
#define SWAPGS swapgs
#endif /* CONFIG_PARAVIRT */ #endif /* CONFIG_PARAVIRT */
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册