tools/dombuilder: Remove PV-only, mandatory hooks
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 17 Dec 2019 17:08:22 +0000 (17:08 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 7 Jan 2020 12:46:03 +0000 (12:46 +0000)
Currently, the setup_pgtable() hook is optional, but alloc_pgtable() hook is
not.  Both are specific to x86 PV guests, and stubbed in various ways by the
dombuilders for translated guests (x86 HVM, ARM).

Make alloc_pgtables() optional, and drop all the stubs for translated guest
types.

No change in the constructed guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wl@xen.org>
Acked-by: Julien Grall <julien@xen.org>
tools/libxc/include/xc_dom.h
tools/libxc/xc_dom_arm.c
tools/libxc/xc_dom_boot.c
tools/libxc/xc_dom_core.c
tools/libxc/xc_dom_x86.c

index 5900bbe8fae03aa8998f00bd86af254e6dfc5f90..9ff1cb8b078673b6bcb634ec33d83f2b14ec9274 100644 (file)
@@ -253,8 +253,9 @@ void xc_dom_register_loader(struct xc_dom_loader *loader);
 /* --- arch specific hooks ----------------------------------------- */
 
 struct xc_dom_arch {
-    /* pagetable setup */
     int (*alloc_magic_pages) (struct xc_dom_image * dom);
+
+    /* pagetable setup - x86 PV only */
     int (*alloc_pgtables) (struct xc_dom_image * dom);
     int (*alloc_p2m_list) (struct xc_dom_image * dom);
     int (*setup_pgtables) (struct xc_dom_image * dom);
index 5b9eca6087ca28afa860699e19b2fbafa75f08fa..7e0fb9169f9d4adc50f261470adbe6f1e0c8e98f 100644 (file)
@@ -46,23 +46,6 @@ const char *xc_domain_get_native_protocol(xc_interface *xch,
     return XEN_IO_PROTO_ABI_ARM;
 }
 
-/* ------------------------------------------------------------------------ */
-/*
- * arm guests are hybrid and start off with paging disabled, therefore no
- * pagetables and nothing to do here.
- */
-static int alloc_pgtables_arm(struct xc_dom_image *dom)
-{
-    DOMPRINTF_CALLED(dom->xch);
-    return 0;
-}
-
-static int setup_pgtables_arm(struct xc_dom_image *dom)
-{
-    DOMPRINTF_CALLED(dom->xch);
-    return 0;
-}
-
 /* ------------------------------------------------------------------------ */
 
 static int alloc_magic_pages(struct xc_dom_image *dom)
@@ -539,8 +522,6 @@ static struct xc_dom_arch xc_dom_32 = {
     .page_shift = PAGE_SHIFT_ARM,
     .sizeof_pfn = 8,
     .alloc_magic_pages = alloc_magic_pages,
-    .alloc_pgtables = alloc_pgtables_arm,
-    .setup_pgtables = setup_pgtables_arm,
     .start_info = start_info_arm,
     .shared_info = shared_info_arm,
     .vcpu = vcpu_arm32,
@@ -555,8 +536,6 @@ static struct xc_dom_arch xc_dom_64 = {
     .page_shift = PAGE_SHIFT_ARM,
     .sizeof_pfn = 8,
     .alloc_magic_pages = alloc_magic_pages,
-    .alloc_pgtables = alloc_pgtables_arm,
-    .setup_pgtables = setup_pgtables_arm,
     .start_info = start_info_arm,
     .shared_info = shared_info_arm,
     .vcpu = vcpu_arm64,
index 918ee4d045731537711f4f8e02a22475f295234b..79dbbf657109bef2bb4686c7f124975fc1df0e17 100644 (file)
@@ -199,9 +199,9 @@ int xc_dom_boot_image(struct xc_dom_image *dom)
     /* initial mm setup */
     if ( (rc = xc_dom_update_guest_p2m(dom)) != 0 )
         return rc;
-    if ( dom->arch_hooks->setup_pgtables )
-        if ( (rc = dom->arch_hooks->setup_pgtables(dom)) != 0 )
-            return rc;
+    if ( dom->arch_hooks->setup_pgtables &&
+         (rc = dom->arch_hooks->setup_pgtables(dom)) != 0 )
+        return rc;
 
     /* start info page */
     if ( dom->arch_hooks->start_info )
index 73fe09fe1864df1735970142f285301b84bc4d7a..fd3264572e8edde8c5a5834477e5fd95adc1eafd 100644 (file)
@@ -1248,7 +1248,8 @@ int xc_dom_build_image(struct xc_dom_image *dom)
         goto err;
     if ( dom->arch_hooks->alloc_magic_pages(dom) != 0 )
         goto err;
-    if ( dom->arch_hooks->alloc_pgtables(dom) != 0 )
+    if ( dom->arch_hooks->alloc_pgtables &&
+         dom->arch_hooks->alloc_pgtables(dom) != 0 )
         goto err;
     if ( dom->alloc_bootstack )
     {
index 1ce3c798efa9490bff4e535ae04b86937787456b..d2acff10614c4b6adb84d3ddd614dcf05b0e8763 100644 (file)
@@ -1690,12 +1690,6 @@ static int bootlate_pv(struct xc_dom_image *dom)
     return 0;
 }
 
-static int alloc_pgtables_hvm(struct xc_dom_image *dom)
-{
-    DOMPRINTF("%s: doing nothing", __func__);
-    return 0;
-}
-
 /*
  * The memory layout of the start_info page and the modules, and where the
  * addresses are stored:
@@ -1906,7 +1900,6 @@ static struct xc_dom_arch xc_hvm_32 = {
     .page_shift = PAGE_SHIFT_X86,
     .sizeof_pfn = 4,
     .alloc_magic_pages = alloc_magic_pages_hvm,
-    .alloc_pgtables = alloc_pgtables_hvm,
     .vcpu = vcpu_hvm,
     .meminit = meminit_hvm,
     .bootearly = bootearly,