]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/arm: Fix reads of CNTFRQ_EL0 in linux-user mode
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 23 Oct 2025 12:12:50 +0000 (13:12 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 23 Oct 2025 12:12:50 +0000 (13:12 +0100)
commit3f462d79a080060e54e39d31ce10fdf1a20317ef
treeb34d22330c25c3f932bcec7a6787803ec7eb5daf
parent2132c93fb97db6fc52f29ba685f109d8db5b6f92
target/arm: Fix reads of CNTFRQ_EL0 in linux-user mode

In commit bd8e9ddf6f6 ("target/arm: Refactor default generic timer
frequency handling") we changed how we initialized the generic timer
frequency as reported in the CNTFRQ_EL0 register.  As part of that,
we chanegd the linux-user version of the CNTFRQ_EL0 sysreg from
having a constant value set at compile time through the .resetvalue
field to having a reset value which we compute in a .resetfn.

This accidentally broke the reading of CNTFRQ_EL0 in linux-user mode,
because the cpreg is marked as ARM_CP_CONST, which means we translate
it as a read of the compile-time constant value in the .resetvalue
field.  This is now zero, so userspace sees a 0 frequency value.

Fix the bug by dropping the ARM_CP_CONST marking.  This will cause us
to translate the read as a load of the value from the CPU state
struct cp15.c14_cntfrq field, which is where the real frequency value
now lives.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3159
Fixes: bd8e9ddf6f6 ("target/arm: Refactor default generic timer frequency handling")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20251013161040.216819-1-peter.maydell@linaro.org
target/arm/helper.c