Thread (3 messages) 3 messages, 3 authors, 4d ago
COOLING4d

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

From: David Woodhouse <dwmw2@infradead.org>
Date: 2026-07-05 08:38:21
Also in: kvm, lkml
Subsystem: kernel virtual machine (kvm), the rest · Maintainers: Paolo Bonzini, Linus Torvalds

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.

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.

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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help