Re: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Peter Maydell
On Mon, 13 Sept 2021 at 19:09, Luis Fernando Fujita Pires wrote: > > > > value = extract64(value, 0, nr_bits); > > > value = ((target_long)value << (64 - nr_bits)) >> (64 - nr_bits); > > > > Oops, sorry. 64 might not be correct here. It would depend on the target > > being > > either 32 o

Re: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Cédric Le Goater
On 9/13/21 8:05 PM, Luis Fernando Fujita Pires wrote: >>> value = extract64(value, 0, nr_bits); >>> value = ((target_long)value << (64 - nr_bits)) >> (64 - nr_bits); >> >> Oops, sorry. 64 might not be correct here. It would depend on the target >> being >> either 32 or 64. > > In fact, se

RE: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Luis Fernando Fujita Pires
> > value = extract64(value, 0, nr_bits); > > value = ((target_long)value << (64 - nr_bits)) >> (64 - nr_bits); > > Oops, sorry. 64 might not be correct here. It would depend on the target being > either 32 or 64. In fact, sextract already does the sign extension, so this should be all th

RE: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Luis Fernando Fujita Pires
> value = extract64(value, 0, nr_bits); > value = ((target_long)value << (64 - nr_bits)) >> (64 - nr_bits); Oops, sorry. 64 might not be correct here. It would depend on the target being either 32 or 64. -- Luis Pires Instituto de Pesquisas ELDORADO Aviso Legal - Disclaimer

RE: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Luis Fernando Fujita Pires
> > bool negative; > > > > /* Truncate value to decr_width and sign extend for simplicity */ > > -value &= ((1ULL << nr_bits) - 1); > > +value &= MAKE_64BIT_MASK(0, nr_bits); > > What about: > >value = extract64(value, 0, nr_bits); >if (value != sextract64(value,

Re: [PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Philippe Mathieu-Daudé
On 9/13/21 6:27 PM, Cédric Le Goater wrote: > The current way the mask is built can overflow with a 64-bit decrementer. > Use MAKE_64BIT_MASK instead. > > Fixes: a8dafa525181 ("target/ppc: Implement large decrementer support for > TCG") > Signed-off-by: Cédric Le Goater > --- > > This was foun

[PATCH] target/ppc: Fix 64-bit decrementer

2021-09-13 Thread Cédric Le Goater
The current way the mask is built can overflow with a 64-bit decrementer. Use MAKE_64BIT_MASK instead. Fixes: a8dafa525181 ("target/ppc: Implement large decrementer support for TCG") Signed-off-by: Cédric Le Goater --- This was found with the QEMU Microwatt machine which uses a 64bit decrement