Re: [PATCH] RISC-V: KVM: Allow memslots ending at the GPA limit

Anup Patel <[email protected]>
Newsgroups org.infradead.lists.linux-riscv,org.infradead.lists.kvm-riscv,org.kernel.vger.kvm,org.kernel.vger.linux-kernel
Message-ID <CAAhSdy1pw+g84HFq9okYcfmG9_nV=Te8q0YHt5yNtf6zsYP9sQ@mail.gmail.com>
On Sat, Jul 18, 2026 at 9:22 AM Pengpeng Hou <[email protected]> wrote:
>
> KVM memslots describe half-open ranges [base_gfn, base_gfn + npages). A
> slot ending exactly at the guest physical-address limit has its final page
> below that limit and is valid.
>
> The current greater-than-or-equal comparison rejects a valid boundary case.
> Use a strict greater-than comparison, matching equivalent KVM architecture
> checks.
>
> Fixes: 9d05c1fee837 ("RISC-V: KVM: Implement stage2 page table programming")
> Signed-off-by: Pengpeng Hou <[email protected]>

LGTM.

Reviewed-by: Anup Patel <[email protected]>

Queued this patch for Linux-7.3

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 082f9b2617338..d3c0c699adb60 100644
> --- a/arch/riscv/kvm/mmu.c
> +++ b/arch/riscv/kvm/mmu.c
> @@ -184,7 +184,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
>          * Prevent userspace from creating a memory region outside of the GPA
>          * space addressable by the KVM guest GPA space.
>          */
> -       if ((new->base_gfn + new->npages) >=
> +       if ((new->base_gfn + new->npages) >
>              kvm_riscv_gstage_gpa_size(kvm->arch.pgd_levels) >> PAGE_SHIFT)
>                 return -EFAULT;
>
> --
> 2.43.0
>

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.