mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
target/arm: Make number of counters in PMCR follow the CPU
Currently we give all the v7-and-up CPUs a PMU with 4 counters. This means that we don't provide the 6 counters that are required by the Arm BSA (Base System Architecture) specification if the CPU supports the Virtualization extensions. Instead of having a single PMCR_NUM_COUNTERS, make each CPU type specify the PMCR reset value (obtained from the appropriate TRM), and use the 'N' field of that value to define the number of counters provided. This means that we now supply 6 counters instead of 4 for: Cortex-A9, Cortex-A15, Cortex-A53, Cortex-A57, Cortex-A72, Cortex-A76, Neoverse-N1, '-cpu max' This CPU goes from 4 to 8 counters: A64FX These CPUs remain with 4 counters: Cortex-A7, Cortex-A8 This CPU goes down from 4 to 3 counters: Cortex-R5 Note that because we now use the PMCR reset value of the specific implementation, we no longer set the LC bit out of reset. This has an UNKNOWN value out of reset for all cores with any AArch32 support, so guest software should be setting it anyway if it wants it. This change was originally landed in commitf7fb73b8cd
(during the 6.0 release cycle) but was then reverted by commit21c2dd77a6
before that release because it did not work with KVM. This version fixes that by creating the scratch vCPU in kvm_arm_get_host_cpu_features() with the KVM_ARM_VCPU_PMU_V3 feature if KVM supports it, and then only asking KVM for the PMCR_EL0 value if the vCPU has a PMU. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> [PMM: Added the correct value for a64fx] Message-id: 20220513122852.4063586-1-peter.maydell@linaro.org
This commit is contained in:
parent
1a13efcc56
commit
24526bb92f
6 changed files with 47 additions and 12 deletions
|
@ -39,7 +39,6 @@
|
|||
#include "cpregs.h"
|
||||
|
||||
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
|
||||
#define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
|
@ -5544,13 +5543,6 @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
|
|||
.resetvalue = 0,
|
||||
.writefn = gt_hyp_ctl_write, .raw_writefn = raw_write },
|
||||
#endif
|
||||
/* The only field of MDCR_EL2 that has a defined architectural reset value
|
||||
* is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N.
|
||||
*/
|
||||
{ .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
|
||||
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
|
||||
.access = PL2_RW, .resetvalue = PMCR_NUM_COUNTERS,
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), },
|
||||
{ .name = "HPFAR", .state = ARM_CP_STATE_AA32,
|
||||
.cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4,
|
||||
.access = PL2_RW, .accessfn = access_el3_aa32ns,
|
||||
|
@ -6604,7 +6596,7 @@ static void define_pmu_regs(ARMCPU *cpu)
|
|||
* field as main ID register, and we implement four counters in
|
||||
* addition to the cycle count register.
|
||||
*/
|
||||
unsigned int i, pmcrn = PMCR_NUM_COUNTERS;
|
||||
unsigned int i, pmcrn = pmu_num_counters(&cpu->env);
|
||||
ARMCPRegInfo pmcr = {
|
||||
.name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0,
|
||||
.access = PL0_RW,
|
||||
|
@ -6619,10 +6611,10 @@ static void define_pmu_regs(ARMCPU *cpu)
|
|||
.access = PL0_RW, .accessfn = pmreg_access,
|
||||
.type = ARM_CP_IO,
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr),
|
||||
.resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT) |
|
||||
PMCRLC,
|
||||
.resetvalue = cpu->isar.reset_pmcr_el0,
|
||||
.writefn = pmcr_write, .raw_writefn = raw_write,
|
||||
};
|
||||
|
||||
define_one_arm_cp_reg(cpu, &pmcr);
|
||||
define_one_arm_cp_reg(cpu, &pmcr64);
|
||||
for (i = 0; i < pmcrn; i++) {
|
||||
|
@ -7979,6 +7971,17 @@ void register_cp_regs_for_features(ARMCPU *cpu)
|
|||
.type = ARM_CP_EL3_NO_EL2_C_NZ,
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) },
|
||||
};
|
||||
/*
|
||||
* The only field of MDCR_EL2 that has a defined architectural reset
|
||||
* value is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N.
|
||||
*/
|
||||
ARMCPRegInfo mdcr_el2 = {
|
||||
.name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
|
||||
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
|
||||
.access = PL2_RW, .resetvalue = pmu_num_counters(env),
|
||||
.fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2),
|
||||
};
|
||||
define_one_arm_cp_reg(cpu, &mdcr_el2);
|
||||
define_arm_cp_regs(cpu, vpidr_regs);
|
||||
define_arm_cp_regs(cpu, el2_cp_reginfo);
|
||||
if (arm_feature(env, ARM_FEATURE_V8)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue