x86/kvm/vmx: read MSR_{FS,KERNEL_GS}_BASE from current->thread
[sfrench/cifs-2.6.git] / arch / x86 / kernel / process_64.c
index 9eb448c7859d2469ba63e6112f129bb2926c4bb0..4b100fe0f5087f3f1a2364c9ffd48e5c1327ab6d 100644 (file)
@@ -205,6 +205,20 @@ static __always_inline void save_fsgs(struct task_struct *task)
        save_base_legacy(task, task->thread.gsindex, GS);
 }
 
+#if IS_ENABLED(CONFIG_KVM)
+/*
+ * While a process is running,current->thread.fsbase and current->thread.gsbase
+ * may not match the corresponding CPU registers (see save_base_legacy()). KVM
+ * wants an efficient way to save and restore FSBASE and GSBASE.
+ * When FSGSBASE extensions are enabled, this will have to use RD{FS,GS}BASE.
+ */
+void save_fsgs_for_kvm(void)
+{
+       save_fsgs(current);
+}
+EXPORT_SYMBOL_GPL(save_fsgs_for_kvm);
+#endif
+
 static __always_inline void loadseg(enum which_selector which,
                                    unsigned short sel)
 {