2022-11-01 05:58:53

by Bo Liu

[permalink] [raw]
Subject: [PATCH] RISC-V: KVM: use vma_lookup() instead of find_vma_intersection()

vma_lookup() finds the vma of a specific address with a cleaner interface
and is more readable.

Signed-off-by: Bo Liu <[email protected]>
---
arch/riscv/kvm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
index 3620ecac2fa1..5942d10c9736 100644
--- a/arch/riscv/kvm/mmu.c
+++ b/arch/riscv/kvm/mmu.c
@@ -632,7 +632,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,

mmap_read_lock(current->mm);

- vma = find_vma_intersection(current->mm, hva, hva + 1);
+ vma = vma_lookup(current->mm, hva);
if (unlikely(!vma)) {
kvm_err("Failed to find VMA for hva 0x%lx\n", hva);
mmap_read_unlock(current->mm);
--
2.27.0



2022-11-02 08:46:48

by Andrew Jones

[permalink] [raw]
Subject: Re: [PATCH] RISC-V: KVM: use vma_lookup() instead of find_vma_intersection()

On Tue, Nov 01, 2022 at 01:38:11AM -0400, Bo Liu wrote:
> vma_lookup() finds the vma of a specific address with a cleaner interface
> and is more readable.
>
> Signed-off-by: Bo Liu <[email protected]>
> ---
> arch/riscv/kvm/mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> index 3620ecac2fa1..5942d10c9736 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
> @@ -632,7 +632,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
>
> mmap_read_lock(current->mm);
>
> - vma = find_vma_intersection(current->mm, hva, hva + 1);
> + vma = vma_lookup(current->mm, hva);
> if (unlikely(!vma)) {
> kvm_err("Failed to find VMA for hva 0x%lx\n", hva);
> mmap_read_unlock(current->mm);
> --
> 2.27.0
>
>

Reviewed-by: Andrew Jones <[email protected]>

2022-11-27 12:21:04

by Anup Patel

[permalink] [raw]
Subject: Re: [PATCH] RISC-V: KVM: use vma_lookup() instead of find_vma_intersection()

On Tue, Nov 1, 2022 at 11:08 AM Bo Liu <[email protected]> wrote:
>
> vma_lookup() finds the vma of a specific address with a cleaner interface
> and is more readable.
>
> Signed-off-by: Bo Liu <[email protected]>

Looks good to me.

Queued this patch for Linux-6.2

Thanks,
Anup

> ---
> arch/riscv/kvm/mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
> index 3620ecac2fa1..5942d10c9736 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
> @@ -632,7 +632,7 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
>
> mmap_read_lock(current->mm);
>
> - vma = find_vma_intersection(current->mm, hva, hva + 1);
> + vma = vma_lookup(current->mm, hva);
> if (unlikely(!vma)) {
> kvm_err("Failed to find VMA for hva 0x%lx\n", hva);
> mmap_read_unlock(current->mm);
> --
> 2.27.0
>