kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
@ 2021-03-24 14:38 Marc Zyngier
  2021-03-24 14:50 ` Alexandru Elisei
  0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2021-03-24 14:38 UTC (permalink / raw)
  To: kvm, kvmarm
  Cc: Paolo Bonzini, Andrew Jones, Eric Auger, Alexandru Elisei,
	qperret, kernel-team, Andrew Walbran

The PMU unit tests fail with an UNDEF exception when no PMU
is available (although KVM hasn't been totally consistent
with that in the past).

This is caused by PMCR_EL0 being read *before* ID_AA64DFR0_EL1
is checked for the PMU version.

Move the PMCR_EL0 access to a reasonable place, which allows the
test to soft-fail gracefully.

Fixes: 784ee933fa5f ("arm: pmu: Introduce defines for PMU versions")
Reported-by: Andrew Walbran <qwandor@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arm/pmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arm/pmu.c b/arm/pmu.c
index cc959e6..15c542a 100644
--- a/arm/pmu.c
+++ b/arm/pmu.c
@@ -988,7 +988,7 @@ static void pmccntr64_test(void)
 /* Return FALSE if no PMU found, otherwise return TRUE */
 static bool pmu_probe(void)
 {
-	uint32_t pmcr = get_pmcr();
+	uint32_t pmcr;
 	uint8_t implementer;
 
 	pmu.version = get_pmu_version();
@@ -997,6 +997,7 @@ static bool pmu_probe(void)
 
 	report_info("PMU version: 0x%x", pmu.version);
 
+	pmcr = get_pmcr();
 	implementer = (pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK;
 	report_info("PMU implementer/ID code: %#"PRIx32"(\"%c\")/%#"PRIx32,
 		    (pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK,
-- 
2.30.0


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

* Re: [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
  2021-03-24 14:38 [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available Marc Zyngier
@ 2021-03-24 14:50 ` Alexandru Elisei
  2021-03-24 15:10   ` Andrew Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandru Elisei @ 2021-03-24 14:50 UTC (permalink / raw)
  To: Marc Zyngier, kvm, kvmarm
  Cc: Paolo Bonzini, Andrew Jones, Eric Auger, qperret, kernel-team,
	Andrew Walbran

Hi Marc,

Thank you for the patch! I have already sent a patch for this [1], which was
queued by Drew [2], but apparently has not landed in master yet.

[1] https://www.spinics.net/lists/kvm-arm/msg44084.html
[2]
https://gitlab.com/rhdrjones/kvm-unit-tests/-/commit/241dac4cadfd7d7ace8c8c3f0613376311b4e785


Thanks,

Alex

On 3/24/21 2:38 PM, Marc Zyngier wrote:
> The PMU unit tests fail with an UNDEF exception when no PMU
> is available (although KVM hasn't been totally consistent
> with that in the past).
>
> This is caused by PMCR_EL0 being read *before* ID_AA64DFR0_EL1
> is checked for the PMU version.
>
> Move the PMCR_EL0 access to a reasonable place, which allows the
> test to soft-fail gracefully.
>
> Fixes: 784ee933fa5f ("arm: pmu: Introduce defines for PMU versions")
> Reported-by: Andrew Walbran <qwandor@google.com>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  arm/pmu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arm/pmu.c b/arm/pmu.c
> index cc959e6..15c542a 100644
> --- a/arm/pmu.c
> +++ b/arm/pmu.c
> @@ -988,7 +988,7 @@ static void pmccntr64_test(void)
>  /* Return FALSE if no PMU found, otherwise return TRUE */
>  static bool pmu_probe(void)
>  {
> -	uint32_t pmcr = get_pmcr();
> +	uint32_t pmcr;
>  	uint8_t implementer;
>  
>  	pmu.version = get_pmu_version();
> @@ -997,6 +997,7 @@ static bool pmu_probe(void)
>  
>  	report_info("PMU version: 0x%x", pmu.version);
>  
> +	pmcr = get_pmcr();
>  	implementer = (pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK;
>  	report_info("PMU implementer/ID code: %#"PRIx32"(\"%c\")/%#"PRIx32,
>  		    (pmcr >> PMU_PMCR_IMP_SHIFT) & PMU_PMCR_IMP_MASK,

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

* Re: [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
  2021-03-24 14:50 ` Alexandru Elisei
@ 2021-03-24 15:10   ` Andrew Jones
  2021-03-24 16:17     ` Marc Zyngier
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Jones @ 2021-03-24 15:10 UTC (permalink / raw)
  To: Alexandru Elisei
  Cc: Marc Zyngier, kvm, kvmarm, Paolo Bonzini, Eric Auger, qperret,
	kernel-team, Andrew Walbran

On Wed, Mar 24, 2021 at 02:50:05PM +0000, Alexandru Elisei wrote:
> Hi Marc,
> 
> Thank you for the patch! I have already sent a patch for this [1], which was
> queued by Drew [2], but apparently has not landed in master yet.
> 
> [1] https://www.spinics.net/lists/kvm-arm/msg44084.html
> [2]
> https://gitlab.com/rhdrjones/kvm-unit-tests/-/commit/241dac4cadfd7d7ace8c8c3f0613376311b4e785

Thanks to you both for the patch and sorry for not getting Alexandru's
patch in early enough to avoid the double reporting and fixing. I
plan to send Paolo an MR as soon as tomorrow that includes the
patch and many others.

Thanks,
drew


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

* Re: [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
  2021-03-24 15:10   ` Andrew Jones
@ 2021-03-24 16:17     ` Marc Zyngier
  0 siblings, 0 replies; 4+ messages in thread
From: Marc Zyngier @ 2021-03-24 16:17 UTC (permalink / raw)
  To: Andrew Jones
  Cc: Alexandru Elisei, kvm, kvmarm, Paolo Bonzini, Eric Auger,
	qperret, kernel-team, Andrew Walbran

On Wed, 24 Mar 2021 15:10:58 +0000,
Andrew Jones <drjones@redhat.com> wrote:
> 
> On Wed, Mar 24, 2021 at 02:50:05PM +0000, Alexandru Elisei wrote:
> > Hi Marc,
> > 
> > Thank you for the patch! I have already sent a patch for this [1], which was
> > queued by Drew [2], but apparently has not landed in master yet.
> > 
> > [1] https://www.spinics.net/lists/kvm-arm/msg44084.html
> > [2]
> > https://gitlab.com/rhdrjones/kvm-unit-tests/-/commit/241dac4cadfd7d7ace8c8c3f0613376311b4e785
> 
> Thanks to you both for the patch and sorry for not getting Alexandru's
> patch in early enough to avoid the double reporting and fixing. I
> plan to send Paolo an MR as soon as tomorrow that includes the
> patch and many others.

No worries. Thanks both!

	M.

-- 
Without deviation from the norm, progress is not possible.

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

end of thread, other threads:[~2021-03-24 16:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 14:38 [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available Marc Zyngier
2021-03-24 14:50 ` Alexandru Elisei
2021-03-24 15:10   ` Andrew Jones
2021-03-24 16:17     ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).