All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Don't access PMCR_EL0 when no PMU is available
@ 2020-12-10  8:30 ` Marc Zyngier
  0 siblings, 0 replies; 32+ messages in thread
From: Marc Zyngier @ 2020-12-10  8:30 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm; +Cc: kernel-team

We reset the guest's view of PMCR_EL0 unconditionally, based on
the host's view of this register. It is however legal for an
imnplementation not to provide any PMU, resulting in an UNDEF.

The obvious fix is to skip the reset of this shadow register
when no PMU is available, sidestepping the issue entirely.
If no PMU is available, the guest is not able to request
a virtual PMU anyway, so not doing nothing is the right thing
to do!

It is unlikely that this bug can hit any HW implementation
though, as they all provide a PMU. It has been found using nested
virt with the host KVM not implementing the PMU itself.

Fixes: ab9468340d2bc ("arm64: KVM: Add access handler for PMCR register")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/sys_regs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index bc15246775d0..6c64d010102b 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -923,6 +923,10 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
 {
 	u64 pmcr, val;
 
+	/* No PMU available, PMCR_EL0 may UNDEF... */
+	if (!kvm_arm_support_pmu_v3())
+		return;
+
 	pmcr = read_sysreg(pmcr_el0);
 	/*
 	 * Writable bits of PMCR_EL0 (ARMV8_PMU_PMCR_MASK) are reset to UNKNOWN
-- 
2.29.2

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2021-01-04 19:34 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-10  8:30 [PATCH] KVM: arm64: Don't access PMCR_EL0 when no PMU is available Marc Zyngier
2020-12-10  8:30 ` Marc Zyngier
2020-12-10 10:12 ` Alexandru Elisei
2020-12-10 10:12   ` Alexandru Elisei
2020-12-10 11:16   ` Marc Zyngier
2020-12-10 11:16     ` Marc Zyngier
2020-12-10 12:22     ` Alexandru Elisei
2020-12-10 12:22       ` Alexandru Elisei
2021-01-04 15:47 ` Qian Cai
2021-01-04 15:47   ` Qian Cai
2021-01-04 15:47   ` Qian Cai
2021-01-04 16:08   ` Marc Zyngier
2021-01-04 16:08     ` Marc Zyngier
2021-01-04 16:08     ` Marc Zyngier
2021-01-04 16:22     ` Qian Cai
2021-01-04 16:22       ` Qian Cai
2021-01-04 16:22       ` Qian Cai
2021-01-04 16:27       ` Marc Zyngier
2021-01-04 16:27         ` Marc Zyngier
2021-01-04 16:27         ` Marc Zyngier
2021-01-04 18:20         ` Qian Cai
2021-01-04 18:20           ` Qian Cai
2021-01-04 18:20           ` Qian Cai
2021-01-04 18:26           ` Marc Zyngier
2021-01-04 18:26             ` Marc Zyngier
2021-01-04 18:26             ` Marc Zyngier
2021-01-04 18:42             ` Qian Cai
2021-01-04 18:42               ` Qian Cai
2021-01-04 18:42               ` Qian Cai
2021-01-04 19:32               ` Marc Zyngier
2021-01-04 19:32                 ` Marc Zyngier
2021-01-04 19:32                 ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.