]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
SVM: avoid VMSAVE in ctxt-switch-to
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 06:54:59 +0000 (08:54 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Oct 2020 06:54:59 +0000 (08:54 +0200)
Of the state saved by the insn and reloaded by the corresponding VMLOAD
- TR and syscall state are invariant while having Xen's state loaded,
- sysenter is unused altogether by Xen,
- FS, GS, and LDTR are not used by Xen and get suitably set in PV
  context switch code.
Note that state is suitably populated in _svm_cpu_up(); a minimal
respective assertion gets added.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/svm/svm.c
xen/include/asm-x86/desc.h

index 9b65445577099aa112ae91269e695358a5bb7070..cfea5b5523e7db472a7f4faf2c98e7d5e91d2f2a 100644 (file)
@@ -984,7 +984,6 @@ static void svm_ctxt_switch_to(struct vcpu *v)
 
     svm_restore_dr(v);
 
-    svm_vmsave_pa(per_cpu(host_vmcb, cpu));
     vmcb->cleanbits.raw = 0;
     svm_tsc_ratio_load(v);
 
@@ -1609,6 +1608,8 @@ static int _svm_cpu_up(bool bsp)
     /* Initialize OSVW bits to be used by guests */
     svm_host_osvw_init();
 
+    /* Minimal checking that enough CPU setup was done by now. */
+    ASSERT(str() == TSS_SELECTOR);
     svm_vmsave_pa(per_cpu(host_vmcb, cpu));
 
     return 0;
index 24db3e951088ddf97d8d256d1f8886148faa0962..dfa643925f7941a967e5ad3861defbe3e999da23 100644 (file)
@@ -236,6 +236,15 @@ static inline void ltr(unsigned int sel)
     __asm__ __volatile__ ( "ltr %w0" :: "rm" (sel) : "memory" );
 }
 
+static inline unsigned int str(void)
+{
+    unsigned int sel;
+
+    __asm__ ( "str %0" : "=r" (sel) );
+
+    return sel;
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __ARCH_DESC_H */