[PATCH v3 2/7] KVM: x86: Treat EFER.LMA, not EFER.LMA, as an EFER MMU role bit

From: Sean Christopherson

Date: Fri Oct 30 2026 - 17:33:20 EST


Now that KVM now longer lets userspace violate the architectural rules when
stuffing EFER, treat EFER.LMA instead of EFER.LME as the relevant EFER MMU
role bit to ensure that the MMU context is reinitialized if EFER.LMA is
toggled without EFER.LME also being toggled. EFER.LMA is the actual bit
that is consumed by e.g. kvm_calc_cpu_role().

While the _current_ code never actually toggles EFER.LMA, that is a flaw
that will soon be fixed. Furthermore, checking EFER.LME was essentially a
hack to fudge around the now-reverted, misguided commit 11988499e62b ("KVM:
x86: Skip EFER vs. guest CPUID checks for host-initiated writes").

Reported-by: Sashiko Bot <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-187201@xxxxxxxxxx
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
arch/x86/kvm/mmu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index 2ae7f9ed4cf8..2c3f777f78d6 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -61,7 +61,7 @@ extern bool __read_mostly eager_page_split;
X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_PKE)

#define KVM_MMU_CR0_ROLE_BITS (X86_CR0_PG | X86_CR0_WP)
-#define KVM_MMU_EFER_ROLE_BITS (EFER_LME | EFER_NX)
+#define KVM_MMU_EFER_ROLE_BITS (EFER_LMA | EFER_NX)

static __always_inline u64 rsvd_bits(int s, int e)
{
--
2.56.0.385.gac671c819a-goog