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

[PATCH 1/3] tools/tests: fix domain creation on ARM



The tests test-mem-claim, test-paging-mempool and test-resource create
ARM domains with xen_arch_domainconfig set to zero, i.e., gic_version
XEN_DOMCTL_CONFIG_GIC_NATIVE, which has been removed. Domain creation in
test-mem-claim and test-paging-mempool fails, and test-resource
skips its ARM configuration.

So, pick the GIC version from the XEN_SYSCTL_PHYSCAP_ARM_GIC_V2/V3
capability bits reported by XEN_SYSCTL_physinfo instead, the same way
libxl does. Use GICv3 if available, else GICv2, else fail the test.

But, even with a valid GIC version, the tests don't properly run,
because ARM domains start with an empty P2M pool. The toolstack calls
libxl__domain_set_paging_mempool_size() in libxl__arch_domain_create()
to provision the page pool. But these tests don't go through the
toolstack and call domain_create() directly.

To fix this, call xc_set_paging_mempool_size() just like the toolstack
does.

Signed-off-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
---
 tools/tests/mem-claim/test-mem-claim.c        | 15 ++++++++
 .../paging-mempool/test-paging-mempool.c      | 34 ++++++++++++++++++-
 tools/tests/resource/test-resource.c          | 21 ++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/tools/tests/mem-claim/test-mem-claim.c 
b/tools/tests/mem-claim/test-mem-claim.c
index 69dc99cfdd..c21d791f0f 100644
--- a/tools/tests/mem-claim/test-mem-claim.c
+++ b/tools/tests/mem-claim/test-mem-claim.c
@@ -9,6 +9,7 @@
 #include <xenctrl.h>
 #include <xenforeignmemory.h>
 #include <xengnttab.h>
+#include <xen-tools/arm-arch-capabilities.h>
 #include <xen-tools/common-macros.h>
 
 static unsigned int nr_failures;
@@ -72,6 +73,13 @@ static void run_tests(void)
         create.flags &= ~XEN_DOMCTL_CDF_hvm;
         create.arch.emulation_flags = 0;
     }
+#elif defined(__arm__) || defined(__aarch64__)
+    if ( arch_capabilities_arm_gic_v3(physinfo.arch_capabilities) )
+        create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+    else if ( arch_capabilities_arm_gic_v2(physinfo.arch_capabilities) )
+        create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
+    else
+        return fail("  No supported GIC version\n");
 #endif
 
     rc = xc_domain_create(xch, &domid, &create);
@@ -84,6 +92,13 @@ static void run_tests(void)
         return fail("  Failed to set maxmem: %d - %s\n",
                     errno, strerror(errno));
 
+#if defined(__arm__) || defined(__aarch64__)
+    rc = xc_set_paging_mempool_size(xch, domid, MB(1));
+    if ( rc )
+        return fail("  Failed to set paging mempool size: %d - %s\n",
+                    errno, strerror(errno));
+#endif
+
     printf("  Created d%u\n", domid);
 
     /*
diff --git a/tools/tests/paging-mempool/test-paging-mempool.c 
b/tools/tests/paging-mempool/test-paging-mempool.c
index 0e03e2e4a0..020ebd5f8f 100644
--- a/tools/tests/paging-mempool/test-paging-mempool.c
+++ b/tools/tests/paging-mempool/test-paging-mempool.c
@@ -9,6 +9,7 @@
 #include <xendevicemodel.h>
 #include <xenforeignmemory.h>
 #include <xengnttab.h>
+#include <xen-tools/arm-arch-capabilities.h>
 #include <xen-tools/common-macros.h>
 
 static unsigned int nr_failures;
@@ -24,6 +25,8 @@ static xendevicemodel_handle *dh;
 static xenforeignmemory_handle *fh;
 static uint32_t domid = DOMID_ANY;
 
+static xc_physinfo_t physinfo;
+
 static struct xen_domctl_createdomain create = {
     .flags = (XEN_DOMCTL_CDF_hvm |
               XEN_DOMCTL_CDF_hap |
@@ -44,7 +47,7 @@ static uint64_t default_mempool_size_bytes =
 #if defined(__x86_64__) || defined(__i386__)
     256 << 12; /* Only x86 HAP for now.  x86 Shadow needs more work. */
 #elif defined (__arm__) || defined(__aarch64__)
-    16 << 12;
+    0;
 #endif
 
 static int test_paging_mempool_size(void)
@@ -80,6 +83,14 @@ static int test_paging_mempool_size(void)
      * Populate the domain with some RAM.  This will cause more of the mempool
      * to be used.
      */
+#if defined(__arm__) || defined(__aarch64__)
+    size_bytes = 16 << 12;
+    rc = xc_set_paging_mempool_size(xch, domid, size_bytes);
+    if ( rc )
+        return fail("  Fail: set mempool size: %d - %s\n",
+                    errno, strerror(errno));
+#endif
+
     old_size_bytes = size_bytes;
 
     rc = xc_domain_setmaxmem(xch, domid, -1);
@@ -274,6 +285,11 @@ static int test_p2m_relocate_memory(void)
            GFN_PAIR(GFN_4M - 32, 32), GFN_PAIR(GFN_4M, 32));
 
     rc = xendevicemodel_relocate_memory(dh, domid, 32, GFN_4M - 32, GFN_4M);
+    if ( rc && (errno == EOPNOTSUPP || errno == ENOSYS) )
+    {
+        printf("  Skip: %d - %s\n", errno, strerror(errno));
+        return 0;
+    }
     if ( rc )
         return fail("  Fail: relocate memory: %d - %s\n",
                     errno, strerror(errno));
@@ -370,6 +386,22 @@ int main(int argc, char **argv)
     if ( !fh )
         err(1, "xenforeignmemory_open");
 
+    rc = xc_physinfo(xch, &physinfo);
+    if ( rc )
+        err(1, "Failed to obtain physinfo");
+
+#if defined(__arm__) || defined(__aarch64__)
+    if ( arch_capabilities_arm_gic_v3(physinfo.arch_capabilities) )
+        create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+    else if ( arch_capabilities_arm_gic_v2(physinfo.arch_capabilities) )
+        create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
+    else
+    {
+        fail("  No supported GIC version\n");
+        goto out;
+    }
+#endif
+
     rc = xc_domain_create(xch, &domid, &create);
     if ( rc )
     {
diff --git a/tools/tests/resource/test-resource.c 
b/tools/tests/resource/test-resource.c
index 236da0dcd4..2392281f76 100644
--- a/tools/tests/resource/test-resource.c
+++ b/tools/tests/resource/test-resource.c
@@ -7,6 +7,7 @@
 #include <xenctrl.h>
 #include <xenforeignmemory.h>
 #include <xengnttab.h>
+#include <xen-tools/arm-arch-capabilities.h>
 #include <xen-tools/common-macros.h>
 
 static unsigned int nr_failures;
@@ -213,6 +214,16 @@ static void test_domain_configurations(void)
                 continue;
             }
         }
+#elif defined(__aarch64__) || defined(__arm__)
+        if ( arch_capabilities_arm_gic_v3(physinfo.arch_capabilities) )
+            t->create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+        else if ( arch_capabilities_arm_gic_v2(physinfo.arch_capabilities) )
+            t->create.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
+        else
+        {
+            fail("  No supported GIC version\n");
+            continue;
+        }
 #endif
 
         rc = xc_domain_create(xch, &domid, &t->create);
@@ -236,6 +247,16 @@ static void test_domain_configurations(void)
             goto test_done;
         }
 
+#if defined(__aarch64__) || defined(__arm__)
+        rc = xc_set_paging_mempool_size(xch, domid, MB(1));
+        if ( rc )
+        {
+            fail("  Failed to set paging mempool size: %d - %s\n",
+                 errno, strerror(errno));
+            goto test_done;
+        }
+#endif
+
         rc = xc_domain_populate_physmap_exact(
             xch, domid, ARRAY_SIZE(ram), 0, 0, ram);
         if ( rc )
-- 
2.53.0



--
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

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