Thread (3 messages) flat view 3 messages, 3 authors, 2026-07-17

Re: [PATCH] KVM: Use vma_lookup() in kvm_host_page_size()

From: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Date: 2026-07-09 08:51:25
Also in: kvm, lkml

David Woodhouse [off-list ref] writes:
From: David Woodhouse <redacted>

kvm_host_page_size() uses find_vma() to determine the host page size
backing a guest page. find_vma() returns the next VMA when the address
falls in an unmapped hole, which means an unmapped address inherits the
page size of a completely unrelated VMA at a higher address. This is
never a meaningful result.

Replace find_vma() with vma_lookup() so that a hole address returns
NULL, causing the function to return PAGE_SIZE (the safe default)
rather than an unrelated VMA's page size.
That's exactly right.
This is currently only cosmetic, as the only caller is in PPC book3s
support (kvmppc_xive_native_set_queue_config()) and subsequently returns
failure if !gfn_to_page() anyway.
Yup. The change make sense to me. Feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

quoted hunk ↗ jump to hunk
Signed-off-by: David Woodhouse <redacted>
---
 virt/kvm/kvm_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 89489996fbc1..d33761123459 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2693,7 +2693,7 @@ unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn)
 		return PAGE_SIZE;
 
 	mmap_read_lock(current->mm);
-	vma = find_vma(current->mm, addr);
+	vma = vma_lookup(current->mm, addr);
 	if (!vma)
 		goto out;
 
-- 
2.43.0
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help