Skip to content

Commit 48f15f6

Browse files
committed
KVM: SVM: Initialize vmsa_pa in VMCB to INVALID_PAGE if VMSA page is NULL
When creating an SEV-ES vCPU for intra-host migration, set its vmsa_pa to INVALID_PAGE to harden against doing VMRUN with a bogus VMSA (KVM checks for a valid VMSA page in pre_sev_run()). Cc: Tom Lendacky <[email protected]> Reviewed-by: Liam Merwick <[email protected]> Tested-by: Liam Merwick <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent ecf371f commit 48f15f6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,8 +4449,12 @@ static void sev_es_init_vmcb(struct vcpu_svm *svm)
44494449
* the VMSA will be NULL if this vCPU is the destination for intrahost
44504450
* migration, and will be copied later.
44514451
*/
4452-
if (svm->sev_es.vmsa && !svm->sev_es.snp_has_guest_vmsa)
4453-
svm->vmcb->control.vmsa_pa = __pa(svm->sev_es.vmsa);
4452+
if (!svm->sev_es.snp_has_guest_vmsa) {
4453+
if (svm->sev_es.vmsa)
4454+
svm->vmcb->control.vmsa_pa = __pa(svm->sev_es.vmsa);
4455+
else
4456+
svm->vmcb->control.vmsa_pa = INVALID_PAGE;
4457+
}
44544458

44554459
if (cpu_feature_enabled(X86_FEATURE_ALLOWED_SEV_FEATURES))
44564460
svm->vmcb->control.allowed_sev_features = sev->vmsa_features |

0 commit comments

Comments
 (0)