Skip to content

Commit f029f04

Browse files
Ackerley Tngbonzini
authored andcommitted
KVM: x86/mmu: Handle guest page faults for guest_memfd with shared memory
Update the KVM MMU fault handler to service guest page faults for memory slots backed by guest_memfd with mmap support. For such slots, the MMU must always fault in pages directly from guest_memfd, bypassing the host's userspace_addr. This ensures that guest_memfd-backed memory is always handled through the guest_memfd specific faulting path, regardless of whether it's for private or non-private (shared) use cases. Additionally, rename kvm_mmu_faultin_pfn_private() to kvm_mmu_faultin_pfn_gmem(), as this function is now used to fault in pages from guest_memfd for both private and non-private memory, accommodating the new use cases. Co-developed-by: David Hildenbrand <david@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Ackerley Tng <ackerleytng@google.com> Co-developed-by: Fuad Tabba <tabba@google.com> Signed-off-by: Fuad Tabba <tabba@google.com> [sean: drop the helper] Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Message-ID: <20250729225455.670324-17-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent b7d97f6 commit f029f04

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/x86/kvm/mmu/mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,8 +4561,8 @@ static void kvm_mmu_finish_page_fault(struct kvm_vcpu *vcpu,
45614561
r == RET_PF_RETRY, fault->map_writable);
45624562
}
45634563

4564-
static int kvm_mmu_faultin_pfn_private(struct kvm_vcpu *vcpu,
4565-
struct kvm_page_fault *fault)
4564+
static int kvm_mmu_faultin_pfn_gmem(struct kvm_vcpu *vcpu,
4565+
struct kvm_page_fault *fault)
45664566
{
45674567
int max_order, r;
45684568

@@ -4589,8 +4589,8 @@ static int __kvm_mmu_faultin_pfn(struct kvm_vcpu *vcpu,
45894589
{
45904590
unsigned int foll = fault->write ? FOLL_WRITE : 0;
45914591

4592-
if (fault->is_private)
4593-
return kvm_mmu_faultin_pfn_private(vcpu, fault);
4592+
if (fault->is_private || kvm_memslot_is_gmem_only(fault->slot))
4593+
return kvm_mmu_faultin_pfn_gmem(vcpu, fault);
45944594

45954595
foll |= FOLL_NOWAIT;
45964596
fault->pfn = __kvm_faultin_pfn(fault->slot, fault->gfn, foll,

0 commit comments

Comments
 (0)