[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XTF-ARM] tests: Hypercall xen_version testing


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Thu, 15 Dec 2022 16:25:11 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3XlbtZruErX/F852tDI5lPA5tVHZaixEiTW1X4sFrHI=; b=F11ftwJz4KXRU/7WIop6LzZjdPpuDyje/R3JkyE3UnvQJxG4s5odtwCV5nnd8GlANgJL2ZERJ80Old0lAK/hIisFtFIgHzb5hVLtQkp9WmwJqDcACFw1Slvq82EvSM3VVjUGxoWFlCceTrV7VdUlKbw1lWXuqtaDCvj9mX3lGaAb/kSVwBsGvF5dY56cbyiKjtTQ2HpN1ige0JMrk6HUii77/LrWPPO/OiZ4IiSHCSz0crofdwuDL80UIYw6ZNgeu3foYF0L+5N0ZpEFxF3uFhR0tI6QH+f5fbkph2FR9Xs3HTr0H5A1nJzEcdTvSbZECXJrGBq4IWhkKGcdhloLUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LauGDEFj6Z4CYADUuQ5eozh3cVXb7gSKRvEtWMPfJ/rotAXD1N6SHjdIVWpROhRTo3I3VDfQjNwHRSX1WjdPBJ+aAsekiFL2MDawOxOo3yIb+c7RpdTk6O7mZMpwZuVRwbp/ZpMDcKLv9h7reeXfHS0ZxG7ieiFhSgXQa5NSyQsk5m0b2nLWaklq6PEMFXQ+JF4xr/TMDkaojb7n4d77/dYiEHZd7Y0QN0puo6JCbMVgnHQOo31UoIOiTV9x9P2kLaPJBoBOayRUeRa0KFZQb7pqScd1u1EytUrb7eF1btNM5gOdnxc56LJhUgHUHtswpgWj4BNHZ9iep5pqPb9x0Q==
  • Cc: <sstabellini@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Thu, 15 Dec 2022 15:25:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add a new test hyp-xen-version to perform functional testing of
xen_version hypercall. Check the following commands (more can be added
later on):
 - XENVER_version,
 - XENVER_extraversion,
 - XENVER_compile_info,
 - XENVER_changeset
 - XENVER_get_features,
 - passing invalid command.

For now, enable this test only for arm64.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
This is a patch for XTF fork https://gitlab.com/xen-project/fusa/xtf
(branch xtf-arm) under which XTF on Arm port is maintained.

Pushed to xen-devel together with patches to Xen CI automation, so that it is
clear what the test is doing.
---
 build/arm64/arch-tests.mk      |   2 +-
 docs/all-tests.dox             |   2 +
 tests/hyp-xen-version/Makefile |  10 ++++
 tests/hyp-xen-version/main.c   | 105 +++++++++++++++++++++++++++++++++
 4 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 tests/hyp-xen-version/Makefile
 create mode 100644 tests/hyp-xen-version/main.c

diff --git a/build/arm64/arch-tests.mk b/build/arm64/arch-tests.mk
index 1a13ba923625..c85e28bbea9e 100644
--- a/build/arm64/arch-tests.mk
+++ b/build/arm64/arch-tests.mk
@@ -1,4 +1,4 @@
 # Supported tests by arm64
 
-# Currently only example test is supported
 TESTS := $(ROOT)/tests/example
+TESTS += $(ROOT)/tests/hyp-xen-version
diff --git a/docs/all-tests.dox b/docs/all-tests.dox
index 322f078db09e..48a407593463 100644
--- a/docs/all-tests.dox
+++ b/docs/all-tests.dox
@@ -20,6 +20,8 @@ and functionality.
 
 @subpage test-fpu-exception-emulation - FPU Exception Emulation.  Covers 
XSA-190.
 
+@subpage test-hyp-xen-version - Hypercall xen_version testing.
+
 @subpage test-invlpg - `invlpg` instruction behaviour.
 
 @subpage test-lbr-tsx-vmentry - Haswell and later LBR/TSX Vmentry failure test.
diff --git a/tests/hyp-xen-version/Makefile b/tests/hyp-xen-version/Makefile
new file mode 100644
index 000000000000..2d7db8fa6ad9
--- /dev/null
+++ b/tests/hyp-xen-version/Makefile
@@ -0,0 +1,10 @@
+include $(ROOT)/build/common.mk
+
+NAME      := hyp-xen-version
+CATEGORY  := functional
+TEST-ARCH := arm64
+TEST-ENVS := $(ALL_ENVIRONMENTS)
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
diff --git a/tests/hyp-xen-version/main.c b/tests/hyp-xen-version/main.c
new file mode 100644
index 000000000000..bda591ca5c29
--- /dev/null
+++ b/tests/hyp-xen-version/main.c
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);
+
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);
+
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);
+
+        printk(" changeset: %s\n", xen_cs);
+    }
+
+    printk("Checking XENVER_get_features:\n");
+    {
+        for ( unsigned int i = 0; i < XENFEAT_NR_SUBMAPS; i++ )
+        {
+            xen_feature_info_t xen_fi = { .submap_idx = i };
+
+            ret = hypercall_xen_version(XENVER_get_features, &xen_fi);
+            if ( ret < 0 )
+                return xtf_error("Error %d for submap[%u]\n", ret, i);
+
+            printk(" submap[%u]: %#x\n", i, xen_fi.submap);
+        }
+    }
+
+    printk("Checking invalid command:\n");
+    {
+        /* Invalid cmd should result in returning -ENOSYS. */
+        ret = hypercall_xen_version(INVALID_CMD, NULL);
+        if ( ret != -ENOSYS )
+            return xtf_error("Error %d\n", ret);
+
+        printk(" ok\n");
+    }
+
+    xtf_success(NULL);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.25.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.