mirror_qemu/target/arm
Peter Maydell 1aa4512ecd target/arm: Saturate L2CTLR_EL1 core count field rather than overflowing
The IMPDEF sysreg L2CTLR_EL1 found on the Cortex-A35, A53, A57, A72
and which we (arguably dubiously) also provide in '-cpu max' has a
2 bit field for the number of processors in the cluster. On real
hardware this must be sufficient because it can only be configured
with up to 4 CPUs in the cluster. However on QEMU if the board code
does not explicitly configure the code into clusters with the right
CPU count we default to "give the value assuming that all CPUs in
the system are in a single cluster", which might be too big to fit
in the field.

Instead of just overflowing this 2-bit field, saturate to 3 (meaning
"4 CPUs", so at least we don't overwrite other fields in the register.
It's unlikely that any guest code really cares about the value in
this field; at least, if it does it probably also wants the system
to be more closely matching real hardware, i.e. not to have more
than 4 CPUs.

This issue has been present since the L2CTLR was first added in
commit 377a44ec8f back in 2014. It was only noticed because
Coverity complains (CID 1509227) that the shift might overflow 32 bits
and inadvertently sign extend into the top half of the 64 bit value.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20230512170223.3801643-2-peter.maydell@linaro.org
2023-05-18 11:39:33 +01:00
..
hvf hvf: arm: Add support for GICv3 2023-02-03 12:59:22 +00:00
tcg target/arm: Convert ERET, ERETAA, ERETAB to decodetree 2023-05-18 11:35:38 +01:00
Kconfig target/arm: Select CONFIG_ARM_V7M when TCG is enabled 2023-05-12 15:49:20 +01:00
arch_dump.c dump: Replace opaque DumpState pointer with a typed one 2022-10-06 19:30:43 +04:00
arm-powerctl.c target/arm: Wrap arm_rebuild_hflags calls with tcg_enabled 2023-02-27 13:27:04 +00:00
arm-powerctl.h target/arm/arm-powerctl: Add new arm_set_cpu_on_and_reset() 2019-02-28 11:03:04 +00:00
arm-qmp-cmds.c target/arm: Restrict 'qapi-commands-machine.h' to system emulation 2023-03-02 07:51:06 +01:00
common-semi-target.h semihosting: Split out common-semi-target.h 2022-06-28 04:35:07 +05:30
cortex-regs.c target/arm: Saturate L2CTLR_EL1 core count field rather than overflowing 2023-05-18 11:39:33 +01:00
cpregs.h target/arm: Move cortex sysregs into a separate file 2023-05-02 10:21:32 +01:00
cpu-param.h target/arm: Remove `NB_MMU_MODES` define 2023-03-13 06:44:37 -07:00
cpu-qom.h target/arm: Convert to 3-phase reset 2022-12-16 15:58:15 +00:00
cpu.c arm/kvm: add support for MTE 2023-05-18 11:08:38 +01:00
cpu.h arm/kvm: add support for MTE 2023-05-18 11:08:38 +01:00
cpu64.c target/arm: Move 64-bit TCG CPUs into tcg/ 2023-05-02 10:21:32 +01:00
debug_helper.c target/arm: add RAZ/WI handling for DBGDTR[TX|RX] 2023-05-18 11:09:36 +01:00
gdbstub.c target/arm: Report pauth information to gdb as 'pauth_v2' 2023-04-20 10:21:16 +01:00
gdbstub64.c target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check 2023-05-12 16:01:25 +01:00
helper.c target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check 2023-05-12 16:01:25 +01:00
helper.h target/arm: Move helper-{a64,mve,sme,sve}.h to tcg/ 2023-05-12 15:43:37 +01:00
hvf_arm.h target: Use forward declared type instead of structure type 2022-03-06 22:22:40 +01:00
idau.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
internals.h target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check 2023-05-12 16:01:25 +01:00
kvm-consts.h target/arm: Remove KVM AArch32 CPU definitions 2023-04-20 10:21:15 +01:00
kvm-stub.c target/arm: Avoid bare abort() or assert(0) 2022-05-05 09:35:51 +01:00
kvm.c arm/kvm: add support for MTE 2023-05-18 11:08:38 +01:00
kvm64.c arm/kvm: add support for MTE 2023-05-18 11:08:38 +01:00
kvm_arm.h arm/kvm: add support for MTE 2023-05-18 11:08:38 +01:00
machine.c target/arm: Wrap arm_rebuild_hflags calls with tcg_enabled 2023-02-27 13:27:04 +00:00
meson.build target/arm: move cpu_tcg to tcg/cpu32.c 2023-05-02 10:54:31 +01:00
op_addsub.h
ptw.c target/arm: Correct AArch64.S2MinTxSZ 32-bit EL1 input size check 2023-05-12 16:01:25 +01:00
syndrome.h target/arm: Implement the HFGITR_EL2.ERET trap 2023-02-03 12:59:24 +00:00
tcg-stubs.c target/arm: Move hflags code into the tcg directory 2023-02-27 13:27:04 +00:00
trace-events docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
vfp_helper.c target/arm: Improve arm_rmode_to_sf 2023-03-13 06:44:38 -07:00