From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com
Subject: [PATCH kvm-unit-tests 8/8] arm/psci: add smccc 1.1 tests
Date: Wed, 7 Feb 2018 20:03:34 +0100 [thread overview]
Message-ID: <20180207190334.16516-9-drjones@redhat.com> (raw)
In-Reply-To: <20180207190334.16516-1-drjones@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/psci.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 67 insertions(+), 2 deletions(-)
diff --git a/arm/psci.c b/arm/psci.c
index a092f00c2cab..af96a82cedd0 100644
--- a/arm/psci.c
+++ b/arm/psci.c
@@ -14,9 +14,14 @@
#include <asm/psci.h>
#include <asm/delay.h>
-static cpumask_t halted;
+#define ARM_SMCCC_VERSION_FUNC_ID ((1U << 31) | 0x0000)
+#define ARM_SMCCC_ARCH_FEATURES_FUNC_ID ((1U << 31) | 0x0001)
+#define ARM_SMCCC_ARCH_WORKAROUND_1 ((1U << 31) | 0x8000)
+static int psci_version;
+static cpumask_t halted;
static bool invalid_function_exception;
+static bool have_workaround1;
#ifdef __arm__
static void invalid_function_handler(struct pt_regs *regs __unused)
@@ -115,12 +120,60 @@ static bool psci_cpu_on_test(void)
return !failed;
}
+static void workaround1_test(void)
+{
+#ifdef __aarch64__
+ unsigned long ret;
+
+ if (!have_workaround1)
+ return;
+
+ asm volatile(
+ " mov w0, " xstr(ARM_SMCCC_ARCH_WORKAROUND_1) "\n"
+ " hvc #0\n"
+ " mov %0, x0\n"
+ : "=r" (ret) : : "x0");
+
+ report("workaround1_test", ret == 0);
+#endif
+}
+
+static void smccc11_test(void)
+{
+ int ret;
+
+ ret = psci_invoke(PSCI_1_0_FN_PSCI_FEATURES, PSCI_1_0_FN_PSCI_FEATURES, 0, 0);
+ if (ret != 0) {
+ ret = 0;
+ goto report_version;
+ }
+
+ ret = psci_invoke(PSCI_1_0_FN_PSCI_FEATURES, ARM_SMCCC_VERSION_FUNC_ID, 0, 0);
+ if (ret != 0) {
+ ret = 0;
+ goto report_version;
+ }
+
+ ret = psci_invoke(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0);
+ report_info("SMCCC version %d.%d", PSCI_VERSION_MAJOR(ret), PSCI_VERSION_MINOR(ret));
+ ret = PSCI_VERSION_MAJOR(ret) >= 1 && PSCI_VERSION_MINOR(ret) >= 1;
+
+report_version:
+ report("smccc: version >= 1.1", ret);
+ have_workaround1 = ret && psci_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID, ARM_SMCCC_ARCH_WORKAROUND_1, 0, 0);
+}
+
static void general_check(void)
{
report("invalid-function", psci_invalid_function());
report("affinity-info-on", psci_affinity_info(0) == PSCI_0_2_AFFINITY_LEVEL_ON);
report("affinity-info-off", psci_affinity_info(1) == PSCI_0_2_AFFINITY_LEVEL_OFF);
+ if (PSCI_VERSION_MAJOR(psci_version) >= 1)
+ smccc11_test();
+
+ workaround1_test();
+
if (ERRATA(6c7a5dce22b3))
report("cpu-on", psci_cpu_on_test());
else
@@ -159,6 +212,11 @@ static void migrate_prepare(void)
cpu_relax();
assert(psci_affinity_info(2) == PSCI_0_2_AFFINITY_LEVEL_ON);
+ if (PSCI_VERSION_MAJOR(psci_version) >= 1)
+ smccc11_test();
+
+ workaround1_test();
+
mdelay(500);
do_migration();
mdelay(500);
@@ -170,6 +228,13 @@ static void migrate_check(void)
report("CPU1 stopped", psci_affinity_info(1) == PSCI_0_2_AFFINITY_LEVEL_OFF);
report("CPU2 not stopped", psci_affinity_info(2) == PSCI_0_2_AFFINITY_LEVEL_ON);
report("CPU2 still halted", cpumask_test_cpu(2, &halted));
+
+ int version = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
+ report_info("PSCI version %d.%d", PSCI_VERSION_MAJOR(version),
+ PSCI_VERSION_MINOR(version));
+ if (PSCI_VERSION_MAJOR(psci_version) >= 1 || PSCI_VERSION_MAJOR(version) >= 1)
+ smccc11_test();
+ workaround1_test();
}
static struct test {
@@ -204,9 +269,9 @@ static struct test *get_test(const char *name)
int main(int ac, char **av)
{
- int psci_version = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
struct test *test = get_test("general");
+ psci_version = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
report_info("PSCI version %d.%d", PSCI_VERSION_MAJOR(psci_version),
PSCI_VERSION_MINOR(psci_version));
--
2.13.6
next prev parent reply other threads:[~2018-02-07 19:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 19:03 [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 1/8] virtio-mmio: fix queue allocation Andrew Jones
2018-02-07 19:32 ` Andrew Jones
2018-02-07 19:34 ` [PATCH kvm-unit-tests v2 " Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 2/8] scripts/arch-run: run_migration improvements Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 3/8] powerpc: don't use NMI's to signal end of migration Andrew Jones
2018-02-08 10:58 ` Thomas Huth
2018-02-07 19:03 ` [PATCH kvm-unit-tests 4/8] powerpc: Introduce getchar Andrew Jones
2018-02-08 11:06 ` Thomas Huth
2018-02-08 12:59 ` Andrew Jones
2018-02-14 11:43 ` Paolo Bonzini
2018-02-14 12:38 ` Andrew Jones
2018-02-14 13:25 ` Paolo Bonzini
2018-02-14 14:38 ` Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 5/8] lib: Introduce do_migration Andrew Jones
2018-02-14 11:45 ` Paolo Bonzini
2018-02-14 12:44 ` Andrew Jones
2018-02-14 13:24 ` Paolo Bonzini
2018-02-07 19:03 ` [PATCH kvm-unit-tests 6/8] arm/arm64: Add support for migration tests Andrew Jones
2018-02-07 19:03 ` [PATCH kvm-unit-tests 7/8] arm/arm64: psci: add migration test Andrew Jones
2018-02-07 19:03 ` Andrew Jones [this message]
2018-02-14 11:46 ` [PATCH kvm-unit-tests 0/8] arm/arm64: extend psci tests Paolo Bonzini
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=20180207190334.16516-9-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).