[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.2 46/60] target/arm: Don't get MDCR_EL2 in pmu_counter_enabl
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.2 46/60] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU |
Date: |
Wed, 21 Feb 2024 11:20:34 +0300 |
From: Peter Maydell <peter.maydell@linaro.org>
It doesn't make sense to read the value of MDCR_EL2 on a non-A-profile
CPU, and in fact if you try to do it we will assert:
#6 0x00007ffff4b95e96 in __GI___assert_fail
(assertion=0x5555565a8c70 "!arm_feature(env, ARM_FEATURE_M)",
file=0x5555565a6e5c "../../target/arm/helper.c", line=12600,
function=0x5555565a9560 <__PRETTY_FUNCTION__.0> "arm_security_space_below_el3")
at ./assert/assert.c:101
#7 0x0000555555ebf412 in arm_security_space_below_el3 (env=0x555557bc8190) at
../../target/arm/helper.c:12600
#8 0x0000555555ea6f89 in arm_is_el2_enabled (env=0x555557bc8190) at
../../target/arm/cpu.h:2595
#9 0x0000555555ea942f in arm_mdcr_el2_eff (env=0x555557bc8190) at
../../target/arm/internals.h:1512
We might call pmu_counter_enabled() on an M-profile CPU (for example
from the migration pre/post hooks in machine.c); this should always
return false because these CPUs don't set ARM_FEATURE_PMU.
Avoid the assertion by not calling arm_mdcr_el2_eff() before we
have done the early return for "PMU not present".
This fixes an assertion failure if you try to do a loadvm or
savevm for an M-profile board.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2155
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: 20240208153346.970021-1-peter.maydell@linaro.org
(cherry picked from commit ac1d88e9e7ca0bed83e91e07ce6d0597f10cc77d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 6515c5e89c..df1646de3a 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1169,13 +1169,21 @@ static bool pmu_counter_enabled(CPUARMState *env,
uint8_t counter)
bool enabled, prohibited = false, filtered;
bool secure = arm_is_secure(env);
int el = arm_current_el(env);
- uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
- uint8_t hpmn = mdcr_el2 & MDCR_HPMN;
+ uint64_t mdcr_el2;
+ uint8_t hpmn;
+ /*
+ * We might be called for M-profile cores where MDCR_EL2 doesn't
+ * exist and arm_mdcr_el2_eff() will assert, so this early-exit check
+ * must be before we read that value.
+ */
if (!arm_feature(env, ARM_FEATURE_PMU)) {
return false;
}
+ mdcr_el2 = arm_mdcr_el2_eff(env);
+ hpmn = mdcr_el2 & MDCR_HPMN;
+
if (!arm_feature(env, ARM_FEATURE_EL2) ||
(counter < hpmn || counter == 31)) {
e = env->cp15.c9_pmcr & PMCRE;
--
2.39.2
- [Stable-8.2.2 52/60] i386/cpuid: Move leaf 7 to correct group, (continued)
- [Stable-8.2.2 52/60] i386/cpuid: Move leaf 7 to correct group, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 24/60] hw/smbios: Fix OEM strings table option validation, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 33/60] hw/cxl: Pass CXLComponentState to cache_mem_ops, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 50/60] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 60/60] tests/qtest: Depend on dbus_display1_dep, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 54/60] ui: reject extended clipboard message if not activated, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 42/60] target/arm: Adjust and validate mtedesc sizem1, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 31/60] cxl/cdat: Fix header sum value in CDAT checksum, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 53/60] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 37/60] tests/acpi: Allow update of DSDT.cxl, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 46/60] target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU,
Michael Tokarev <=
- [Stable-8.2.2 32/60] hw/cxl/device: read from register values in mdev_reg_read(), Michael Tokarev, 2024/02/21
- [Stable-8.2.2 49/60] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 43/60] target/arm: Split out make_svemte_desc, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 41/60] target/arm: Fix nregs computation in do_{ld, st}_zpa, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 44/60] target/arm: Handle mte in do_ldrq, do_ldro, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 35/60] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 55/60] ui/clipboard: mark type as not available when there is no data, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 19/60] virtio-blk: avoid using ioeventfd state in irqfd conditional, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 57/60] ui/console: Fix console resize with placeholder surface, Michael Tokarev, 2024/02/21
- [Stable-8.2.2 26/60] hw/net/tulip: add chip status register values, Michael Tokarev, 2024/02/21