[PATCH v2 3/5] target/avr: fix avr features processing

Pavel Dovgalyuk posted 5 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v2 3/5] target/avr: fix avr features processing
Posted by Pavel Dovgalyuk 2 years, 7 months ago
Bit vector for features has 64 bits. This patch fixes bit shifts in
avr_feature and set_avr_feature functions to be 64-bit too.

Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
---
 target/avr/cpu.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/avr/cpu.h b/target/avr/cpu.h
index 7c3895b65e..280edc495b 100644
--- a/target/avr/cpu.h
+++ b/target/avr/cpu.h
@@ -166,12 +166,12 @@ vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr);
 
 static inline int avr_feature(CPUAVRState *env, AVRFeature feature)
 {
-    return (env->features & (1U << feature)) != 0;
+    return (env->features & (1ULL << feature)) != 0;
 }
 
 static inline void set_avr_feature(CPUAVRState *env, int feature)
 {
-    env->features |= (1U << feature);
+    env->features |= (1ULL << feature);
 }
 
 #define cpu_list avr_cpu_list
Re: [PATCH v2 3/5] target/avr: fix avr features processing
Posted by Richard Henderson 2 years, 7 months ago
On 1/18/23 23:22, Pavel Dovgalyuk wrote:
> Bit vector for features has 64 bits. This patch fixes bit shifts in
> avr_feature and set_avr_feature functions to be 64-bit too.
> 
> Signed-off-by: Pavel Dovgalyuk<Pavel.Dovgalyuk@ispras.ru>
> Reviewed-by: Michael Rolnik<mrolnik@gmail.com>
> ---
>   target/avr/cpu.h |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Re: [PATCH v2 3/5] target/avr: fix avr features processing
Posted by Philippe Mathieu-Daudé 2 years, 7 months ago
On 19/1/23 10:22, Pavel Dovgalyuk wrote:
> Bit vector for features has 64 bits. This patch fixes bit shifts in
> avr_feature and set_avr_feature functions to be 64-bit too.
> 
> Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
> Reviewed-by: Michael Rolnik <mrolnik@gmail.com>
> ---
>   target/avr/cpu.h |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/avr/cpu.h b/target/avr/cpu.h
> index 7c3895b65e..280edc495b 100644
> --- a/target/avr/cpu.h
> +++ b/target/avr/cpu.h
> @@ -166,12 +166,12 @@ vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr);
>   
>   static inline int avr_feature(CPUAVRState *env, AVRFeature feature)
>   {
> -    return (env->features & (1U << feature)) != 0;
> +    return (env->features & (1ULL << feature)) != 0;
>   }
>   
>   static inline void set_avr_feature(CPUAVRState *env, int feature)
>   {
> -    env->features |= (1U << feature);
> +    env->features |= (1ULL << feature);
>   }

Consider using extract64() or BIT_ULL(). Regardless:

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>