Patchwork [6/5] arm/arm64: selftest.vectors-user: clean up PSCI exit

login
register
mail settings
Submitter Andrew Jones
Date Feb. 5, 2019, 2:29 p.m.
Message ID <20190205142901.13019-1-drjones@redhat.com>
Download mbox | patch
Permalink /patch/718367/
State New
Headers show

Comments

Andrew Jones - Feb. 5, 2019, 2:29 p.m.
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Tested-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---

The original posting didn't consider arm32. I kept Alexandru's tags
for this new version though, as the tweaks should be safe. Also
added __builtin_unreachable as suggested by Alexandru.

 arm/selftest.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Patch

diff --git a/arm/selftest.c b/arm/selftest.c
index ea5101ef7217..28a17f7a7531 100644
--- a/arm/selftest.c
+++ b/arm/selftest.c
@@ -17,6 +17,13 @@ 
 #include <asm/smp.h>
 #include <asm/barrier.h>
 
+static void __user_psci_system_off(void)
+{
+	psci_system_off();
+	halt();
+	__builtin_unreachable();
+}
+
 static void check_setup(int argc, char **argv)
 {
 	int nr_tests = 0, len, i;
@@ -154,6 +161,11 @@  static bool check_svc(void)
 
 	return svc_works;
 }
+
+static void user_psci_system_off(struct pt_regs *regs)
+{
+	__user_psci_system_off();
+}
 #elif defined(__aarch64__)
 
 /*
@@ -270,12 +282,25 @@  static bool check_svc(void)
 
 	return svc_works;
 }
+
+static void user_psci_system_off(struct pt_regs *regs, unsigned int esr)
+{
+	__user_psci_system_off();
+}
 #endif
 
 static void check_vectors(void *arg __unused)
 {
 	report("und", check_und());
 	report("svc", check_svc());
+	if (is_user()) {
+#ifdef __arm__
+		install_exception_handler(EXCPTN_UND, user_psci_system_off);
+#else
+		install_exception_handler(EL0_SYNC_64, ESR_EL1_EC_UNKNOWN,
+					  user_psci_system_off);
+#endif
+	}
 	exit(report_summary());
 }