[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240301101410.356007-4-kraxel@redhat.com>
Date: Fri, 1 Mar 2024 11:14:09 +0100
From: Gerd Hoffmann <kraxel@...hat.com>
To: kvm@...r.kernel.org
Cc: Gerd Hoffmann <kraxel@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
x86@...nel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)),
"H. Peter Anvin" <hpa@...or.com>,
linux-kernel@...r.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT))
Subject: [PATCH 3/3] kvm/svm: limit guest_phys_bits to 48 in 4-level paging mode
If the host runs in 4-level paging mode NPT is restricted to 4 paging
levels too. Adjust kvm_caps.guest_phys_bits accordingly.
Signed-off-by: Gerd Hoffmann <kraxel@...hat.com>
---
arch/x86/kvm/svm/svm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index e90b429c84f1..8c3e2e3bd468 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -5229,6 +5229,11 @@ static __init int svm_hardware_setup(void)
get_npt_level(), PG_LEVEL_1G);
pr_info("Nested Paging %sabled\n", npt_enabled ? "en" : "dis");
+ if (npt_enabled &&
+ get_npt_level() == PT64_ROOT_4LEVEL &&
+ kvm_caps.guest_phys_bits > 48)
+ kvm_caps.guest_phys_bits = 48;
+
/* Setup shadow_me_value and shadow_me_mask */
kvm_mmu_set_me_spte_mask(sme_me_mask, sme_me_mask);
--
2.44.0
Powered by blists - more mailing lists