Skip to content

Commit

Permalink
KVM: SVM: Disable SEV/SEV-ES if NPT is disabled
Browse files Browse the repository at this point in the history
Disable SEV and SEV-ES if NPT is disabled.  While the APM doesn't clearly
state that NPT is mandatory, it's alluded to by:

  The guest page tables, managed by the guest, may mark data memory pages
  as either private or shared, thus allowing selected pages to be shared
  outside the guest.

And practically speaking, shadow paging can't work since KVM can't read
the guest's page tables.

Fixes: e9df094 ("KVM: SVM: Add sev module_param")
Cc: Brijesh Singh <brijesh.singh@amd.com
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210422021125.3417167-4-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Apr 26, 2021
1 parent f31b88b commit fa13680
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions arch/x86/kvm/svm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,21 +982,6 @@ static __init int svm_hardware_setup(void)
kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
}

if (IS_ENABLED(CONFIG_KVM_AMD_SEV) && sev) {
sev_hardware_setup();
} else {
sev = false;
sev_es = false;
}

svm_adjust_mmio_mask();

for_each_possible_cpu(cpu) {
r = svm_cpu_init(cpu);
if (r)
goto err;
}

/*
* KVM's MMU doesn't support using 2-level paging for itself, and thus
* NPT isn't supported if the host is using 2-level paging since host
Expand All @@ -1011,6 +996,21 @@ static __init int svm_hardware_setup(void)
kvm_configure_mmu(npt_enabled, get_max_npt_level(), PG_LEVEL_1G);
pr_info("kvm: Nested Paging %sabled\n", npt_enabled ? "en" : "dis");

if (IS_ENABLED(CONFIG_KVM_AMD_SEV) && sev && npt_enabled) {
sev_hardware_setup();
} else {
sev = false;
sev_es = false;
}

svm_adjust_mmio_mask();

for_each_possible_cpu(cpu) {
r = svm_cpu_init(cpu);
if (r)
goto err;
}

if (nrips) {
if (!boot_cpu_has(X86_FEATURE_NRIPS))
nrips = false;
Expand Down

0 comments on commit fa13680

Please sign in to comment.