Skip to content

Commit 14d7802

Browse files
sean-jcgregkh
authored andcommitted
KVM: SVM: Disable SEV/SEV-ES if NPT is disabled
[ Upstream commit fa13680 ] 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 <[email protected] Cc: Tom Lendacky <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b75a9a6 commit 14d7802

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -968,21 +968,6 @@ static __init int svm_hardware_setup(void)
968968
kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
969969
}
970970

971-
if (IS_ENABLED(CONFIG_KVM_AMD_SEV) && sev) {
972-
sev_hardware_setup();
973-
} else {
974-
sev = false;
975-
sev_es = false;
976-
}
977-
978-
svm_adjust_mmio_mask();
979-
980-
for_each_possible_cpu(cpu) {
981-
r = svm_cpu_init(cpu);
982-
if (r)
983-
goto err;
984-
}
985-
986971
/*
987972
* KVM's MMU doesn't support using 2-level paging for itself, and thus
988973
* NPT isn't supported if the host is using 2-level paging since host
@@ -997,6 +982,21 @@ static __init int svm_hardware_setup(void)
997982
kvm_configure_mmu(npt_enabled, get_max_npt_level(), PG_LEVEL_1G);
998983
pr_info("kvm: Nested Paging %sabled\n", npt_enabled ? "en" : "dis");
999984

985+
if (IS_ENABLED(CONFIG_KVM_AMD_SEV) && sev && npt_enabled) {
986+
sev_hardware_setup();
987+
} else {
988+
sev = false;
989+
sev_es = false;
990+
}
991+
992+
svm_adjust_mmio_mask();
993+
994+
for_each_possible_cpu(cpu) {
995+
r = svm_cpu_init(cpu);
996+
if (r)
997+
goto err;
998+
}
999+
10001000
if (nrips) {
10011001
if (!boot_cpu_has(X86_FEATURE_NRIPS))
10021002
nrips = false;

0 commit comments

Comments
 (0)