public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu
Subject: [PATCH kvm-unit-tests 2/2] arm/arm64: psci: support testing tcg
Date: Mon, 27 Feb 2017 18:32:08 +0100	[thread overview]
Message-ID: <20170227173208.14854-3-drjones@redhat.com> (raw)
In-Reply-To: <20170227173208.14854-1-drjones@redhat.com>

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arm/psci.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/arm/psci.c b/arm/psci.c
index e571afb92c7e..3c5f43877fde 100644
--- a/arm/psci.c
+++ b/arm/psci.c
@@ -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)
-- 
2.9.3

      parent reply	other threads:[~2017-02-27 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27 17:32 [PATCH kvm-unit-tests 0/2] arm/arm64: introduce PSCI tests Andrew Jones
2017-02-27 17:32 ` [PATCH kvm-unit-tests 1/2] arm/arm64: Add " Andrew Jones
2017-03-03 14:19   ` Radim Krčmář
2017-02-27 17:32 ` Andrew Jones [this message]

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=20170227173208.14854-3-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox