[PATCH v3] target/riscv: Fix incorrect MMU_USER_IDX value

Wang Yechao posted 1 patch 3 weeks, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261027023729.680646-1-wang.yechao255@zte.com.cn
Maintainers: Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu@processmission.com>
target/riscv/cpu.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v3] target/riscv: Fix incorrect MMU_USER_IDX value
Posted by Wang Yechao 3 weeks, 6 days ago
MMU_USER_IDX is defined as 3, but the RISC-V user-mode MMU index
is MMUIdx_U, which is 0. This macro is used by the generic
cpu_mmu_index() for CONFIG_USER_ONLY builds and must match
riscv_env_mmu_index(), so fix the value to 0.

Fixes: dc5bd18fa572 ("RISC-V CPU Core Definition")
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
---
Changes in v3:
- Keep the MMU_USER_IDX macro because cpu_mmu_index() needs it.
- Link to v2: https://lore.kernel.org/qemu-devel/20261026031144.631964-1-wang.yechao255@zte.com.cn/

Changes in v2:
- Adjust the patch descriptions and rebased on riscv-to-apply.next.
- Link to v1: https://lore.kernel.org/qemu-devel/20260107161336108RbvgIEJ1pww_fKZtMreFp@zte.com.cn/

 target/riscv/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index b65d631994..aaf16231de 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -180,7 +180,7 @@ extern RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[];
 
 #define RISCV_IMPLIED_EXTS_RULE_END -1
 
-#define MMU_USER_IDX 3
+#define MMU_USER_IDX 0   /* MMUIdx_U */
 
 #if !defined(CONFIG_USER_ONLY)
 #include "tcg/pmp.h"
-- 
2.27.0
Re: [PATCH v3] target/riscv: Fix incorrect MMU_USER_IDX value
Posted by Alistair Francis 1 week, 5 days ago
On Tue, 2026-10-27 at 10:37 +0800, Wang Yechao wrote:
> MMU_USER_IDX is defined as 3, but the RISC-V user-mode MMU index
> is MMUIdx_U, which is 0. This macro is used by the generic
> cpu_mmu_index() for CONFIG_USER_ONLY builds and must match
> riscv_env_mmu_index(), so fix the value to 0.
> 
> Fixes: dc5bd18fa572 ("RISC-V CPU Core Definition")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>

Thanks!

Applied to riscv-to-apply.next

Alistair

> ---
> Changes in v3:
> - Keep the MMU_USER_IDX macro because cpu_mmu_index() needs it.
> - Link to v2:
> https://lore.kernel.org/qemu-devel/20261026031144.631964-1-wang.yechao255@zte.com.cn/
> 
> Changes in v2:
> - Adjust the patch descriptions and rebased on riscv-to-apply.next.
> - Link to v1:
> https://lore.kernel.org/qemu-devel/20260107161336108RbvgIEJ1pww_fKZtMreFp@zte.com.cn/
> 
>  target/riscv/cpu.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index b65d631994..aaf16231de 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -180,7 +180,7 @@ extern RISCVCPUImpliedExtsRule
> *riscv_multi_ext_implied_rules[];
>  
>  #define RISCV_IMPLIED_EXTS_RULE_END -1
>  
> -#define MMU_USER_IDX 3
> +#define MMU_USER_IDX 0   /* MMUIdx_U */
>  
>  #if !defined(CONFIG_USER_ONLY)
>  #include "tcg/pmp.h"
Re: [PATCH v3] target/riscv: Fix incorrect MMU_USER_IDX value
Posted by Alistair Francis 1 week, 5 days ago
On Tue, 2026-10-27 at 10:37 +0800, Wang Yechao wrote:
> MMU_USER_IDX is defined as 3, but the RISC-V user-mode MMU index
> is MMUIdx_U, which is 0. This macro is used by the generic
> cpu_mmu_index() for CONFIG_USER_ONLY builds and must match
> riscv_env_mmu_index(), so fix the value to 0.
> 
> Fixes: dc5bd18fa572 ("RISC-V CPU Core Definition")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>

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

Alistair

> ---
> Changes in v3:
> - Keep the MMU_USER_IDX macro because cpu_mmu_index() needs it.
> - Link to v2:
> https://lore.kernel.org/qemu-devel/20261026031144.631964-1-wang.yechao255@zte.com.cn/
> 
> Changes in v2:
> - Adjust the patch descriptions and rebased on riscv-to-apply.next.
> - Link to v1:
> https://lore.kernel.org/qemu-devel/20260107161336108RbvgIEJ1pww_fKZtMreFp@zte.com.cn/
> 
>  target/riscv/cpu.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index b65d631994..aaf16231de 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -180,7 +180,7 @@ extern RISCVCPUImpliedExtsRule
> *riscv_multi_ext_implied_rules[];
>  
>  #define RISCV_IMPLIED_EXTS_RULE_END -1
>  
> -#define MMU_USER_IDX 3
> +#define MMU_USER_IDX 0   /* MMUIdx_U */
>  
>  #if !defined(CONFIG_USER_ONLY)
>  #include "tcg/pmp.h"
Re: [PATCH v3] target/riscv: Fix incorrect MMU_USER_IDX value
Posted by Nutty.Liu 3 weeks, 6 days ago
On 10/27/2026 10:37 AM, Wang Yechao wrote:
> MMU_USER_IDX is defined as 3, but the RISC-V user-mode MMU index
> is MMUIdx_U, which is 0. This macro is used by the generic
> cpu_mmu_index() for CONFIG_USER_ONLY builds and must match
> riscv_env_mmu_index(), so fix the value to 0.
>
> Fixes: dc5bd18fa572 ("RISC-V CPU Core Definition")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>

Thanks,
Nutty
> ---
> Changes in v3:
> - Keep the MMU_USER_IDX macro because cpu_mmu_index() needs it.
> - Link to v2: https://lore.kernel.org/qemu-devel/20261026031144.631964-1-wang.yechao255@zte.com.cn/
>
> Changes in v2:
> - Adjust the patch descriptions and rebased on riscv-to-apply.next.
> - Link to v1: https://lore.kernel.org/qemu-devel/20260107161336108RbvgIEJ1pww_fKZtMreFp@zte.com.cn/
>
>   target/riscv/cpu.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index b65d631994..aaf16231de 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -180,7 +180,7 @@ extern RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rules[];
>   
>   #define RISCV_IMPLIED_EXTS_RULE_END -1
>   
> -#define MMU_USER_IDX 3
> +#define MMU_USER_IDX 0   /* MMUIdx_U */
>   
>   #if !defined(CONFIG_USER_ONLY)
>   #include "tcg/pmp.h"