* [PATCH] KVM: Use vma_lookup() in kvm_host_page_size()
@ 2026-07-05 8:38 David Woodhouse
2026-07-09 8:46 ` Ritesh Harjani
0 siblings, 1 reply; 2+ messages in thread
From: David Woodhouse @ 2026-07-05 8:38 UTC (permalink / raw)
To: Paolo Bonzini
Cc: kvm, linux-kernel, Madhavan Srinivasan, Nicholas Piggin,
Michael Ellerman, Christophe Leroy (CS GROUP), linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]
From: David Woodhouse <dwmw@amazon.co.uk>
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 <dwmw@amazon.co.uk>
---
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
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5069 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: Use vma_lookup() in kvm_host_page_size()
2026-07-05 8:38 [PATCH] KVM: Use vma_lookup() in kvm_host_page_size() David Woodhouse
@ 2026-07-09 8:46 ` Ritesh Harjani
0 siblings, 0 replies; 2+ messages in thread
From: Ritesh Harjani @ 2026-07-09 8:46 UTC (permalink / raw)
To: David Woodhouse, Paolo Bonzini
Cc: kvm, linux-kernel, Madhavan Srinivasan, Nicholas Piggin,
Michael Ellerman, Christophe Leroy (CS GROUP), linuxppc-dev
David Woodhouse <dwmw2@infradead.org> writes:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> 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>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-09 8:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05 8:38 [PATCH] KVM: Use vma_lookup() in kvm_host_page_size() David Woodhouse
2026-07-09 8:46 ` Ritesh Harjani
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox