From: Marc Zyngier <maz@kernel.org>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Andrew Walbran <qwandor@google.com>,
kernel-team@android.com, Paolo Bonzini <pbonzini@redhat.com>
Subject: [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
Date: Wed, 24 Mar 2021 14:38:56 +0000 [thread overview]
Message-ID: <20210324143856.2079220-1-maz@kernel.org> (raw)
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
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Andrew Jones <drjones@redhat.com>,
Eric Auger <eric.auger@redhat.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
qperret@google.com, kernel-team@android.com,
Andrew Walbran <qwandor@google.com>
Subject: [kvm-unit-tests PATCH] arm: pmu: Fix failing PMU test when no PMU is available
Date: Wed, 24 Mar 2021 14:38:56 +0000 [thread overview]
Message-ID: <20210324143856.2079220-1-maz@kernel.org> (raw)
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
next reply other threads:[~2021-03-24 14:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-24 14:38 Marc Zyngier [this message]
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 14:50 ` Alexandru Elisei
2021-03-24 15:10 ` Andrew Jones
2021-03-24 15:10 ` Andrew Jones
2021-03-24 16:17 ` Marc Zyngier
2021-03-24 16:17 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210324143856.2079220-1-maz@kernel.org \
--to=maz@kernel.org \
--cc=kernel-team@android.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=pbonzini@redhat.com \
--cc=qwandor@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.