Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-12-03 Thread Philippe Mathieu-Daudé
Hi Alistair, On 3/12/24 07:31, Alistair Francis wrote: On Thu, Nov 28, 2024 at 7:39 PM Peter Maydell wrote: In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that "1 << cause" is undefined

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-12-02 Thread Alistair Francis
On Thu, Nov 28, 2024 at 7:39 PM Peter Maydell wrote: > > In riscv_cpu_do_interrupt() we use the 'cause' value we got out of > cs->exception as a shift value. However this value can be larger > than 31, which means that "1 << cause" is undefined behaviour, > because we do the shift on an 'int' typ

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-12-02 Thread Richard Henderson
On 12/2/24 07:46, Peter Maydell wrote: On Thu, 28 Nov 2024 at 12:59, Richard Henderson wrote: On 11/28/24 04:38, Peter Maydell wrote: In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-12-02 Thread Alistair Francis
On Thu, Nov 28, 2024 at 7:39 PM Peter Maydell wrote: > > In riscv_cpu_do_interrupt() we use the 'cause' value we got out of > cs->exception as a shift value. However this value can be larger > than 31, which means that "1 << cause" is undefined behaviour, > because we do the shift on an 'int' typ

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-12-02 Thread Peter Maydell
On Thu, 28 Nov 2024 at 12:59, Richard Henderson wrote: > > On 11/28/24 04:38, Peter Maydell wrote: > > In riscv_cpu_do_interrupt() we use the 'cause' value we got out of > > cs->exception as a shift value. However this value can be larger > > than 31, which means that "1 << cause" is undefined be

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-11-28 Thread Richard Henderson
On 11/28/24 04:38, Peter Maydell wrote: In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that "1 << cause" is undefined behaviour, because we do the shift on an 'int' type. This causes the un

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-11-28 Thread Peter Maydell
On Thu, 28 Nov 2024 at 11:20, Daniel Henrique Barboza wrote: > > > > On 11/28/24 7:38 AM, Peter Maydell wrote: > > In riscv_cpu_do_interrupt() we use the 'cause' value we got out of > > cs->exception as a shift value. However this value can be larger > > than 31, which means that "1 << cause" is

Re: [PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-11-28 Thread Daniel Henrique Barboza
On 11/28/24 7:38 AM, Peter Maydell wrote: In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that "1 << cause" is undefined behaviour, because we do the shift on an 'int' type. This causes t

[PATCH for-9.2] target/riscv: Avoid bad shift in riscv_cpu_do_interrupt()

2024-11-28 Thread Peter Maydell
In riscv_cpu_do_interrupt() we use the 'cause' value we got out of cs->exception as a shift value. However this value can be larger than 31, which means that "1 << cause" is undefined behaviour, because we do the shift on an 'int' type. This causes the undefined behaviour sanitizer to complain on