[+kvmarm, Marc] On 2021/3/12 0:59, Peter Maydell wrote:
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 for Cortex-A53, A57, A72, A15 and A9 as well as '-cpu max'; Cortex-A7 and A8 stay at 4; and Cortex-R5 goes down to 3. 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. Signed-off-by: Peter Maydell <peter.maydell@xxxxxxxxxx> --- This is pretty much untested (I just checked Linux still boots; haven't tried it with KVM either). It's an alternative to just bumping PMCR_NUM_COUNTERS to 6.
So I've tested it with kvm and I get the following error before VM startup: "qemu-system-aarch64: Failed to retrieve host CPU features"
--- target/arm/cpu.h | 1 + target/arm/cpu64.c | 3 +++ target/arm/cpu_tcg.c | 5 +++++ target/arm/helper.c | 29 +++++++++++++++++------------ target/arm/kvm64.c | 2 ++ 5 files changed, 28 insertions(+), 12 deletions(-)
[...]
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index dff85f6db94..581335e49d3 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -566,6 +566,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 7, 1)); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, ARM64_SYS_REG(3, 0, 0, 7, 2)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, + ARM64_SYS_REG(3, 3, 9, 12, 0));
Looks like we tried to access PMCR_EL0 *before* telling kvm that KVM_ARM_VCPU_PMU_V3 feature should be supported, which is now refused by kvm [*]. [*] https://git.kernel.org/torvalds/c/11663111cd49 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm