Mailing List Archive

[xen master] SVM: avoid VMSAVE in ctxt-switch-to
commit a7f0831e58bf4681d710e9a029644b6fa07b7cb0
Author: Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Oct 20 08:54:59 2020 +0200
Commit: Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Oct 20 08:54:59 2020 +0200

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 <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 | 3 ++-
xen/include/asm-x86/desc.h | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)

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 */
--
generated by git-patchbot for /home/xen/git/xen.git#master