KVM: x86/mmu: Locally cache whether a PFN is host MMIO when making a SPTE
authorSean Christopherson <seanjc@google.com>
Fri, 23 May 2025 01:17:53 +0000 (18:17 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 24 Jun 2025 20:29:31 +0000 (13:29 -0700)
commitffe9d7966d0190a7f6db4dcacda0c8a12084ca09
tree7e03b4c2d545c09c9c38d7ba5f359dba7c65bfcd
parentc126b46e6fa87eb27e08e2120a732ec988f20eb2
KVM: x86/mmu: Locally cache whether a PFN is host MMIO when making a SPTE

When making a SPTE, cache whether or not the target PFN is host MMIO in
order to avoid multiple rounds of the slow path of kvm_is_mmio_pfn(), e.g.
hitting pat_pfn_immune_to_uc_mtrr() in particular can be problematic.  KVM
currently avoids multiple calls by virtue of the two users being mutually
exclusive (.get_mt_mask() is Intel-only, shadow_me_value is AMD-only), but
that won't hold true if/when KVM needs to detect host MMIO mappings for
other reasons, e.g. for mitigating the MMIO Stale Data vulnerability.

No functional change intended.

Tested-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Link: https://lore.kernel.org/r/20250523011756.3243624-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/spte.c