[PATCH 4/5] target/microblaze: Remove target_ulong use in helper_stackprot()

Philippe Mathieu-Daudé posted 5 patches 1 month, 1 week ago
Maintainers: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
There is a newer version of this series
[PATCH 4/5] target/microblaze: Remove target_ulong use in helper_stackprot()
Posted by Philippe Mathieu-Daudé 1 month, 1 week ago
Since commit 36a9529e60e ("target/microblaze: Simplify
compute_ldst_addr_type{a,b}"), helper_stackprot() takes
a TCGv_i32 argument.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/microblaze/helper.h    | 2 +-
 target/microblaze/op_helper.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
index ef4fad9b91e..01eba592b26 100644
--- a/target/microblaze/helper.h
+++ b/target/microblaze/helper.h
@@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_3(fcmp_ne, TCG_CALL_NO_WG, i32, env, i32, i32)
 DEF_HELPER_FLAGS_3(fcmp_ge, TCG_CALL_NO_WG, i32, env, i32, i32)
 
 DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_NO_RWG_SE, i32, i32, i32)
-DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, tl)
+DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, i32)
 DEF_HELPER_FLAGS_2(get, TCG_CALL_NO_RWG, i32, i32, i32)
 DEF_HELPER_FLAGS_3(put, TCG_CALL_NO_RWG, void, i32, i32, i32)
 
diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
index b8365b3b1d2..df93c4229d6 100644
--- a/target/microblaze/op_helper.c
+++ b/target/microblaze/op_helper.c
@@ -365,13 +365,13 @@ uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
     return 0;
 }
 
-void helper_stackprot(CPUMBState *env, target_ulong addr)
+void helper_stackprot(CPUMBState *env, uint32_t addr)
 {
     if (addr < env->slr || addr > env->shr) {
         CPUState *cs = env_cpu(env);
 
         qemu_log_mask(CPU_LOG_INT, "Stack protector violation at "
-                      TARGET_FMT_lx " %x %x\n",
+                                   "0x%x 0x%x 0x%x\n",
                       addr, env->slr, env->shr);
 
         env->ear = addr;
-- 
2.51.0


Re: [PATCH 4/5] target/microblaze: Remove target_ulong use in helper_stackprot()
Posted by Pierrick Bouvier 1 month, 1 week ago
On 10/7/25 11:01 PM, Philippe Mathieu-Daudé wrote:
> Since commit 36a9529e60e ("target/microblaze: Simplify
> compute_ldst_addr_type{a,b}"), helper_stackprot() takes
> a TCGv_i32 argument.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/microblaze/helper.h    | 2 +-
>   target/microblaze/op_helper.c | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
> index ef4fad9b91e..01eba592b26 100644
> --- a/target/microblaze/helper.h
> +++ b/target/microblaze/helper.h
> @@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_3(fcmp_ne, TCG_CALL_NO_WG, i32, env, i32, i32)
>   DEF_HELPER_FLAGS_3(fcmp_ge, TCG_CALL_NO_WG, i32, env, i32, i32)
>   
>   DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_NO_RWG_SE, i32, i32, i32)
> -DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, tl)
> +DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, i32)
>   DEF_HELPER_FLAGS_2(get, TCG_CALL_NO_RWG, i32, i32, i32)
>   DEF_HELPER_FLAGS_3(put, TCG_CALL_NO_RWG, void, i32, i32, i32)
>   
> diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
> index b8365b3b1d2..df93c4229d6 100644
> --- a/target/microblaze/op_helper.c
> +++ b/target/microblaze/op_helper.c
> @@ -365,13 +365,13 @@ uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
>       return 0;
>   }
>   
> -void helper_stackprot(CPUMBState *env, target_ulong addr)
> +void helper_stackprot(CPUMBState *env, uint32_t addr)
>   {
>       if (addr < env->slr || addr > env->shr) {
>           CPUState *cs = env_cpu(env);
>   
>           qemu_log_mask(CPU_LOG_INT, "Stack protector violation at "
> -                      TARGET_FMT_lx " %x %x\n",
> +                                   "0x%x 0x%x 0x%x\n",
>                         addr, env->slr, env->shr);
>   
>           env->ear = addr;

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


Re: [PATCH 4/5] target/microblaze: Remove target_ulong use in helper_stackprot()
Posted by Anton Johansson via 1 month, 1 week ago
On 08/10/25, Philippe Mathieu-Daudé wrote:
> Since commit 36a9529e60e ("target/microblaze: Simplify
> compute_ldst_addr_type{a,b}"), helper_stackprot() takes
> a TCGv_i32 argument.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  target/microblaze/helper.h    | 2 +-
>  target/microblaze/op_helper.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
> index ef4fad9b91e..01eba592b26 100644
> --- a/target/microblaze/helper.h
> +++ b/target/microblaze/helper.h
> @@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_3(fcmp_ne, TCG_CALL_NO_WG, i32, env, i32, i32)
>  DEF_HELPER_FLAGS_3(fcmp_ge, TCG_CALL_NO_WG, i32, env, i32, i32)
>  
>  DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_NO_RWG_SE, i32, i32, i32)
> -DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, tl)
> +DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, i32)
>  DEF_HELPER_FLAGS_2(get, TCG_CALL_NO_RWG, i32, i32, i32)
>  DEF_HELPER_FLAGS_3(put, TCG_CALL_NO_RWG, void, i32, i32, i32)
>  
> diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
> index b8365b3b1d2..df93c4229d6 100644
> --- a/target/microblaze/op_helper.c
> +++ b/target/microblaze/op_helper.c
> @@ -365,13 +365,13 @@ uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
>      return 0;
>  }
>  
> -void helper_stackprot(CPUMBState *env, target_ulong addr)
> +void helper_stackprot(CPUMBState *env, uint32_t addr)
>  {
>      if (addr < env->slr || addr > env->shr) {
>          CPUState *cs = env_cpu(env);
>  
>          qemu_log_mask(CPU_LOG_INT, "Stack protector violation at "
> -                      TARGET_FMT_lx " %x %x\n",
> +                                   "0x%x 0x%x 0x%x\n",
>                        addr, env->slr, env->shr);
>  
>          env->ear = addr;
> -- 
> 2.51.0
> 

Might as well update call sites to gen_helper_stackprot() as well.
compute_ldst_addr_type[ab]() calls into gen_helper_stackprot() but
returns TCGv.  That return value is passed to do_load() and
do_store() as TCGv, but the bodies of these function clearly expect
TCG_i32.

Otherwise

Reviewed-by: Anton Johansson <anjo@rev.ng>

Re: [PATCH 4/5] target/microblaze: Remove target_ulong use in helper_stackprot()
Posted by Philippe Mathieu-Daudé 1 month ago
On 8/10/25 12:22, Anton Johansson wrote:
> On 08/10/25, Philippe Mathieu-Daudé wrote:
>> Since commit 36a9529e60e ("target/microblaze: Simplify
>> compute_ldst_addr_type{a,b}"), helper_stackprot() takes
>> a TCGv_i32 argument.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   target/microblaze/helper.h    | 2 +-
>>   target/microblaze/op_helper.c | 4 ++--
>>   2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
>> index ef4fad9b91e..01eba592b26 100644
>> --- a/target/microblaze/helper.h
>> +++ b/target/microblaze/helper.h
>> @@ -20,7 +20,7 @@ DEF_HELPER_FLAGS_3(fcmp_ne, TCG_CALL_NO_WG, i32, env, i32, i32)
>>   DEF_HELPER_FLAGS_3(fcmp_ge, TCG_CALL_NO_WG, i32, env, i32, i32)
>>   
>>   DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_NO_RWG_SE, i32, i32, i32)
>> -DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, tl)
>> +DEF_HELPER_FLAGS_2(stackprot, TCG_CALL_NO_WG, void, env, i32)
>>   DEF_HELPER_FLAGS_2(get, TCG_CALL_NO_RWG, i32, i32, i32)
>>   DEF_HELPER_FLAGS_3(put, TCG_CALL_NO_RWG, void, i32, i32, i32)
>>   
>> diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
>> index b8365b3b1d2..df93c4229d6 100644
>> --- a/target/microblaze/op_helper.c
>> +++ b/target/microblaze/op_helper.c
>> @@ -365,13 +365,13 @@ uint32_t helper_pcmpbf(uint32_t a, uint32_t b)
>>       return 0;
>>   }
>>   
>> -void helper_stackprot(CPUMBState *env, target_ulong addr)
>> +void helper_stackprot(CPUMBState *env, uint32_t addr)
>>   {
>>       if (addr < env->slr || addr > env->shr) {
>>           CPUState *cs = env_cpu(env);
>>   
>>           qemu_log_mask(CPU_LOG_INT, "Stack protector violation at "
>> -                      TARGET_FMT_lx " %x %x\n",
>> +                                   "0x%x 0x%x 0x%x\n",
>>                         addr, env->slr, env->shr);
>>   
>>           env->ear = addr;
>> -- 
>> 2.51.0
>>
> 
> Might as well update call sites to gen_helper_stackprot() as well.
> compute_ldst_addr_type[ab]() calls into gen_helper_stackprot() but
> returns TCGv.  That return value is passed to do_load() and
> do_store() as TCGv, but the bodies of these function clearly expect
> TCG_i32.

Right, but tcg_gen_qemu_ld_i32/tcg_gen_qemu_st_i32() take a TCGv...

I'll address as follow up patches I think.

> 
> Otherwise
> 
> Reviewed-by: Anton Johansson <anjo@rev.ng>

Thanks!