Thread (14 messages) 14 messages, 5 authors, 2021-07-15

Re: [PATCH 1/3] KVM: arm64: Narrow PMU sysreg reset values to architectural requirements

From: "Russell King (Oracle)" <linux@armlinux.org.uk>
Date: 2021-07-13 16:17:03
Also in: kvmarm, linux-arm-kernel

On Tue, Jul 13, 2021 at 04:59:58PM +0100, Marc Zyngier wrote:
On Tue, 13 Jul 2021 15:39:49 +0100,
"Russell King (Oracle)" [off-list ref] wrote:
quoted
On Tue, Jul 13, 2021 at 02:58:58PM +0100, Marc Zyngier wrote:
quoted
+static void reset_pmu_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
+{
+	u64 n, mask;
+
+	/* No PMU available, any PMU reg may UNDEF... */
+	if (!kvm_arm_support_pmu_v3())
+		return;
+
+	n = read_sysreg(pmcr_el0) >> ARMV8_PMU_PMCR_N_SHIFT;
+	n &= ARMV8_PMU_PMCR_N_MASK;
+
+	reset_unknown(vcpu, r);
+
+	mask = BIT(ARMV8_PMU_CYCLE_IDX);
+	if (n)
+		mask |= GENMASK(n - 1, 0);
+
+	__vcpu_sys_reg(vcpu, r->reg) &= mask;
Would this read more logically to structure it as:

	mask = BIT(ARMV8_PMU_CYCLE_IDX);

	n = read_sysreg(pmcr_el0) >> ARMV8_PMU_PMCR_N_SHIFT;
	n &= ARMV8_PMU_PMCR_N_MASK;
	if (n)
		mask |= GENMASK(n - 1, 0);

	reset_unknown(vcpu, r);
	__vcpu_sys_reg(vcpu, r->reg) &= mask;

?
Yup, that's nicer. Amended locally.
Thanks Marc.

For the whole series:

Acked-by: Russell King (Oracle) <redacted>

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help