KVM: arm64: PMU: Fix PMCR_EL0 reset value
cover KVM: arm64: PMU: Fix PMCR_EL0 reset value
Hi,
We noticed qemu failing to run because of an assert on our CI. I don't see the issue anymore with this fix.
Applies to kvmarm/next (753d734f3f34)
Thanks
James Clark (1):
KVM: arm64: PMU: Fix PMCR_EL0 reset value
arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.25.1
PATCH 1/1 KVM: arm64: PMU: Fix PMCR_EL0 reset value
ARMV8_PMU_PMCR_N_MASK is an unshifted value which results in the wrong reset value for PMCR_EL0, so shift it to fix it.
This fixes the following error when running qemu:
$ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ...
target/arm/helper.c:1813: pmevcntr_rawwrite: Assertion `counter < pmu_num_counters(env)' failed.
--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +1 -1
@@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)return ;/* Only preserve PMCR_EL0.N, and reset the rest to 0 */ - pmcr =read_sysreg (pmcr_el0) &ARMV8_PMU_PMCR_N_MASK ; + pmcr =read_sysreg (pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK <<ARMV8_PMU_PMCR_N_SHIFT );if (!kvm_supports_32bit_el0 ()) pmcr |=ARMV8_PMU_PMCR_LC ;
Signature · 1 line
2.25.1
Quoted 2 lines · James Clark
ARMV8_PMU_PMCR_N_MASKis an unshifted value which results in the wrong reset value forPMCR_EL0, so shift it to fix it.
That's just mean. *_MASK tends to be a shifted mask, although it would appear that asm/perf_event.h does not follow this convention. Fixing that would be nice (as I'm sure somebody else will get burned by this), but for the sake of an immediate fix:
Quoted 8 lines
This fixes the following error when running qemu:
$ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ...
target/arm/helper.c:1813:pmevcntr_rawwrite: Assertion `counter <pmu_num_counters(env)' failed.Fixes 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling")Signed-off-by James Clark <[email protected]>
--
Thanks,
Oliver
Quoted 20 lines
--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kvm/sys_regs.c +1
-1@@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)return ;/* Only preserve PMCR_EL0.N, and reset the rest to 0 */ - pmcr =read_sysreg (pmcr_el0) &ARMV8_PMU_PMCR_N_MASK ; + pmcr =read_sysreg (pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK <<ARMV8_PMU_PMCR_N_SHIFT );if (!kvm_supports_32bit_el0 ()) pmcr |=ARMV8_PMU_PMCR_LC ;Signature · 1 line
2.25.1
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Marc Zyngier
maintainerQuoted 9 lines · Oliver Upton
Quoted 2 lines · James Clark
ARMV8_PMU_PMCR_N_MASKis an unshifted value which results in the wrong reset value forPMCR_EL0, so shift it to fix it.That's just mean.
*_MASKtends to be a shifted mask, although it would appear thatasm/perf_event.hdoes not follow this convention. Fixing that would be nice (as I'm sure somebody else will get burned by this), but for the sake of an immediate fix:
Well, that'll teach me the usual lesson: last minute changes without full non-regression testing are bound to end in disaster.
Quoted 11 lines
Quoted 9 lines
This fixes the following error when running qemu:
$ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ...
target/arm/helper.c:1813:pmevcntr_rawwrite: Assertion `counter <pmu_num_counters(env)' failed.Fixes 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling")Signed-off-by James Clark <[email protected]>Reviewed-by Oliver Upton <[email protected]>
Thanks both. I'll queue that ASAP as a fix.
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 8 lines · Oliver Upton
Quoted 2 lines · James Clark
ARMV8_PMU_PMCR_N_MASKis an unshifted value which results in the wrong reset value forPMCR_EL0, so shift it to fix it.That's just mean.
*_MASKtends to be a shifted mask, although it would appear thatasm/perf_event.hdoes not follow this convention. Fixing that would be nice (as I'm sure somebody else will get burned by this), but for the sake of an immediate fix:
New arch/arm64/tools/sysreg generates shifted i.e in place masks for register fields. Once all these PMU registers move into arch/arm64/tools/sysreg, this problem will be solved.
Quoted 41 lines
Quoted 9 lines
This fixes the following error when running qemu:
$ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ...
target/arm/helper.c:1813:pmevcntr_rawwrite: Assertion `counter <pmu_num_counters(env)' failed.Fixes 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling")Signed-off-by James Clark <[email protected]>Reviewed-by Oliver Upton <[email protected]>--
Thanks,
OliverQuoted 20 lines
--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kvm/sys_regs.c +1
-1@@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)return ;/* Only preserve PMCR_EL0.N, and reset the rest to 0 */ - pmcr =read_sysreg (pmcr_el0) &ARMV8_PMU_PMCR_N_MASK ; + pmcr =read_sysreg (pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK <<ARMV8_PMU_PMCR_N_SHIFT );if (!kvm_supports_32bit_el0 ()) pmcr |=ARMV8_PMU_PMCR_LC ;Signature · 1 line
2.25.1_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 9 lines · Oliver Upton
Quoted 2 lines · James Clark
ARMV8_PMU_PMCR_N_MASKis an unshifted value which results in the wrong reset value forPMCR_EL0, so shift it to fix it.That's just mean.
*_MASKtends to be a shifted mask, although it would appear thatasm/perf_event.hdoes not follow this convention. Fixing that would be nice (as I'm sure somebody else will get burned by this), but for the sake of an immediate fix:
Even kvm-unit-tests does this:
arm/pmu.c:
#define PMU_PMCR_N_SHIFT 11
#define PMU_PMCR_N_MASK 0x1f
Quoted 39 lines
Quoted 8 lines
This fixes the following error when running qemu:
$ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ...
target/arm/helper.c:1813:pmevcntr_rawwrite: Assertion `counter <pmu_num_counters(env)' failed.Fixes 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling")Signed-off-by James Clark <[email protected]>Reviewed-by Oliver Upton <[email protected]>--
Thanks,
OliverQuoted 20 lines
--- arch/arm64/kvm/sys_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/kvm/sys_regs.c +1
-1@@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)return ;/* Only preserve PMCR_EL0.N, and reset the rest to 0 */ - pmcr =read_sysreg (pmcr_el0) &ARMV8_PMU_PMCR_N_MASK ; + pmcr =read_sysreg (pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK <<ARMV8_PMU_PMCR_N_SHIFT );if (!kvm_supports_32bit_el0 ()) pmcr |=ARMV8_PMU_PMCR_LC ;Signature · 1 line
2.25.1_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 8 lines · James Clark
We noticed qemu failing to run because of an assert on our CI. I don't see the issue anymore with this fix.
Applies to kvmarm/next (
753d734f3f34)Thanks
[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value
commit: aff234839f8b80ac101e6c2f14d0e44b236efa48
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
Quoted 8 lines · James Clark
We noticed qemu failing to run because of an assert on our CI. I don't see the issue anymore with this fix.
Applies to kvmarm/next (
753d734f3f34)Thanks
[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value
commit: edb4929ea9ba48cd91e3867041f49e4c34d729ed
Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.