KVM: x86/mmu: Embed direct bits into gpa for KVM_PRE_FAULT_MEMORY
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 11 Jun 2025 00:10:18 +0000 (20:10 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 Jun 2025 04:43:39 +0000 (00:43 -0400)
commitaa2024c01a9afba6728b362626f868811ca872ee
treeb6f667cde3395a97721995715e73f8226e873b86
parent179a8427fcbffe36ccfed5e138d7c9b6180caff9
KVM: x86/mmu: Embed direct bits into gpa for KVM_PRE_FAULT_MEMORY

Bug[*] reported for TDX case when enabling KVM_PRE_FAULT_MEMORY in QEMU.

It turns out that @gpa passed to kvm_mmu_do_page_fault() doesn't have
shared bit set when the memory attribute of it is shared, and it leads
to wrong root in tdp_mmu_get_root_for_fault().

Fix it by embedding the direct bits in the gpa that is passed to
kvm_tdp_map_page(), when the memory of the gpa is not private.

[*] https://lore.kernel.org/qemu-devel/4a757796-11c2-47f1-ae0d-335626e818fd@intel.com/

Reported-by: Xiaoyao Li <xiaoyao.li@intel.com>
Closes: https://lore.kernel.org/qemu-devel/4a757796-11c2-47f1-ae0d-335626e818fd@intel.com/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Message-ID: <20250611001018.2179964-1-xiaoyao.li@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c