Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
---
arch/x86/kvm/svm/svm.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index f1b032114406..983ae98133e9 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1387,6 +1387,14 @@ static void svm_prepare_switch_to_guest(struct kvm_vcpu *vcpu)
if (svm->guest_state_loaded)
return;
+ /*
+ * Without virtual VMSAVE/VMLOAD, the instruction would directly access
+ * host physical addresses, so make sure they are intercepted.
+ */
+ if (!(svm->vmcb->control.virt_ext & VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK))
+ WARN_ON_ONCE(!svm_is_intercept(svm, INTERCEPT_VMSAVE) ||
+ !svm_is_intercept(svm, INTERCEPT_VMLOAD));
+
/*
* Save additional host state that will be restored on VMEXIT (sev-es)
* or subsequent vmload of host save area.
--
2.52.0.457.g6b5491de43-goog