Skip to content

Commit 1952e74

Browse files
committed
KVM: SVM: Skip VMSA init in sev_es_init_vmcb() if pointer is NULL
Skip initializing the VMSA physical address in the VMCB if the VMSA is NULL, which occurs during intrahost migration as KVM initializes the VMCB before copying over state from the source to the destination (including the VMSA and its physical address). In normal builds, __pa() is just math, so the bug isn't fatal, but with CONFIG_DEBUG_VIRTUAL=y, the validity of the virtual address is verified and passing in NULL will make the kernel unhappy. Fixes: 6defa24 ("KVM: SEV: Init target VMCBs in sev_migrate_from") Cc: stable@vger.kernel.org Cc: Peter Gonda <pgonda@google.com> Reviewed-by: Peter Gonda <pgonda@google.com> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com> Link: https://lore.kernel.org/r/20230825022357.2852133-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent f1187ef commit 1952e74

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2975,9 +2975,12 @@ static void sev_es_init_vmcb(struct vcpu_svm *svm)
29752975
/*
29762976
* An SEV-ES guest requires a VMSA area that is a separate from the
29772977
* VMCB page. Do not include the encryption mask on the VMSA physical
2978-
* address since hardware will access it using the guest key.
2978+
* address since hardware will access it using the guest key. Note,
2979+
* the VMSA will be NULL if this vCPU is the destination for intrahost
2980+
* migration, and will be copied later.
29792981
*/
2980-
svm->vmcb->control.vmsa_pa = __pa(svm->sev_es.vmsa);
2982+
if (svm->sev_es.vmsa)
2983+
svm->vmcb->control.vmsa_pa = __pa(svm->sev_es.vmsa);
29812984

29822985
/* Can't intercept CR register access, HV can't modify CR registers */
29832986
svm_clr_intercept(svm, INTERCEPT_CR0_READ);

0 commit comments

Comments
 (0)