From: Jan Beulich Date: Tue, 20 Oct 2020 06:54:59 +0000 (+0200) Subject: SVM: avoid VMSAVE in ctxt-switch-to X-Git-Tag: 4.15.0-rc1~637 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a7f0831e58bf4681d710e9a029644b6fa07b7cb0;p=xen.git SVM: avoid VMSAVE in ctxt-switch-to 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 Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 9b65445577..cfea5b5523 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -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; diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h index 24db3e9510..dfa643925f 100644 --- a/xen/include/asm-x86/desc.h +++ b/xen/include/asm-x86/desc.h @@ -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 */