[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bit
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bits |
Date: |
Thu, 9 Nov 2023 16:58:33 +0300 |
From: Nicholas Piggin <npiggin@gmail.com>
When storing a large decrementer value with the most significant
implemented bit set, it is to be treated as a negative and sign
extended.
This isn't hit for book3s DEC because of another bug, fixing it
in the next patch exposes this one and can cause additional
problems, so fix this first. It can be hit with HDECR and other
edge triggered types.
Fixes: a8dafa52518 ("target/ppc: Implement large decrementer support for TCG")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[ clg: removed extra cpu and pcc variables shadowing local variables ]
Signed-off-by: Cédric Le Goater <clg@kaod.org>
(cherry picked from commit c8fbc6b9f2f3c732ee3307093c1c5c367eaa64ae)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 9961abc505..5573ab467c 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -746,7 +746,9 @@ target_ulong cpu_ppc_load_decr(CPUPPCState *env)
* to 64 bits, otherwise it is a 32 bit value.
*/
if (env->spr[SPR_LPCR] & LPCR_LD) {
- return decr;
+ PowerPCCPU *cpu = env_archcpu(env);
+ PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+ return sextract64(decr, 0, pcc->lrg_decr_bits);
}
return (uint32_t) decr;
}
@@ -765,7 +767,7 @@ target_ulong cpu_ppc_load_hdecr(CPUPPCState *env)
* extended to 64 bits, otherwise it is 32 bits.
*/
if (pcc->lrg_decr_bits > 32) {
- return hdecr;
+ return sextract64(hdecr, 0, pcc->lrg_decr_bits);
}
return (uint32_t) hdecr;
}
--
2.39.2
- [Stable-7.2.7 00/62] Patch Round-up for stable 7.2.7, freeze on 2023-11-19, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 01/62] hw/ppc: Introduce functions for conversion between timebase and nanoseconds, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 03/62] hw/ppc: Round up the decrementer interval when converting to ns, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 02/62] host-utils: Add muldiv64_round_up, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 04/62] hw/ppc: Avoid decrementer rounding errors, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 08/62] linux-user/hppa: clear the PSW 'N' bit when delivering signals, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 09/62] linux-user/hppa: lock both words of function descriptor, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 07/62] hw/ppc: Always store the decrementer value, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 05/62] target/ppc: Sign-extend large decrementer to 64-bits,
Michael Tokarev <=
- [Stable-7.2.7 22/62] target/i386: Fix and add some comments next to SSE/AVX instructions., Michael Tokarev, 2023/11/09
- [Stable-7.2.7 13/62] hw/scsi/scsi-disk: Disallow block sizes smaller than 512 [CVE-2023-42467], Michael Tokarev, 2023/11/09
- [Stable-7.2.7 06/62] target/ppc: Decrementer fix BookE semantics, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 10/62] hw/cxl: Fix CFMW config memory leak, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 15/62] ui/vnc: fix handling of VNC_FEATURE_XVP, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 11/62] target/arm: Don't skip MTE checks for LDRT/STRT at EL0, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 12/62] accel/tcg: mttcg remove false-negative halted assertion, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 14/62] ui/vnc: fix debug output for invalid audio message, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 16/62] optionrom: Remove build-id section, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 21/62] tests/tcg/i386: correct mask for VPERM2F128/VPERM2I128, Michael Tokarev, 2023/11/09