[PATCH 1/2] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses

Max Chou posted 2 patches 2 weeks, 5 days ago
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
[PATCH 1/2] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
Posted by Max Chou 2 weeks, 5 days ago
When probe_pages probes a memory region that spans two pages, it calls
probe_access_flags twice - once for each page. However, the flags from
the second page probe were overwriting the flags from the first page
instead of being merged together.

Signed-off-by: Max Chou <max.chou@sifive.com>
---
 target/riscv/vector_helper.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
index 3334662dcd..a74ce70943 100644
--- a/target/riscv/vector_helper.c
+++ b/target/riscv/vector_helper.c
@@ -265,9 +265,9 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
         addr += curlen;
         curlen = len - curlen;
         if (flags != NULL) {
-            *flags = probe_access_flags(env, adjust_addr(env, addr), curlen,
-                                        access_type, mmu_index, nonfault,
-                                        host, ra);
+            *flags |= probe_access_flags(env, adjust_addr(env, addr), curlen,
+                                         access_type, mmu_index, nonfault,
+                                         host, ra);
         } else {
             probe_access(env, adjust_addr(env, addr), curlen, access_type,
                          mmu_index, ra);
@@ -275,7 +275,6 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
     }
 }
 
-
 static inline void vext_set_elem_mask(void *v0, int index,
                                       uint8_t value)
 {
-- 
2.43.7
Re: [PATCH 1/2] target/riscv: rvv: Fix missing flags merge in probe_pages for cross-page accesses
Posted by Alistair Francis 2 weeks, 4 days ago
On Wed, Mar 18, 2026 at 11:38 AM Max Chou <max.chou@sifive.com> wrote:
>
> When probe_pages probes a memory region that spans two pages, it calls
> probe_access_flags twice - once for each page. However, the flags from
> the second page probe were overwriting the flags from the first page
> instead of being merged together.
>
> Signed-off-by: Max Chou <max.chou@sifive.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/vector_helper.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> index 3334662dcd..a74ce70943 100644
> --- a/target/riscv/vector_helper.c
> +++ b/target/riscv/vector_helper.c
> @@ -265,9 +265,9 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
>          addr += curlen;
>          curlen = len - curlen;
>          if (flags != NULL) {
> -            *flags = probe_access_flags(env, adjust_addr(env, addr), curlen,
> -                                        access_type, mmu_index, nonfault,
> -                                        host, ra);
> +            *flags |= probe_access_flags(env, adjust_addr(env, addr), curlen,
> +                                         access_type, mmu_index, nonfault,
> +                                         host, ra);
>          } else {
>              probe_access(env, adjust_addr(env, addr), curlen, access_type,
>                           mmu_index, ra);
> @@ -275,7 +275,6 @@ static void probe_pages(CPURISCVState *env, target_ulong addr, target_ulong len,
>      }
>  }
>
> -
>  static inline void vext_set_elem_mask(void *v0, int index,
>                                        uint8_t value)
>  {
> --
> 2.43.7
>
>