All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, pbonzini@redhat.com, lvivier@redhat.com,
	thuth@redhat.com
Subject: [PATCH kvm-unit-tests v3 8/9] AArch32: apply errata framework to unsafe pmccntr64 test
Date: Tue, 13 Jun 2017 13:54:50 +0200	[thread overview]
Message-ID: <20170613115451.6240-9-drjones@redhat.com> (raw)
In-Reply-To: <20170613115451.6240-1-drjones@redhat.com>

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arm/pmu.c  | 26 ++++++++++++++++++--------
 errata.txt |  1 +
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/arm/pmu.c b/arm/pmu.c
index 74848988a678..1ac692023e5e 100644
--- a/arm/pmu.c
+++ b/arm/pmu.c
@@ -14,6 +14,7 @@
  * for more details.
  */
 #include "libcflat.h"
+#include "errata.h"
 #include "asm/barrier.h"
 #include "asm/sysreg.h"
 #include "asm/processor.h"
@@ -57,18 +58,12 @@ static inline uint8_t get_pmu_version(void)
 
 static inline uint64_t get_pmccntr(void)
 {
-	if (pmu_version == 0x3)
-		return read_sysreg(PMCCNTR64);
-	else
-		return read_sysreg(PMCCNTR32);
+	return read_sysreg(PMCCNTR32);
 }
 
 static inline void set_pmccntr(uint64_t value)
 {
-	if (pmu_version == 0x3)
-		write_sysreg(value, PMCCNTR64);
-	else
-		write_sysreg(value & 0xffffffff, PMCCNTR32);
+	write_sysreg(value & 0xffffffff, PMCCNTR32);
 }
 
 /* PMCCFILTR is an obsolete name for PMXEVTYPER31 in ARMv7 */
@@ -267,6 +262,19 @@ static bool check_cpi(int cpi)
 	return true;
 }
 
+static void pmccntr64_test(void)
+{
+#ifdef __arm__
+	if (pmu_version == 0x3) {
+		if (ERRATA(9e3f7a296940)) {
+			write_sysreg(0xdead, PMCCNTR64);
+			report("pmccntr64", read_sysreg(PMCCNTR64) == 0xdead);
+		} else
+			report_skip("Skipping unsafe pmccntr64 test. Set ERRATA_9e3f7a296940=y to enable.");
+	}
+#endif
+}
+
 /* Return FALSE if no PMU found, otherwise return TRUE */
 bool pmu_probe(void)
 {
@@ -293,5 +301,7 @@ int main(int argc, char *argv[])
 	report("Monotonically increasing cycle count", check_cycles_increase());
 	report("Cycle/instruction ratio", check_cpi(cpi));
 
+	pmccntr64_test();
+
 	return report_summary();
 }
diff --git a/errata.txt b/errata.txt
index 95b66c837c63..682d7aa067b9 100644
--- a/errata.txt
+++ b/errata.txt
@@ -2,4 +2,5 @@
 # commit	: minimum kernel	: summary
 # 12 hex digits	: version		:
 #---------------:-----------------------:--------------------------------------
+9e3f7a296940	: 4.9			: arm64: KVM: pmu: Fix AArch32 cycle counter access
 #---------------:-----------------------:--------------------------------------
-- 
2.9.4

  parent reply	other threads:[~2017-06-13 11:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13 11:54 [PATCH kvm-unit-tests v3 0/9] Extend and apply the errata framework Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 1/9] arch-run: introduce initrd_create Andrew Jones
2017-06-13 12:09   ` Laurent Vivier
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 2/9] arch-run: provide errata from run env Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 3/9] x86/run: source config.mak Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 4/9] arch-run: generate errata when no environ is provided Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 5/9] mkstandalone: provide errata to tests Andrew Jones
2017-06-13 12:15   ` Laurent Vivier
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 6/9] errata: add ERRATA_FORCE Andrew Jones
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 7/9] README: add section on guarding unsafe tests Andrew Jones
2017-06-13 12:15   ` Laurent Vivier
2017-06-13 11:54 ` Andrew Jones [this message]
2017-06-13 11:54 ` [PATCH kvm-unit-tests v3 9/9] arm/arm64: apply errata framework to unsafe cpu-on test Andrew Jones
2017-06-14 18:58 ` [PATCH kvm-unit-tests v3 0/9] Extend and apply the errata framework Radim Krčmář

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=20170613115451.6240-9-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@redhat.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.