qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] target/ppc: Fix 64-bit decrementer
@ 2021-09-14  8:54 Cédric Le Goater
  2021-09-14  9:19 ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Cédric Le Goater @ 2021-09-14  8:54 UTC (permalink / raw)
  To: David Gibson, Greg Kurz
  Cc: qemu-ppc, Luis Fernando Fujita Pires, Philippe Mathieu-Daudé,
	qemu-devel, Cédric Le Goater

The current way the mask is built can overflow with a 64-bit decrementer.
Use sextract64() instead.

Cc: Luis Fernando Fujita Pires <luis.pires@eldorado.org.br>
Fixes: a8dafa525181 ("target/ppc: Implement large decrementer support for TCG")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 v2: replaced MAKE_64BIT_MASK by sextract64

 hw/ppc/ppc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 7375bf4fa910..4f14464c9220 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -876,7 +876,7 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
     bool negative;
 
     /* Truncate value to decr_width and sign extend for simplicity */
-    value &= ((1ULL << nr_bits) - 1);
+    value = sextract64(value, 0, nr_bits);
     negative = !!(value & (1ULL << (nr_bits - 1)));
     if (negative) {
         value |= (0xFFFFFFFFULL << nr_bits);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-14 15:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-14  8:54 [PATCH v2] target/ppc: Fix 64-bit decrementer Cédric Le Goater
2021-09-14  9:19 ` Peter Maydell
2021-09-14  9:47   ` Cédric Le Goater
2021-09-14 10:23     ` Peter Maydell
2021-09-14 13:21     ` Richard Henderson
2021-09-14 13:43       ` Cédric Le Goater
2021-09-14 14:41         ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).