Skip to contentSkip to conversation

arm/arm64: introduce PSCI tests

PATCH Applied Andrew Jones 2 participants 4 messages Mar 3, 2017

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/2 arm/arm64: Add PSCI tests

In reply to Andrew Jones

From: Levente Kurusa <[email protected]>

The cpu_on test exposed two races in KVM's PSCI emulation.

[Rewrote the cpu_on test to improve the chance of hitting the race.
Also added affinity-info tests and made some minor cleanups. -drew]

---
 arm/Makefile.common |   1 +
 arm/psci.c          | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg   |   6 +++
 3 files changed, 125 insertions(+)
 create mode 100644 arm/psci.c
arm/Makefile.common +1 -0
index f7193c3e6d64..74c7394eb7c1 100644
@@ -14,6 +14,7 @@ tests-common += $(TEST_DIR)/spinlock-test.flat
 tests-common += $(TEST_DIR)/pci-test.flat
 tests-common += $(TEST_DIR)/pmu.flat
 tests-common += $(TEST_DIR)/gic.flat
+tests-common += $(TEST_DIR)/psci.flat
 
 tests-all = $(tests-common) $(tests)
 all: $(tests-all)
arm/psci.c new file +118 -0

118 lines not on this page · raw message

arm/unittests.cfg +6 -0
index 8cf94729d86e..c98658f7488b 100644
@@ -91,3 +91,9 @@ file = gic.flat
 smp = $MAX_SMP
 extra_params = -machine gic-version=3 -append 'ipi'
 groups = gic
+
+# Test PSCI emulation
+[psci]
+file = psci.flat
+smp = $MAX_SMP
+groups = nodefault,psci
Signature · 1 line
2.9.3
#2 lore raw

PATCH v2 2/2 arm/arm64: psci: support testing tcg

In reply to Andrew Jones
---
 arm/psci.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
arm/psci.c +33 -1
index 86f621b4ddba..f1004339b30f 100644
@@ -8,12 +8,44 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.
  */
 #include <libcflat.h>
+#include <asm/processor.h>
 #include <asm/smp.h>
 #include <asm/psci.h>
 
+static bool invalid_function_exception;
+
+#ifdef __arm__
+static void invalid_function_handler(struct pt_regs *regs __unused)
+{
+	invalid_function_exception = true;
+}
+#else
+static void invalid_function_handler(struct pt_regs *regs, unsigned int esr __unused)
+{
+	invalid_function_exception = true;
+	regs->pc += 4;
+}
+#endif
+
+static void install_invalid_function_handler(exception_fn handler)
+{
+#ifdef __arm__
+	install_exception_handler(EXCPTN_UND, handler);
+#else
+	install_exception_handler(EL1H_SYNC, ESR_EL1_EC_UNKNOWN, handler);
+#endif
+}
+
 static bool psci_invalid_function(void)
 {
-	return psci_invoke(1337, 0, 0, 0) == PSCI_RET_NOT_SUPPORTED;
+	bool pass;
+
+	install_invalid_function_handler(invalid_function_handler);
+
+	pass = psci_invoke(1337, 0, 0, 0) == PSCI_RET_NOT_SUPPORTED || invalid_function_exception;
+
+	install_invalid_function_handler(NULL);
+	return pass;
 }
 
 static int psci_affinity_info(unsigned long target_affinity, uint32_t lowest_affinity_level)
Signature · 1 line
2.9.3
#0 lore raw

v2 cover arm/arm64: introduce PSCI tests

Andrew Jones (1):
arm/arm64: psci: support testing tcg

Levente Kurusa (1):
arm/arm64: Add PSCI tests

 arm/Makefile.common |   1 +
 arm/psci.c          | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg   |   6 +++
 3 files changed, 157 insertions(+)
 create mode 100644 arm/psci.c
Signature · 1 line
2.9.3
#3 lore raw

Applied, thanks.

2017-03-03 15:30+0100, Andrew Jones:

Quoted 15 lines

Andrew Jones (1):
arm/arm64: psci: support testing tcg

Levente Kurusa (1):
arm/arm64: Add PSCI tests

 arm/Makefile.common |   1 +
 arm/psci.c          | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 arm/unittests.cfg   |   6 +++
 3 files changed, 157 insertions(+)
 create mode 100644 arm/psci.c
Signature · 1 line
2.9.3