KVM: x86/mmu: Check for host MMIO exclusion from mem encrypt iff necessary
Sean Christopherson
maintainerPATCH 1/1 KVM: x86/mmu: Check for host MMIO exclusion from mem encrypt iff necessary
When determining whether or not a SPTE needs to have SME/SEV's memory encryption flag set, do the moderately expension host MMIO pfn check if and only if the memory encryption mask is non-zero.
Note, KVM could further optimize the host MMIO checks by making a single call to kvm_is_mmio_pfn(), but the tdp_enabled path (for EPT's memtype handling) will likely be split out to a separate flow[*]. At that point, a better approach would be to shove the call to kvm_is_mmio_pfn() into VMX code so that AMD+NPT without SME doesn't get hit with an unnecessary lookup.
[*] https://lkml.kernel.org/r/[email protected]
--- arch/x86/kvm/mmu/spte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/spte.c +1 -1
@@ -139,7 +139,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,else pte_access &= ~ACC_WRITE_MASK ; -if (!kvm_is_mmio_pfn (pfn)) +if (shadow_me_mask && !kvm_is_mmio_pfn (pfn)) spte |= shadow_me_mask; spte |= (u64 )pfn <<PAGE_SHIFT ;
base-commit: 150866cd0ec871c765181d145aa0912628289c8a
Signature · 1 line
2.36.0.rc0.470.gd361397f0d-goog
Queued, thanks.
Paolo