Skip to contentSkip to conversation

Allow x86 to unflatten DTs

PATCH In review Alejandro Vallejo 4 participants 16 messages Jul 22, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

v8 cover Allow x86 to unflatten DTs

Hi,

Really minor changes wrt v7

1. s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/
2. Remove stale obj-y statements in the last patch

pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1940366600

v7: https://lore.kernel.org/xen-devel/[email protected]>
v6: https://lore.kernel.org/xen-devel/[email protected]/
v5: https://lore.kernel.org/xen-devel/[email protected]/
v4: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v2: https://lore.kernel.org/xen-devel/[email protected]/
v1: https://lore.kernel.org/xen-devel/[email protected]/

Alejandro Vallejo (11):
x86: Replace arch-specific boot_module with common one
xen: Refactor kernel_info to have a header like boot_domain
x86: Replace arch-specific boot_domain with the common one xen/dt: Move bootfdt functions to xen/bootfdt.h xen/dt: Move bootinfo functions to a new bootinfo.h xen/dt: Rename bootfdt.c -> bootinfo-fdt.c
xen/dt: Extract bootinfo-independent functions to bootfdt.c xen/dt: Extract helper to map nodes to module kinds
xen: Split HAS_DEVICE_TREE in two
xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/

 xen/Kconfig.debug                       |   2 +-
 xen/arch/arm/Kconfig                    |   2 +-
 xen/arch/arm/dom0less-build.c           |   8 +-
 xen/arch/arm/domain_build.c             |  21 +-
 xen/arch/arm/include/asm/setup.h        |   2 +-
 xen/arch/arm/kernel.c                   |   8 +-
 xen/arch/arm/setup.c                    |   1 +
 xen/arch/ppc/Kconfig                    |   2 +-
 xen/arch/riscv/Kconfig                  |   2 +-
 xen/arch/riscv/cpufeature.c             |   1 +
 xen/arch/riscv/mm.c                     |   2 +-
 xen/arch/riscv/setup.c                  |   2 +-
 xen/arch/riscv/smpboot.c                |   1 +
 xen/arch/x86/cpu/microcode/core.c       |   7 +-
 xen/arch/x86/hvm/dom0_build.c           |   8 +-
 xen/arch/x86/include/asm/boot-domain.h  |  33 --
 xen/arch/x86/include/asm/bootfdt.h      |  50 ++
 xen/arch/x86/include/asm/bootinfo.h     |  57 +--
 xen/arch/x86/pv/dom0_build.c            |   6 +-
 xen/arch/x86/setup.c                    |  45 +-
 xen/common/Kconfig                      |  15 +-
 xen/common/Makefile                     |   4 +-
 xen/common/device-tree/Makefile         |   5 +-
 xen/common/device-tree/bootfdt.c        | 617 +-----------------------
 xen/common/device-tree/bootinfo-fdt.c   | 584 ++++++++++++++++++++++
 xen/common/device-tree/bootinfo.c       |   4 +-
 xen/common/device-tree/device-tree.c    |   3 +
 xen/common/device-tree/dom0less-build.c |  20 +-
 xen/common/device-tree/domain-build.c   |  22 +-
 xen/common/device-tree/kernel.c         |  22 +-
 xen/common/device-tree/static-evtchn.c  |   1 +
 xen/common/device.c                     |   4 +-
 xen/common/efi/boot.c                   |   2 +-
 xen/common/sched/Kconfig                |   2 +-
 xen/common/sched/boot-cpupool.c         |   1 +
 xen/drivers/char/ns16550.c              |   6 +-
 xen/drivers/passthrough/Makefile        |   2 +-
 xen/drivers/passthrough/iommu.c         |   2 +-
 xen/include/asm-generic/device.h        |  10 +-
 xen/include/xen/bootfdt.h               | 318 +++++-------
 xen/include/xen/bootinfo.h              | 213 ++++++++
 xen/include/xen/device_tree.h           |  82 +---
 xen/include/xen/fdt-domain-build.h      |   2 +-
 xen/include/xen/fdt-kernel.h            |   7 +-
 xen/include/xen/iommu.h                 |   8 +-
 xen/include/xsm/dummy.h                 |   4 +-
 xen/include/xsm/xsm.h                   |  12 +-
 xen/xsm/dummy.c                         |   2 +-
 xen/xsm/flask/hooks.c                   |   6 +-
 xen/xsm/xsm_core.c                      |   4 +-
 xen/xsm/xsm_policy.c                    |   8 +-
 51 files changed, 1148 insertions(+), 1104 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/boot-domain.h
 create mode 100644 xen/arch/x86/include/asm/bootfdt.h
 create mode 100644 xen/common/device-tree/bootinfo-fdt.c
 create mode 100644 xen/include/xen/bootinfo.h

base-commit: 31bf9f72a9d89221f173c94e379891380333b018

Signature · 1 line
2.43.0
#1 lore raw

PATCH v8 1/11 x86: Replace arch-specific boot_module with common one

These types resemble each other very closely in layout and intent, and with "struct boot_module" already in common code it makes perfect sense to merge them. In order to do so, rename identical fields with conflicting names.

While doing this, s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/, as it was on x86. XSM doesn't support external modules, so don't let the name imply it through ambiguity.

No functional change intended.

---
v8:
* s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/

---
 xen/arch/x86/cpu/microcode/core.c   |  7 ++--
 xen/arch/x86/hvm/dom0_build.c       |  6 ++--
 xen/arch/x86/include/asm/bootfdt.h  | 50 ++++++++++++++++++++++++++
 xen/arch/x86/include/asm/bootinfo.h | 56 +++--------------------------
 xen/arch/x86/pv/dom0_build.c        |  4 +--
 xen/arch/x86/setup.c                | 43 +++++++++++-----------
 xen/common/device-tree/bootfdt.c    |  4 +--
 xen/common/device-tree/bootinfo.c   |  2 +-
 xen/include/xen/bootfdt.h           | 10 +++++-
 xen/xsm/xsm_policy.c                |  4 +--
 10 files changed, 98 insertions(+), 88 deletions(-)
 create mode 100644 xen/arch/x86/include/asm/bootfdt.h
xen/arch/x86/cpu/microcode/core.c +3 -4
index 34a94cd25b..816e9bfe40 100644
@@ -764,8 +764,7 @@ static int __init early_microcode_load(struct boot_info *bi)
             struct cpio_data cd;
 
             /* Search anything unclaimed or likely to be a CPIO archive. */
-            if ( bm->type != BOOTMOD_UNKNOWN &&
-                 bm->type != BOOTMOD_RAMDISK )
+            if ( bm->kind != BOOTMOD_UNKNOWN && bm->kind != BOOTMOD_RAMDISK )
                 continue;
 
             size = bm->size;
@@ -815,12 +814,12 @@ static int __init early_microcode_load(struct boot_info *bi)
             return -ENODEV;
         }
 
-        if ( bi->mods[idx].type != BOOTMOD_UNKNOWN )
+        if ( bi->mods[idx].kind != BOOTMOD_UNKNOWN )
         {
             printk(XENLOG_WARNING "Microcode: Chosen module %d already used\n", idx);
             return -ENODEV;
         }
-        bi->mods[idx].type = BOOTMOD_MICROCODE;
+        bi->mods[idx].kind = BOOTMOD_MICROCODE;
 
         size = bi->mods[idx].size;
         data = bootstrap_map_bm(&bi->mods[idx]);
xen/arch/x86/hvm/dom0_build.c +3 -3
index 9964068387..6be26cc66f 100644
@@ -650,7 +650,7 @@ static int __init pvh_load_kernel(
     struct boot_module *image = bd->kernel;
     struct boot_module *initrd = bd->module;
     void *image_base = bootstrap_map_bm(image);
-    void *image_start = image_base + image->headroom;
+    void *image_start = image_base + image->arch.headroom;
     unsigned long image_len = image->size;
     unsigned long initrd_len = initrd ? initrd->size : 0;
     size_t cmdline_len = bd->cmdline ? strlen(bd->cmdline) + 1 : 0;
@@ -721,9 +721,9 @@ static int __init pvh_load_kernel(
     {
         size_t initrd_space = elf_round_up(&elf, initrd_len);
 
-        if ( initrd->cmdline_pa )
+        if ( initrd->arch.cmdline_pa )
         {
-            initrd_cmdline = __va(initrd->cmdline_pa);
+            initrd_cmdline = __va(initrd->arch.cmdline_pa);
             if ( !*initrd_cmdline )
                 initrd_cmdline = NULL;
         }
xen/arch/x86/include/asm/bootfdt.h new file +50 -0

50 lines not on this page · raw message

xen/arch/x86/include/asm/bootinfo.h +4 -52

81 lines not on this page · raw message

xen/arch/x86/pv/dom0_build.c +2 -2
index e1b78d47c2..a4b5362357 100644
@@ -422,7 +422,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
 
     image_base = bootstrap_map_bm(image);
     image_len = image->size;
-    image_start = image_base + image->headroom;
+    image_start = image_base + image->arch.headroom;
 
     d->max_pages = ~0U;
 
@@ -659,7 +659,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
              * pages. Tell the boot_module handling that we've freed it, so the
              * memory is left alone.
              */
-            initrd->released = true;
+            initrd->arch.released = true;
         }
 
         iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)),
xen/arch/x86/setup.c +22 -21

134 lines not on this page · raw message

xen/common/device-tree/bootfdt.c +2 -2
index 08d919aba6..01f475510e 100644
@@ -349,7 +349,7 @@ static void __init process_multiboot_node(const void *fdt, int node,
               fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
         kind = BOOTMOD_RAMDISK;
     else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
-        kind = BOOTMOD_XSM;
+        kind = BOOTMOD_XSM_POLICY;
     else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") == 0 )
         kind = BOOTMOD_GUEST_DTB;
     else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") == 0 )
@@ -377,7 +377,7 @@ static void __init process_multiboot_node(const void *fdt, int node,
         default: break;
         }
         if ( kind_guess > 1 && has_xsm_magic(start) )
-            kind = BOOTMOD_XSM;
+            kind = BOOTMOD_XSM_POLICY;
     }
 
     domU = fdt_node_check_compatible(fdt, parent_node, "xen,domain") == 0;
xen/common/device-tree/bootinfo.c +1 -1
index 2a27d1318b..eb1b2b729d 100644
@@ -29,7 +29,7 @@ const char * __init boot_module_kind_as_string(boot_module_kind kind)
     case BOOTMOD_FDT:     return "Device Tree";
     case BOOTMOD_KERNEL:  return "Kernel";
     case BOOTMOD_RAMDISK: return "Ramdisk";
-    case BOOTMOD_XSM:     return "XSM";
+    case BOOTMOD_XSM_POLICY:    return "XSM Policy";
     case BOOTMOD_GUEST_DTB:     return "DTB";
     case BOOTMOD_MICROCODE:     return "Microcode";
     case BOOTMOD_UNKNOWN: return "Unknown";
xen/include/xen/bootfdt.h +9 -1
index 7f49d0ccdd..1218b23bb4 100644
@@ -7,6 +7,10 @@
 #include <xen/macros.h>
 #include <xen/xmalloc.h>
 
+#if __has_include(<asm/bootfdt.h>)
+#include <asm/bootfdt.h>
+#endif
+
 #define MIN_FDT_ALIGN 8
 
 #define NR_MEM_BANKS 256
@@ -19,7 +23,7 @@ typedef enum {
     BOOTMOD_FDT,
     BOOTMOD_KERNEL,
     BOOTMOD_RAMDISK,
-    BOOTMOD_XSM,
+    BOOTMOD_XSM_POLICY,
     BOOTMOD_GUEST_DTB,
     BOOTMOD_MICROCODE,
     BOOTMOD_UNKNOWN
@@ -110,6 +114,10 @@ struct boot_module {
 #endif
     paddr_t start;
     paddr_t size;
+
+#if __has_include(<asm/bootfdt.h>)
+    struct arch_boot_module arch;
+#endif
 };
 
 /* DT_MAX_NAME is the node name max length according the DT spec */
xen/xsm/xsm_policy.c +2 -2
index 1f88b4fc5a..27bfc3b995 100644
@@ -53,7 +53,7 @@ int __init xsm_multiboot_policy_init(
             printk("Policy len %#lx, start at %p.\n",
                    _policy_len,_policy_start);
 
-            bm->type = BOOTMOD_XSM_POLICY;
+            bm->kind = BOOTMOD_XSM_POLICY;
             break;
 
         }
@@ -68,7 +68,7 @@ int __init xsm_multiboot_policy_init(
 #ifdef CONFIG_HAS_DEVICE_TREE
 int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size)
 {
-    struct boot_module *mod = boot_module_find_by_kind(BOOTMOD_XSM);
+    struct boot_module *mod = boot_module_find_by_kind(BOOTMOD_XSM_POLICY);
     paddr_t paddr, len;
 
     if ( !mod || !mod->size )
Signature · 1 line
2.43.0
Acked-by on v8 1/11
#2 lore raw

Re: [PATCH v8 01/11] x86: Replace arch-specific boot_module with common one

Quoted 487 lines · Alejandro Vallejo

These types resemble each other very closely in layout and intent, and with "struct boot_module" already in common code it makes perfect sense to merge them. In order to do so, rename identical fields with conflicting names.

While doing this, s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/, as it was on x86. XSM doesn't support external modules, so don't let the name imply it through ambiguity.

No functional change intended.

---
v8:
* s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/

---
  xen/arch/x86/cpu/microcode/core.c   |  7 ++--
  xen/arch/x86/hvm/dom0_build.c       |  6 ++--
  xen/arch/x86/include/asm/bootfdt.h  | 50 ++++++++++++++++++++++++++
  xen/arch/x86/include/asm/bootinfo.h | 56 +++--------------------------
  xen/arch/x86/pv/dom0_build.c        |  4 +--
  xen/arch/x86/setup.c                | 43 +++++++++++-----------
  xen/common/device-tree/bootfdt.c    |  4 +--
  xen/common/device-tree/bootinfo.c   |  2 +-
  xen/include/xen/bootfdt.h           | 10 +++++-
  xen/xsm/xsm_policy.c                |  4 +--
  10 files changed, 98 insertions(+), 88 deletions(-)

create mode 100644 xen/arch/x86/include/asm/bootfdt.h

xen/arch/x86/cpu/microcode/core.c +3 -4
index 34a94cd25b..816e9bfe40 100644
@@ -764,8 +764,7 @@ static int __init early_microcode_load(struct boot_info *bi)
              struct cpio_data cd;
 
              /* Search anything unclaimed or likely to be a CPIO archive. */
-            if ( bm->type != BOOTMOD_UNKNOWN &&
-                 bm->type != BOOTMOD_RAMDISK )
+            if ( bm->kind != BOOTMOD_UNKNOWN && bm->kind != BOOTMOD_RAMDISK )
                  continue;
 
              size = bm->size;
@@ -815,12 +814,12 @@ static int __init early_microcode_load(struct boot_info *bi)
              return -ENODEV;
          }
 
-        if ( bi->mods[idx].type != BOOTMOD_UNKNOWN )
+        if ( bi->mods[idx].kind != BOOTMOD_UNKNOWN )
          {
              printk(XENLOG_WARNING "Microcode: Chosen module %d already used\n", idx);
              return -ENODEV;
          }
-        bi->mods[idx].type = BOOTMOD_MICROCODE;
+        bi->mods[idx].kind = BOOTMOD_MICROCODE;
 
          size = bi->mods[idx].size;
          data = bootstrap_map_bm(&bi->mods[idx]);
xen/arch/x86/hvm/dom0_build.c +3 -3
index 9964068387..6be26cc66f 100644
@@ -650,7 +650,7 @@ static int __init pvh_load_kernel(
      struct boot_module *image = bd->kernel;
      struct boot_module *initrd = bd->module;
      void *image_base = bootstrap_map_bm(image);
-    void *image_start = image_base + image->headroom;
+    void *image_start = image_base + image->arch.headroom;
      unsigned long image_len = image->size;
      unsigned long initrd_len = initrd ? initrd->size : 0;
      size_t cmdline_len = bd->cmdline ? strlen(bd->cmdline) + 1 : 0;
@@ -721,9 +721,9 @@ static int __init pvh_load_kernel(
      {
          size_t initrd_space = elf_round_up(&elf, initrd_len);
 
-        if ( initrd->cmdline_pa )
+        if ( initrd->arch.cmdline_pa )
          {
-            initrd_cmdline = __va(initrd->cmdline_pa);
+            initrd_cmdline = __va(initrd->arch.cmdline_pa);
              if ( !*initrd_cmdline )
                  initrd_cmdline = NULL;
          }
xen/arch/x86/include/asm/bootfdt.h new file +50 -0
new file mode 100644
index 0000000000..a4c4bf30b9
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef X86_BOOTFDT_H
+#define X86_BOOTFDT_H
+
+#include <xen/types.h>
+
+struct arch_boot_module
+{
+    /*
+     * Module State Flags:
+     *   relocated:   indicates module has been relocated in memory.
+     *   released:    indicates module's pages have been freed.
+     */
+    bool relocated:1;
+    bool released:1;
+
+    /*
+     * A boot module may need decompressing by Xen.  Headroom is an estimate of
+     * the additional space required to decompress the module.
+     *
+     * Headroom is accounted for at the start of the module.  Decompressing is
+     * done in-place with input=start, output=start-headroom, expecting the
+     * pointers to become equal (give or take some rounding) when decompression
+     * is complete.
+     *
+     * Memory layout at boot:
+     *
+     *               start ----+
+     *                         v
+     *   |<-----headroom------>|<------size------->|
+     *                         +-------------------+
+     *                         | Compressed Module |
+     *   +---------------------+-------------------+
+     *   |           Decompressed Module           |
+     *   +-----------------------------------------+
+     */
+    unsigned long headroom;
+    paddr_t cmdline_pa;
+};
+
+#endif /* X86_BOOTFDT_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/x86/include/asm/bootinfo.h +4 -52
index 3afc214c17..d33b100e04 100644
@@ -8,6 +8,7 @@
  #ifndef X86_BOOTINFO_H
  #define X86_BOOTINFO_H
 
+#include <xen/bootfdt.h>
  #include <xen/init.h>
  #include <xen/multiboot.h>
  #include <xen/types.h>
@@ -19,55 +20,6 @@
  /* Max number of boot domains that Xen can construct */
  #define MAX_NR_BOOTDOMS 1
 
-/* Boot module binary type / purpose */
-enum bootmod_type {
-    BOOTMOD_UNKNOWN,
-    BOOTMOD_XEN,
-    BOOTMOD_KERNEL,
-    BOOTMOD_RAMDISK,
-    BOOTMOD_MICROCODE,
-    BOOTMOD_XSM_POLICY,
-};
-
-struct boot_module {
-    enum bootmod_type type;
-
-    /*
-     * Module State Flags:
-     *   relocated: indicates module has been relocated in memory.
-     *   released:  indicates module's pages have been freed.
-     */
-    bool relocated:1;
-    bool released:1;
-
-    /*
-     * A boot module may need decompressing by Xen.  Headroom is an estimate of
-     * the additional space required to decompress the module.
-     *
-     * Headroom is accounted for at the start of the module.  Decompressing is
-     * done in-place with input=start, output=start-headroom, expecting the
-     * pointers to become equal (give or take some rounding) when decompression
-     * is complete.
-     *
-     * Memory layout at boot:
-     *
-     *               start ----+
-     *                         v
-     *   |<-----headroom------>|<------size------->|
-     *                         +-------------------+
-     *                         | Compressed Module |
-     *   +---------------------+-------------------+
-     *   |           Decompressed Module           |
-     *   +-----------------------------------------+
-     */
-    unsigned long headroom;
-
-    paddr_t cmdline_pa;
-
-    paddr_t start;
-    size_t size;
-};
-
  /*
   * Xen internal representation of information provided by the
   * bootloader/environment, or derived from the information.
@@ -94,16 +46,16 @@ struct boot_info {
   *      Failure - a value greater than MAX_NR_BOOTMODS
   */
  static inline unsigned int __init next_boot_module_index(
-    const struct boot_info *bi, enum bootmod_type t, unsigned int start)
+    const struct boot_info *bi, boot_module_kind k, unsigned int start)
  {
      unsigned int i;
 
-    if ( t == BOOTMOD_XEN )
+    if ( k == BOOTMOD_XEN )
          return bi->nr_modules;
 
      for ( i = start; i < bi->nr_modules; i++ )
      {
-        if ( bi->mods[i].type == t )
+        if ( bi->mods[i].kind == k )
              return i;
      }
 
xen/arch/x86/pv/dom0_build.c +2 -2
index e1b78d47c2..a4b5362357 100644
@@ -422,7 +422,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
 
      image_base = bootstrap_map_bm(image);
      image_len = image->size;
-    image_start = image_base + image->headroom;
+    image_start = image_base + image->arch.headroom;
 
      d->max_pages = ~0U;
 
@@ -659,7 +659,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
               * pages. Tell the boot_module handling that we've freed it, so the
               * memory is left alone.
               */
-            initrd->released = true;
+            initrd->arch.released = true;
          }
 
          iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)),
xen/arch/x86/setup.c +22 -21
index c6890669b9..58fd806072 100644
@@ -303,7 +303,7 @@ struct boot_info __initdata xen_boot_info = {
       *
       * The extra entry exists to be able to add the Xen image as a module.
       */
-    .mods = { [0 ... MAX_NR_BOOTMODS] = { .type = BOOTMOD_UNKNOWN } },
+    .mods = { [0 ... MAX_NR_BOOTMODS] = { .kind = BOOTMOD_UNKNOWN } },
  };
 
  static struct boot_info *__init multiboot_fill_boot_info(
@@ -338,7 +338,7 @@ static struct boot_info *__init multiboot_fill_boot_info(
       */
      for ( i = 0; i < MAX_NR_BOOTMODS && i < bi->nr_modules; i++ )
      {
-        bi->mods[i].cmdline_pa = mods[i].string;
+        bi->mods[i].arch.cmdline_pa = mods[i].string;
 
          if ( efi_enabled(EFI_LOADER) )
          {
@@ -361,7 +361,7 @@ static struct boot_info *__init multiboot_fill_boot_info(
      }
 
      /* Variable 'i' should be one entry past the last module. */
-    bi->mods[i].type = BOOTMOD_XEN;
+    bi->mods[i].kind = BOOTMOD_XEN;
 
      return bi;
  }
@@ -388,11 +388,11 @@ unsigned long __init initial_images_nrpages(nodeid_t node)
 
  void __init release_boot_module(struct boot_module *bm)
  {
-    ASSERT(!bm->released);
+    ASSERT(!bm->arch.released);
 
      init_domheap_pages(bm->start, bm->start + PAGE_ALIGN(bm->size));
 
-    bm->released = true;
+    bm->arch.released = true;
  }
 
  void __init free_boot_modules(void)
@@ -402,7 +402,7 @@ void __init free_boot_modules(void)
 
      for ( i = 0; i < bi->nr_modules; ++i )
      {
-        if ( bi->mods[i].released )
+        if ( bi->mods[i].arch.released )
              continue;
 
          release_boot_module(&bi->mods[i]);
@@ -997,8 +997,8 @@ static size_t __init domain_cmdline_size(const struct boot_info *bi,
  {
      size_t s = 0;
 
-    if ( bd->kernel->cmdline_pa )
-        s += strlen(__va(bd->kernel->cmdline_pa));
+    if ( bd->kernel->arch.cmdline_pa )
+        s += strlen(__va(bd->kernel->arch.cmdline_pa));
 
      if ( bi->kextra )
          s += strlen(bi->kextra);
@@ -1065,9 +1065,10 @@ static struct domain *__init create_dom0(struct boot_info *bi)
          if ( !(cmdline = xzalloc_array(char, cmdline_size)) )
              panic("Error allocating cmdline buffer for %pd\n", d);
 
-        if ( bd->kernel->cmdline_pa )
+        if ( bd->kernel->arch.cmdline_pa )
              strlcpy(cmdline,
-                    cmdline_cook(__va(bd->kernel->cmdline_pa), bi->loader),
+                    cmdline_cook(__va(bd->kernel->arch.cmdline_pa),
+                                 bi->loader),
                      cmdline_size);
 
          if ( bi->kextra )
@@ -1089,7 +1090,7 @@ static struct domain *__init create_dom0(struct boot_info *bi)
              strlcat(cmdline, " acpi=", cmdline_size);
              strlcat(cmdline, acpi_param, cmdline_size);
          }
-        bd->kernel->cmdline_pa = 0;
+        bd->kernel->arch.cmdline_pa = 0;
          bd->cmdline = cmdline;
      }
 
@@ -1302,7 +1303,7 @@ void asmlinkage __init noreturn __start_xen(void)
      }
 
      /* Dom0 kernel is always first */
-    bi->mods[0].type = BOOTMOD_KERNEL;
+    bi->mods[0].kind = BOOTMOD_KERNEL;
      bi->domains[0].kernel = &bi->mods[0];
 
      if ( pvh_boot )
@@ -1486,7 +1487,7 @@ void asmlinkage __init noreturn __start_xen(void)
          xen->size  = __2M_rwdata_end - _stext;
      }
 
-    bi->mods[0].headroom =
+    bi->mods[0].arch.headroom =
          bzimage_headroom(bootstrap_map_bm(&bi->mods[0]), bi->mods[0].size);
      bootstrap_unmap();
 
@@ -1568,9 +1569,9 @@ void asmlinkage __init noreturn __start_xen(void)
          for ( j = bi->nr_modules - 1; j >= 0; j-- )
          {
              struct boot_module *bm = &bi->mods[j];
-            unsigned long size = PAGE_ALIGN(bm->headroom + bm->size);
+            unsigned long size = PAGE_ALIGN(bm->arch.headroom + bm->size);
 
-            if ( bm->relocated )
+            if ( bm->arch.relocated )
                  continue;
 
              /* Don't overlap with other modules (or Xen itself). */
@@ -1580,12 +1581,12 @@ void asmlinkage __init noreturn __start_xen(void)
              if ( highmem_start && end > highmem_start )
                  continue;
 
-            if ( s < end && (bm->headroom || (end - size) > bm->start) )
+            if ( s < end && (bm->arch.headroom || (end - size) > bm->start) )
              {
-                move_memory(end - size + bm->headroom, bm->start, bm->size);
+                move_memory(end - size + bm->arch.headroom, bm->start, bm->size);
                  bm->start = (end - size);
-                bm->size += bm->headroom;
-                bm->relocated = true;
+                bm->size += bm->arch.headroom;
+                bm->arch.relocated = true;
              }
          }
 
@@ -1611,7 +1612,7 @@ void asmlinkage __init noreturn __start_xen(void)
  #endif
      }
 
-    if ( bi->mods[0].headroom && !bi->mods[0].relocated )
+    if ( bi->mods[0].arch.headroom && !bi->mods[0].arch.relocated )
          panic("Not enough memory to relocate the dom0 kernel image\n");
      for ( i = 0; i < bi->nr_modules; ++i )
      {
@@ -2169,7 +2170,7 @@ void asmlinkage __init noreturn __start_xen(void)
      initrdidx = first_boot_module_index(bi, BOOTMOD_UNKNOWN);
      if ( initrdidx < MAX_NR_BOOTMODS )
      {
-        bi->mods[initrdidx].type = BOOTMOD_RAMDISK;
+        bi->mods[initrdidx].kind = BOOTMOD_RAMDISK;
          bi->domains[0].module = &bi->mods[initrdidx];
          if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS )
              printk(XENLOG_WARNING
xen/common/device-tree/bootfdt.c +2 -2
index 08d919aba6..01f475510e 100644
@@ -349,7 +349,7 @@ static void __init process_multiboot_node(const void *fdt, int node,
                fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
          kind = BOOTMOD_RAMDISK;
      else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
-        kind = BOOTMOD_XSM;
+        kind = BOOTMOD_XSM_POLICY;
      else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") == 0 )
          kind = BOOTMOD_GUEST_DTB;
      else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") == 0 )
@@ -377,7 +377,7 @@ static void __init process_multiboot_node(const void *fdt, int node,
          default: break;
          }
          if ( kind_guess > 1 && has_xsm_magic(start) )
-            kind = BOOTMOD_XSM;
+            kind = BOOTMOD_XSM_POLICY;
      }
 
      domU = fdt_node_check_compatible(fdt, parent_node, "xen,domain") == 0;
xen/common/device-tree/bootinfo.c +1 -1
index 2a27d1318b..eb1b2b729d 100644
@@ -29,7 +29,7 @@ const char * __init boot_module_kind_as_string(boot_module_kind kind)
      case BOOTMOD_FDT:     return "Device Tree";
      case BOOTMOD_KERNEL:  return "Kernel";
      case BOOTMOD_RAMDISK: return "Ramdisk";
-    case BOOTMOD_XSM:     return "XSM";
+    case BOOTMOD_XSM_POLICY:    return "XSM Policy";
      case BOOTMOD_GUEST_DTB:     return "DTB";
      case BOOTMOD_MICROCODE:     return "Microcode";
      case BOOTMOD_UNKNOWN: return "Unknown";
xen/include/xen/bootfdt.h +9 -1
index 7f49d0ccdd..1218b23bb4 100644
@@ -7,6 +7,10 @@
  #include <xen/macros.h>
  #include <xen/xmalloc.h>
 
+#if __has_include(<asm/bootfdt.h>)
+#include <asm/bootfdt.h>
+#endif
+
  #define MIN_FDT_ALIGN 8
 
  #define NR_MEM_BANKS 256
@@ -19,7 +23,7 @@ typedef enum {
      BOOTMOD_FDT,
      BOOTMOD_KERNEL,
      BOOTMOD_RAMDISK,
-    BOOTMOD_XSM,
+    BOOTMOD_XSM_POLICY,
      BOOTMOD_GUEST_DTB,
      BOOTMOD_MICROCODE,
      BOOTMOD_UNKNOWN
@@ -110,6 +114,10 @@ struct boot_module {
  #endif
      paddr_t start;
      paddr_t size;
+
+#if __has_include(<asm/bootfdt.h>)
+    struct arch_boot_module arch;
+#endif
  };
 
  /* DT_MAX_NAME is the node name max length according the DT spec */
xen/xsm/xsm_policy.c +1 -1
index 1f88b4fc5a..27bfc3b995 100644
@@ -53,7 +53,7 @@ int __init xsm_multiboot_policy_init(
              printk("Policy len %#lx, start at %p.\n",
                     _policy_len,_policy_start);
 
-            bm->type = BOOTMOD_XSM_POLICY;
+            bm->kind = BOOTMOD_XSM_POLICY;
              break;
 
          }

xen/xsm/xsm_policy.c int __init xsm_multiboot_policy_init( · line 74

Quoted 8 lines
xen/xsm/xsm_policy.c +1 -1
@@ -68,7 +68,7 @@ int __init xsm_multiboot_policy_init(
  #ifdef CONFIG_HAS_DEVICE_TREE
  int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size)
  {
-    struct boot_module *mod = boot_module_find_by_kind(BOOTMOD_XSM);
+    struct boot_module *mod = boot_module_find_by_kind(BOOTMOD_XSM_POLICY);
      paddr_t paddr, len;
 
      if ( !mod || !mod->size )
#3 lore raw

PATCH v8 2/11 xen: Refactor kernel_info to have a header like boot_domain

In reply to Alejandro Vallejo

Create a struct field within kernel_info with the contents common to kernel_info and boot_domain, and define that field in common code. This enables x86 to use that field as-is and drop x86's boot_domain.

Note that x86 mutates the module when releasing it, calculating headroom, etc. So they must be made non-const on move.

Not a functional change.

---
 xen/arch/arm/dom0less-build.c           |  8 ++++----
 xen/arch/arm/domain_build.c             | 20 ++++++++++----------
 xen/arch/arm/kernel.c                   |  8 ++++----
 xen/common/device-tree/dom0less-build.c | 18 +++++++++---------
 xen/common/device-tree/domain-build.c   | 20 ++++++++++----------
 xen/common/device-tree/kernel.c         | 20 ++++++++++----------
 xen/include/xen/bootfdt.h               |  9 +++++++++
 xen/include/xen/fdt-kernel.h            |  5 ++---
 8 files changed, 58 insertions(+), 50 deletions(-)
xen/arch/arm/dom0less-build.c +4 -4
index 4b285cff5e..69b9ea22ce 100644
@@ -32,7 +32,7 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo)
     int res = 0;
     __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2];
     __be32 *cells;
-    const struct domain *d = kinfo->d;
+    const struct domain *d = kinfo->bd.d;
 
     res = domain_fdt_begin_node(fdt, "interrupt-controller",
                                 vgic_dist_base(&d->arch.vgic));
@@ -85,7 +85,7 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo)
     void *fdt = kinfo->fdt;
     int res = 0;
     __be32 *reg, *cells;
-    const struct domain *d = kinfo->d;
+    const struct domain *d = kinfo->bd.d;
     unsigned int i, len = 0;
 
     res = domain_fdt_begin_node(fdt, "interrupt-controller",
@@ -152,7 +152,7 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo)
 
 int __init make_intc_domU_node(struct kernel_info *kinfo)
 {
-    switch ( kinfo->d->arch.vgic.version )
+    switch ( kinfo->bd.d->arch.vgic.version )
     {
 #ifdef CONFIG_GICV3
     case GIC_V3:
@@ -175,7 +175,7 @@ static int __init make_vpl011_uart_node(struct kernel_info *kinfo)
     gic_interrupt_t intr;
     __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS];
     __be32 *cells;
-    struct domain *d = kinfo->d;
+    struct domain *d = kinfo->bd.d;
 
     res = domain_fdt_begin_node(fdt, "sbsa-uart", d->arch.vpl011.base_addr);
     if ( res )
xen/arch/arm/domain_build.c +10 -10
index ed668bd61c..5f81d060dd 100644
@@ -459,8 +459,8 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,
     int had_dom0_bootargs = 0;
     struct dt_device_node *iommu_node;
 
-    if ( kinfo->cmdline && kinfo->cmdline[0] )
-        bootargs = &kinfo->cmdline[0];
+    if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] )
+        bootargs = &kinfo->bd.cmdline[0];
 
     /*
      * We always skip the IOMMU device when creating DT for hwdom if there is
@@ -574,7 +574,7 @@ static int __init write_properties(struct domain *d, struct kernel_info *kinfo,
 
     if ( dt_node_path_is_equal(node, "/chosen") )
     {
-        const struct boot_module *initrd = kinfo->initrd;
+        const struct boot_module *initrd = kinfo->bd.initrd;
 
         if ( bootargs )
         {
@@ -1456,7 +1456,7 @@ int __init make_timer_node(const struct kernel_info *kinfo)
     if ( res )
         return res;
 
-    if ( !is_64bit_domain(kinfo->d) )
+    if ( !is_64bit_domain(kinfo->bd.d) )
         res = fdt_property_string(fdt, "compatible", "arm,armv7-timer");
     else
         res = fdt_property_string(fdt, "compatible", "arm,armv8-timer");
@@ -1468,7 +1468,7 @@ int __init make_timer_node(const struct kernel_info *kinfo)
      * It always exposes an active-low level-sensitive interrupt.
      */
 
-    if ( is_hardware_domain(kinfo->d) )
+    if ( is_hardware_domain(kinfo->bd.d) )
     {
         irq[TIMER_PHYS_SECURE_PPI] = timer_get_irq(TIMER_PHYS_SECURE_PPI);
         irq[TIMER_PHYS_NONSECURE_PPI] =
@@ -1517,7 +1517,7 @@ int __init make_chosen_node(const struct kernel_info *kinfo)
 {
     int res;
     const char *bootargs = NULL;
-    const struct boot_module *initrd = kinfo->initrd;
+    const struct boot_module *initrd = kinfo->bd.initrd;
     void *fdt = kinfo->fdt;
 
     dt_dprintk("Create chosen node\n");
@@ -1525,9 +1525,9 @@ int __init make_chosen_node(const struct kernel_info *kinfo)
     if ( res )
         return res;
 
-    if ( kinfo->cmdline && kinfo->cmdline[0] )
+    if ( kinfo->bd.cmdline && kinfo->bd.cmdline[0] )
     {
-        bootargs = &kinfo->cmdline[0];
+        bootargs = &kinfo->bd.cmdline[0];
         res = fdt_property(fdt, "bootargs", bootargs, strlen(bootargs) + 1);
         if ( res )
            return res;
@@ -1976,7 +1976,7 @@ static int __init construct_dom0(struct domain *d)
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
     kinfo.unassigned_mem = dom0_mem;
-    kinfo.d = d;
+    kinfo.bd.d = d;
 
     rc = kernel_probe(&kinfo, NULL);
     if ( rc < 0 )
@@ -1988,7 +1988,7 @@ static int __init construct_dom0(struct domain *d)
 int __init construct_hwdom(struct kernel_info *kinfo,
                            const struct dt_device_node *node)
 {
-    struct domain *d = kinfo->d;
+    struct domain *d = kinfo->bd.d;
     int rc;
 
     iommu_hwdom_init(d);
xen/arch/arm/kernel.c +4 -4
index e734ec5c1e..48f4b56d0c 100644
@@ -46,7 +46,7 @@ static void __init place_modules(struct kernel_info *info,
                                  paddr_t kernbase, paddr_t kernend)
 {
     /* Align DTB and initrd size to 2Mb. Linux only requires 4 byte alignment */
-    const struct boot_module *mod = info->initrd;
+    const struct boot_module *mod = info->bd.initrd;
     const struct membanks *mem = kernel_info_get_mem(info);
     const paddr_t initrd_len = ROUNDUP(mod ? mod->size : 0, MB(2));
     const paddr_t dtb_len = ROUNDUP(fdt_totalsize(info->fdt), MB(2));
@@ -152,12 +152,12 @@ static void __init kernel_zimage_load(struct kernel_info *info)
 
     kernel = ioremap_wc(paddr, len);
     if ( !kernel )
-        panic("Unable to map the %pd kernel\n", info->d);
+        panic("Unable to map the %pd kernel\n", info->bd.d);
 
-    rc = copy_to_guest_phys_flush_dcache(info->d, load_addr,
+    rc = copy_to_guest_phys_flush_dcache(info->bd.d, load_addr,
                                          kernel, len);
     if ( rc != 0 )
-        panic("Unable to copy the kernel in the %pd memory\n", info->d);
+        panic("Unable to copy the kernel in the %pd memory\n", info->bd.d);
 
     iounmap(kernel);
 }
xen/common/device-tree/dom0less-build.c +9 -9
index 0012046574..15b3c4b241 100644
@@ -170,18 +170,18 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
             return -EINVAL;
         }
 
-        res = iomem_permit_access(kinfo->d, paddr_to_pfn(mstart),
+        res = iomem_permit_access(kinfo->bd.d, paddr_to_pfn(mstart),
                                   paddr_to_pfn(PAGE_ALIGN(mstart + size - 1)));
         if ( res )
         {
             printk(XENLOG_ERR "Unable to permit to dom%d access to"
                    " 0x%"PRIpaddr" - 0x%"PRIpaddr"\n",
-                   kinfo->d->domain_id,
+                   kinfo->bd.d->domain_id,
                    mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - 1);
             return res;
         }
 
-        res = map_regions_p2mt(kinfo->d,
+        res = map_regions_p2mt(kinfo->bd.d,
                                gaddr_to_gfn(gstart),
                                PFN_DOWN(size),
                                maddr_to_mfn(mstart),
@@ -220,7 +220,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
         return -EINVAL;
     }
 
-    res = map_device_irqs_to_domain(kinfo->d, node, true, NULL);
+    res = map_device_irqs_to_domain(kinfo->bd.d, node, true, NULL);
     if ( res < 0 )
         return res;
 
@@ -232,7 +232,7 @@ static int __init handle_passthrough_prop(struct kernel_info *kinfo,
     if ( xen_force && !dt_device_is_protected(node) )
         return 0;
 
-    return iommu_assign_dt_device(kinfo->d, node);
+    return iommu_assign_dt_device(kinfo->bd.d, node);
 }
 
 static int __init handle_prop_pfdt(struct kernel_info *kinfo,
@@ -299,14 +299,14 @@ static int __init handle_prop_pfdt(struct kernel_info *kinfo,
                                       address_cells, size_cells);
         if ( res < 0 )
         {
-            printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->d);
+            printk(XENLOG_ERR "Failed to assign device to %pd\n", kinfo->bd.d);
             return res;
         }
     }
     else if ( (xen_path && !xen_reg) || (xen_reg && !xen_path && !xen_force) )
     {
         printk(XENLOG_ERR "xen,reg or xen,path missing for %pd\n",
-               kinfo->d);
+               kinfo->bd.d);
         return -EINVAL;
     }
 
@@ -608,7 +608,7 @@ static int __init alloc_xenstore_page(struct domain *d)
 
 static int __init alloc_xenstore_params(struct kernel_info *kinfo)
 {
-    struct domain *d = kinfo->d;
+    struct domain *d = kinfo->bd.d;
     int rc = 0;
 
 #ifdef CONFIG_HVM
@@ -776,7 +776,7 @@ static int __init construct_domU(struct domain *d,
 
     d->max_pages = ((paddr_t)mem * SZ_1K) >> PAGE_SHIFT;
 
-    kinfo.d = d;
+    kinfo.bd.d = d;
 
     rc = kernel_probe(&kinfo, node);
     if ( rc < 0 )
xen/common/device-tree/domain-build.c +10 -10
index 4eea095e49..2fdea6624a 100644
@@ -76,7 +76,7 @@ bool __init allocate_bank_memory(struct kernel_info *kinfo, gfn_t sgfn,
                                  paddr_t tot_size)
 {
     struct membanks *mem = kernel_info_get_mem(kinfo);
-    struct domain *d = kinfo->d;
+    struct domain *d = kinfo->bd.d;
     struct membank *bank;
 
     /*
@@ -170,7 +170,7 @@ int __init find_unallocated_memory(const struct kernel_info *kinfo,
     unsigned int i, j;
     int res;
 
-    ASSERT(domain_use_host_layout(kinfo->d));
+    ASSERT(domain_use_host_layout(kinfo->bd.d));
 
     unalloc_mem = rangeset_new(NULL, NULL, 0);
     if ( !unalloc_mem )
@@ -341,23 +341,23 @@ void __init dtb_load(struct kernel_info *kinfo,
     unsigned long left;
 
     printk("Loading %pd DTB to 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           kinfo->d, kinfo->dtb_paddr,
+           kinfo->bd.d, kinfo->dtb_paddr,
            kinfo->dtb_paddr + fdt_totalsize(kinfo->fdt));
 
-    left = cb(kinfo->d, kinfo->dtb_paddr,
+    left = cb(kinfo->bd.d, kinfo->dtb_paddr,
               kinfo->fdt,
               fdt_totalsize(kinfo->fdt));
 
     if ( left != 0 )
         panic("Unable to copy the DTB to %pd memory (left = %lu bytes)\n",
-              kinfo->d, left);
+              kinfo->bd.d, left);
     xfree(kinfo->fdt);
 }
 
 void __init initrd_load(struct kernel_info *kinfo,
                         copy_to_guest_phys_cb cb)
 {
-    const struct boot_module *mod = kinfo->initrd;
+    const struct boot_module *mod = kinfo->bd.initrd;
     paddr_t load_addr = kinfo->initrd_paddr;
     paddr_t paddr, len;
     int node;
@@ -373,7 +373,7 @@ void __init initrd_load(struct kernel_info *kinfo,
     len = mod->size;
 
     printk("Loading %pd initrd from %"PRIpaddr" to 0x%"PRIpaddr"-0x%"PRIpaddr"\n",
-           kinfo->d, paddr, load_addr, load_addr + len);
+           kinfo->bd.d, paddr, load_addr, load_addr + len);
 
     /* Fix up linux,initrd-start and linux,initrd-end in /chosen */
     node = fdt_path_offset(kinfo->fdt, "/chosen");
@@ -396,11 +396,11 @@ void __init initrd_load(struct kernel_info *kinfo,
 
     initrd = ioremap_wc(paddr, len);
     if ( !initrd )
-        panic("Unable to map the %pd initrd\n", kinfo->d);
+        panic("Unable to map the %pd initrd\n", kinfo->bd.d);
 
-    res = cb(kinfo->d, load_addr, initrd, len);
+    res = cb(kinfo->bd.d, load_addr, initrd, len);
     if ( res != 0 )
-        panic("Unable to copy the initrd in the %pd memory\n", kinfo->d);
+        panic("Unable to copy the initrd in the %pd memory\n", kinfo->bd.d);
 
     iounmap(initrd);
 }
xen/common/device-tree/kernel.c +10 -10
index e1b22dc1c7..6de2334dbe 100644
@@ -136,16 +136,16 @@ int __init kernel_probe(struct kernel_info *info,
     /* domain is NULL only for the hardware domain */
     if ( domain == NULL )
     {
-        ASSERT(is_hardware_domain(info->d));
+        ASSERT(is_hardware_domain(info->bd.d));
 
         mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
 
-        info->kernel = mod;
-        info->initrd = boot_module_find_by_kind(BOOTMOD_RAMDISK);
+        info->bd.kernel = mod;
+        info->bd.initrd = boot_module_find_by_kind(BOOTMOD_RAMDISK);
 
         cmd = boot_cmdline_find_by_kind(BOOTMOD_KERNEL);
         if ( cmd )
-            info->cmdline = &cmd->cmdline[0];
+            info->bd.cmdline = &cmd->cmdline[0];
     }
     else
     {
@@ -162,7 +162,7 @@ int __init kernel_probe(struct kernel_info *info,
                 dt_get_range(&val, node, &kernel_addr, &size);
                 mod = boot_module_find_by_addr_and_kind(
                         BOOTMOD_KERNEL, kernel_addr);
-                info->kernel = mod;
+                info->bd.kernel = mod;
             }
             else if ( dt_device_is_compatible(node, "multiboot,ramdisk") )
             {
@@ -171,7 +171,7 @@ int __init kernel_probe(struct kernel_info *info,
 
                 val = dt_get_property(node, "reg", &len);
                 dt_get_range(&val, node, &initrd_addr, &size);
-                info->initrd = boot_module_find_by_addr_and_kind(
+                info->bd.initrd = boot_module_find_by_addr_and_kind(
                         BOOTMOD_RAMDISK, initrd_addr);
             }
             else if ( dt_device_is_compatible(node, "multiboot,device-tree") )
@@ -192,7 +192,7 @@ int __init kernel_probe(struct kernel_info *info,
         name = dt_node_name(domain);
         cmd = boot_cmdline_find_by_name(name);
         if ( cmd )
-            info->cmdline = &cmd->cmdline[0];
+            info->bd.cmdline = &cmd->cmdline[0];
     }
     if ( !mod || !mod->size )
     {
@@ -201,10 +201,10 @@ int __init kernel_probe(struct kernel_info *info,
     }
 
     printk("Loading %pd kernel from boot module @ %"PRIpaddr"\n",
-           info->d, info->kernel->start);
-    if ( info->initrd )
+           info->bd.d, info->bd.kernel->start);
+    if ( info->bd.initrd )
         printk("Loading ramdisk from boot module @ %"PRIpaddr"\n",
-               info->initrd->start);
+               info->bd.initrd->start);
 
     /*
      * uImage isn't really used nowadays thereby leave kernel_uimage_probe()
xen/include/xen/bootfdt.h +9 -0
index 1218b23bb4..fceffaf2ec 100644
@@ -100,6 +100,15 @@ struct shared_meminfo {
     struct shmem_membank_extra extra[NR_SHMEM_BANKS];
 };
 
+struct boot_domain {
+    struct domain *d;
+
+    struct boot_module *kernel;
+    struct boot_module *initrd;
+
+    const char *cmdline;
+};
+
 #define BOOTMOD_MAX_CMDLINE 1024
 struct boot_module {
     boot_module_kind kind;
xen/include/xen/fdt-kernel.h +2 -3
index 12a0b42d17..8363865282 100644
@@ -16,7 +16,7 @@
 #endif
 
 struct kernel_info {
-    struct domain *d;
+    struct boot_domain bd;
 
     void *fdt; /* flat device tree */
     paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */
@@ -34,8 +34,7 @@ struct kernel_info {
     paddr_t gnttab_size;
 
     /* boot blob load addresses */
-    const struct boot_module *kernel, *initrd, *dtb;
-    const char* cmdline;
+    const struct boot_module *dtb;
     paddr_t dtb_paddr;
     paddr_t initrd_paddr;
 
Signature · 1 line
2.43.0
#4 lore raw

PATCH v8 3/11 x86: Replace arch-specific boot_domain with the common one

In reply to Alejandro Vallejo

No functional change intended.

---
 xen/arch/x86/hvm/dom0_build.c          |  2 +-
 xen/arch/x86/include/asm/boot-domain.h | 33 --------------------------
 xen/arch/x86/include/asm/bootinfo.h    |  1 -
 xen/arch/x86/pv/dom0_build.c           |  2 +-
 xen/arch/x86/setup.c                   |  2 +-
 xen/include/xen/bootfdt.h              |  4 ++++
 6 files changed, 7 insertions(+), 37 deletions(-)
 delete mode 100644 xen/arch/x86/include/asm/boot-domain.h
xen/arch/x86/hvm/dom0_build.c +1 -1
index 6be26cc66f..5551f90448 100644
@@ -648,7 +648,7 @@ static int __init pvh_load_kernel(
 {
     struct domain *d = bd->d;
     struct boot_module *image = bd->kernel;
-    struct boot_module *initrd = bd->module;
+    struct boot_module *initrd = bd->initrd;
     void *image_base = bootstrap_map_bm(image);
     void *image_start = image_base + image->arch.headroom;
     unsigned long image_len = image->size;
xen/arch/x86/include/asm/boot-domain.h deleted +0 -33
deleted file mode 100644
index d7c6042e25..0000000000
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2024 Apertus Solutions, LLC
- * Author: Daniel P. Smith <[email protected]>
- * Copyright (c) 2024 Christopher Clark <[email protected]>
- */
-
-#ifndef __XEN_X86_BOOTDOMAIN_H__
-#define __XEN_X86_BOOTDOMAIN_H__
-
-#include <public/xen.h>
-
-struct boot_domain {
-    domid_t domid;
-
-    struct boot_module *kernel;
-    struct boot_module *module;
-    const char *cmdline;
-
-    struct domain *d;
-};
-
-#endif
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
xen/arch/x86/include/asm/bootinfo.h +0 -1
index d33b100e04..4f2cc5906e 100644
@@ -12,7 +12,6 @@
 #include <xen/init.h>
 #include <xen/multiboot.h>
 #include <xen/types.h>
-#include <asm/boot-domain.h>
 
 /* Max number of boot modules a bootloader can provide in addition to Xen */
 #define MAX_NR_BOOTMODS 63
xen/arch/x86/pv/dom0_build.c +1 -1
index a4b5362357..c37bea9454 100644
@@ -375,7 +375,7 @@ static int __init dom0_construct(const struct boot_domain *bd)
     struct vcpu *v = d->vcpu[0];
 
     struct boot_module *image = bd->kernel;
-    struct boot_module *initrd = bd->module;
+    struct boot_module *initrd = bd->initrd;
     void *image_base;
     unsigned long image_len;
     void *image_start;
xen/arch/x86/setup.c +1 -1
index 58fd806072..1543dd251c 100644
@@ -2171,7 +2171,7 @@ void asmlinkage __init noreturn __start_xen(void)
     if ( initrdidx < MAX_NR_BOOTMODS )
     {
         bi->mods[initrdidx].kind = BOOTMOD_RAMDISK;
-        bi->domains[0].module = &bi->mods[initrdidx];
+        bi->domains[0].initrd = &bi->mods[initrdidx];
         if ( first_boot_module_index(bi, BOOTMOD_UNKNOWN) < MAX_NR_BOOTMODS )
             printk(XENLOG_WARNING
                    "Multiple initrd candidates, picking module #%u\n",
xen/include/xen/bootfdt.h +4 -0
index fceffaf2ec..9c2b954121 100644
@@ -103,6 +103,10 @@ struct shared_meminfo {
 struct boot_domain {
     struct domain *d;
 
+#ifdef CONFIG_X86
+    domid_t domid;
+#endif
+
     struct boot_module *kernel;
     struct boot_module *initrd;
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH v8 4/11 xen/dt: Move bootfdt functions to xen/bootfdt.h

In reply to Alejandro Vallejo

Part of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take.

Move functions required for early FDT parsing from device_tree.h and arm's setup.h onto bootfdt.h

Declaration motion only. Not a functional change.

---
 xen/arch/riscv/cpufeature.c            |   1 +
 xen/arch/riscv/smpboot.c               |   1 +
 xen/common/device-tree/bootfdt.c       |  12 ---
 xen/common/device-tree/device-tree.c   |   1 +
 xen/common/device-tree/static-evtchn.c |   1 +
 xen/common/sched/boot-cpupool.c        |   1 +
 xen/include/xen/bootfdt.h              | 103 +++++++++++++++++++++++++
 xen/include/xen/device_tree.h          |  78 -------------------
 8 files changed, 108 insertions(+), 90 deletions(-)
xen/arch/riscv/cpufeature.c +1 -0
index b7d5ec6580..b846a106a3 100644
@@ -8,6 +8,7 @@
  */
 
 #include <xen/bitmap.h>
+#include <xen/bootfdt.h>
 #include <xen/ctype.h>
 #include <xen/device_tree.h>
 #include <xen/errno.h>
xen/arch/riscv/smpboot.c +1 -0
index 470f6d1311..3b8bf98e20 100644
@@ -1,3 +1,4 @@
+#include <xen/bootfdt.h>
 #include <xen/cpumask.h>
 #include <xen/device_tree.h>
 #include <xen/errno.h>
xen/common/device-tree/bootfdt.c +0 -12
index 01f475510e..48ecbfd600 100644
@@ -215,18 +215,6 @@ u32 __init device_tree_get_u32(const void *fdt, int node,
     return fdt32_to_cpu(get_unaligned_t(uint32_t, prop->data));
 }
 
-/**
- * device_tree_for_each_node - iterate over all device tree sub-nodes
- * @fdt: flat device tree.
- * @node: parent node to start the search from
- * @func: function to call for each sub-node.
- * @data: data to pass to @func.
- *
- * Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored.
- *
- * Returns 0 if all nodes were iterated over successfully.  If @func
- * returns a value different from 0, that value is returned immediately.
- */
 int __init device_tree_for_each_node(const void *fdt, int node,
                                      device_tree_node_func func,
                                      void *data)
xen/common/device-tree/device-tree.c +1 -0
index 7bede20fa6..4ebdb2e52e 100644
@@ -8,6 +8,7 @@
  */
 
 #include <xen/bitops.h>
+#include <xen/bootfdt.h>
 #include <xen/types.h>
 #include <xen/init.h>
 #include <xen/guest_access.h>
xen/common/device-tree/static-evtchn.c +1 -0
index 8b82e6b3d8..88342b44a1 100644
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
+#include <xen/bootfdt.h>
 #include <xen/event.h>
 #include <xen/static-evtchn.h>
 
xen/common/sched/boot-cpupool.c +1 -0
index 641f3495cb..03be73efdd 100644
@@ -7,6 +7,7 @@
  * Copyright (C) 2022 Arm Ltd.
  */
 
+#include <xen/bootfdt.h>
 #include <xen/acpi.h>
 #include <xen/sched.h>
 
xen/include/xen/bootfdt.h +103 -0

123 lines not on this page · raw message

xen/include/xen/device_tree.h +0 -78

116 lines not on this page · raw message

Signature · 1 line
2.43.0
#6 lore raw

PATCH v8 5/11 xen/dt: Move bootinfo functions to a new bootinfo.h

In reply to Alejandro Vallejo

Part of an unpicking process to extract bootfdt contents independent of bootinfo to a separate file for x86 to take.

With this, bootfdt.h can be cleanly included from x86. A later patch extracts the definitions so the functions may be called too.

Not a functional change.

---
 xen/arch/arm/domain_build.c             |   1 +
 xen/arch/arm/include/asm/setup.h        |   2 +-
 xen/arch/arm/setup.c                    |   1 +
 xen/arch/riscv/mm.c                     |   2 +-
 xen/arch/riscv/setup.c                  |   2 +-
 xen/common/device-tree/bootfdt.c        |   2 +-
 xen/common/device-tree/bootinfo.c       |   2 +-
 xen/common/device-tree/dom0less-build.c |   2 +-
 xen/common/device-tree/domain-build.c   |   2 +-
 xen/common/device-tree/kernel.c         |   2 +-
 xen/include/xen/bootfdt.h               | 207 -----------------------
 xen/include/xen/bootinfo.h              | 213 ++++++++++++++++++++++++
 xen/include/xen/fdt-domain-build.h      |   2 +-
 xen/include/xen/fdt-kernel.h            |   2 +-
 14 files changed, 225 insertions(+), 217 deletions(-)
 create mode 100644 xen/include/xen/bootinfo.h
xen/arch/arm/domain_build.c +1 -0
index 5f81d060dd..d91a71acfd 100644
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 #include <xen/init.h>
+#include <xen/bootinfo.h>
 #include <xen/compile.h>
 #include <xen/fdt-domain-build.h>
 #include <xen/fdt-kernel.h>
xen/arch/arm/include/asm/setup.h +1 -1
index b199d92a42..1eaf13bd66 100644
@@ -3,7 +3,7 @@
 
 #include <public/version.h>
 #include <asm/p2m.h>
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 
 #if defined(CONFIG_MMU)
xen/arch/arm/setup.c +1 -0
index 12b76a0a98..8abc1d641d 100644
@@ -8,6 +8,7 @@
  * Copyright (c) 2011 Citrix Systems.
  */
 
+#include <xen/bootinfo.h>
 #include <xen/compile.h>
 #include <xen/device_tree.h>
 #include <xen/domain_page.h>
xen/arch/riscv/mm.c +1 -1
index 774ea42f2d..1ef015f179 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/bug.h>
 #include <xen/compiler.h>
 #include <xen/domain_page.h>
xen/arch/riscv/setup.c +1 -1
index a17096bf02..483cdd7e17 100644
@@ -2,7 +2,7 @@
 
 #include <xen/acpi.h>
 #include <xen/bug.h>
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/compile.h>
 #include <xen/console.h>
 #include <xen/device_tree.h>
xen/common/device-tree/bootfdt.c +1 -1
index 48ecbfd600..8ed8e06872 100644
@@ -5,7 +5,7 @@
  * Copyright (C) 2012-2014 Citrix Systems, Inc.
  */
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 #include <xen/efi.h>
 #include <xen/init.h>
xen/common/device-tree/bootinfo.c +1 -1
index eb1b2b729d..c637c45ad5 100644
@@ -10,7 +10,7 @@
  */
 
 #include <xen/acpi.h>
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/bug.h>
 #include <xen/device_tree.h>
 #include <xen/init.h>
xen/common/device-tree/dom0less-build.c +1 -1
index 15b3c4b241..efa846da2a 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 #include <xen/domain.h>
 #include <xen/domain_page.h>
xen/common/device-tree/domain-build.c +1 -1
index 2fdea6624a..95b383e00f 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/fdt-domain-build.h>
 #include <xen/init.h>
 #include <xen/lib.h>
xen/common/device-tree/kernel.c +1 -1
index 6de2334dbe..ef393182b6 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 #include <xen/fdt-kernel.h>
 #include <xen/errno.h>
xen/include/xen/bootfdt.h +0 -207

236 lines not on this page · raw message

xen/include/xen/bootinfo.h new file +213 -0

213 lines not on this page · raw message

xen/include/xen/fdt-domain-build.h +1 -1
index 3a20623cf5..886a853816 100644
@@ -3,7 +3,7 @@
 #ifndef __XEN_FDT_DOMAIN_BUILD_H__
 #define __XEN_FDT_DOMAIN_BUILD_H__
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 #include <xen/fdt-kernel.h>
 #include <xen/mm.h>
xen/include/xen/fdt-kernel.h +1 -1
index 8363865282..33a60597bb 100644
@@ -7,7 +7,7 @@
 #ifndef __XEN_FDT_KERNEL_H__
 #define __XEN_FDT_KERNEL_H__
 
-#include <xen/bootfdt.h>
+#include <xen/bootinfo.h>
 #include <xen/device_tree.h>
 #include <xen/types.h>
 
Signature · 1 line
2.43.0
#7 lore raw

PATCH v8 6/11 xen/dt: Rename bootfdt.c -> bootinfo-fdt.c

In reply to Alejandro Vallejo

bootinfo-fdt.c will eventually contain bootfdt helpers that make heavy use of bootinfo. To simplify git history do the rename here explicitly. A later patch extracts bootinfo-independent helpers into bootfdt.c.

Doing so here would needlessly pollute the diffs.

Not a functional change.

---
 xen/common/device-tree/Makefile                      | 2 +-
 xen/common/device-tree/{bootfdt.c => bootinfo-fdt.c} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename xen/common/device-tree/{bootfdt.c => bootinfo-fdt.c} (100%)
xen/common/device-tree/Makefile +1 -1
index 13127296cb..8a3f2be89e 100644
@@ -1,4 +1,4 @@
-obj-y += bootfdt.init.o
+obj-y += bootinfo-fdt.init.o
 obj-y += bootinfo.init.o
 obj-y += device-tree.o
 obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.init.o
xen/common/device-tree/bootinfo-fdt.c renamed from xen/common/device-tree/bootfdt.c +0 -0
similarity index 100%
rename from xen/common/device-tree/bootfdt.c
rename to xen/common/device-tree/bootinfo-fdt.c
Signature · 1 line
2.43.0
#8 lore raw

PATCH v8 7/11 xen/dt: Extract bootinfo-independent functions to bootfdt.c

In reply to Alejandro Vallejo

Move all functions independent of "struct bootinfo" back to bootfdt.c

Not a functional change.

---
 xen/common/device-tree/Makefile       |  1 +
 xen/common/device-tree/bootfdt.c      | 99 +++++++++++++++++++++++++++
 xen/common/device-tree/bootinfo-fdt.c | 94 +------------------------
 3 files changed, 101 insertions(+), 93 deletions(-)
 create mode 100644 xen/common/device-tree/bootfdt.c
xen/common/device-tree/Makefile +1 -0
index 8a3f2be89e..8abc069c4b 100644
@@ -1,3 +1,4 @@
+obj-y += bootfdt.init.o
 obj-y += bootinfo-fdt.init.o
 obj-y += bootinfo.init.o
 obj-y += device-tree.o
xen/common/device-tree/bootfdt.c new file +99 -0

99 lines not on this page · raw message

xen/common/device-tree/bootinfo-fdt.c +1 -93

111 lines not on this page · raw message

Signature · 1 line
2.43.0
#9 lore raw

PATCH v8 8/11 xen/dt: Extract helper to map nodes to module kinds

In reply to Alejandro Vallejo

This will be required later by x86 code in order to do early identification of boot modules when booting off a DTB.

Not a functional change.

---
 xen/common/device-tree/bootfdt.c      | 18 ++++++++++++++++++
 xen/common/device-tree/bootinfo-fdt.c | 16 +---------------
 xen/include/xen/bootfdt.h             |  7 +++++++
 3 files changed, 26 insertions(+), 15 deletions(-)
xen/common/device-tree/bootfdt.c +18 -0
index 84520eed30..7c790b9a4d 100644
@@ -5,6 +5,24 @@
 #include <xen/libfdt/libfdt.h>
 #include <xen/unaligned.h>
 
+boot_module_kind __init fdt_node_to_kind(const void *fdt, int node)
+{
+    if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
+         fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
+        return BOOTMOD_KERNEL;
+    if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") == 0 ||
+         fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
+        return BOOTMOD_RAMDISK;
+    if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
+        return BOOTMOD_XSM_POLICY;
+    if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") == 0 )
+        return BOOTMOD_GUEST_DTB;
+    if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") == 0 )
+        return BOOTMOD_MICROCODE;
+
+    return BOOTMOD_UNKNOWN;
+}
+
 void __init device_tree_get_reg(const __be32 **cell, uint32_t address_cells,
                                 uint32_t size_cells, paddr_t *start,
                                 paddr_t *size)
xen/common/device-tree/bootinfo-fdt.c +1 -15
index 5111fc9436..2aa94b91a4 100644
@@ -237,21 +237,7 @@ static void __init process_multiboot_node(const void *fdt, int node,
 
     cell = (const __be32 *)prop->data;
     device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
-
-    if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
-         fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
-        kind = BOOTMOD_KERNEL;
-    else if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") == 0 ||
-              fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
-        kind = BOOTMOD_RAMDISK;
-    else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
-        kind = BOOTMOD_XSM_POLICY;
-    else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") == 0 )
-        kind = BOOTMOD_GUEST_DTB;
-    else if ( fdt_node_check_compatible(fdt, node, "multiboot,microcode") == 0 )
-        kind = BOOTMOD_MICROCODE;
-    else
-        kind = BOOTMOD_UNKNOWN;
+    kind = fdt_node_to_kind(fdt, node);
 
     /**
      * Guess the kind of these first two unknowns respectively:
xen/include/xen/bootfdt.h +7 -0
index 5719bbfb93..6cf05b5cdd 100644
@@ -157,4 +157,11 @@ u32 device_tree_get_u32(const void *fdt, int node,
 void device_tree_get_reg(const __be32 **cell, uint32_t address_cells,
                          uint32_t size_cells, paddr_t *start, paddr_t *size);
 
+/*
+ * Probe an FDT node thought to be a boot module to identify its kind.
+ *
+ * If correctly identified, returns the detected kind, otherwise BOOTMOD_UNKNOWN
+ */
+boot_module_kind fdt_node_to_kind(const void *fdt, int node);
+
 #endif /* XEN_BOOTFDT_H */
Signature · 1 line
2.43.0
#10 lore raw

PATCH v8 9/11 xen: Split HAS_DEVICE_TREE in two

In reply to Alejandro Vallejo

Moving forward the idea is for there to be:

1. Basic DT support: used by dom0less/hyperlaunch.
2. Full DT support: used for device discovery and HW setup.

Rename HAS_DEVICE_TREE to HAS_DEVICE_TREE_DISCOVERY to describe (2) and create a new DEVICE_TREE_PARSE to describe (1).

Have DEVICE_TREE_PARSE selected by both HAS_DEVICE_TREE_DISCOVERY and DOM0LESS_BOOT.

Add a dependency on STATIC_MEMORY for discovery, as it relies on the memory map itself being described on the DTB.

---
 xen/Kconfig.debug                |  2 +-
 xen/arch/arm/Kconfig             |  2 +-
 xen/arch/ppc/Kconfig             |  2 +-
 xen/arch/riscv/Kconfig           |  2 +-
 xen/common/Kconfig               | 15 ++++++++++-----
 xen/common/Makefile              |  4 ++--
 xen/common/device.c              |  4 ++--
 xen/common/efi/boot.c            |  2 +-
 xen/common/sched/Kconfig         |  2 +-
 xen/drivers/char/ns16550.c       |  6 +++---
 xen/drivers/passthrough/Makefile |  2 +-
 xen/drivers/passthrough/iommu.c  |  2 +-
 xen/include/asm-generic/device.h | 10 +++++-----
 xen/include/xen/iommu.h          |  8 ++++----
 xen/include/xsm/dummy.h          |  4 ++--
 xen/include/xsm/xsm.h            | 12 ++++++------
 xen/xsm/dummy.c                  |  2 +-
 xen/xsm/flask/hooks.c            |  6 +++---
 xen/xsm/xsm_core.c               |  4 ++--
 xen/xsm/xsm_policy.c             |  4 ++--
 20 files changed, 50 insertions(+), 45 deletions(-)
xen/Kconfig.debug +1 -1
index 38a134fa3b..d900d926c5 100644
@@ -92,7 +92,7 @@ config VERBOSE_DEBUG
 
 config DEVICE_TREE_DEBUG
 	bool "Device tree debug messages"
-	depends on HAS_DEVICE_TREE
+	depends on DEVICE_TREE_PARSE
 	help
 	  Device tree parsing and DOM0 device tree building messages are
 	  logged in the Xen ring buffer.
xen/arch/arm/Kconfig +1 -1
index bf6d1cf88e..17df147b25 100644
@@ -17,7 +17,7 @@ config ARM
 	select FUNCTION_ALIGNMENT_4B
 	select GENERIC_UART_INIT
 	select HAS_ALTERNATIVE if HAS_VMAP
-	select HAS_DEVICE_TREE
+	select HAS_DEVICE_TREE_DISCOVERY
 	select HAS_DOM0LESS
 	select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE
 	select HAS_STACK_PROTECTOR
xen/arch/ppc/Kconfig +1 -1
index 917f5d53a6..5bedf6055e 100644
@@ -1,7 +1,7 @@
 config PPC
 	def_bool y
 	select FUNCTION_ALIGNMENT_4B
-	select HAS_DEVICE_TREE
+	select HAS_DEVICE_TREE_DISCOVERY
 	select HAS_UBSAN
 	select HAS_VMAP
 
xen/arch/riscv/Kconfig +1 -1
index 96bef90751..89876b3217 100644
@@ -3,7 +3,7 @@ config RISCV
 	select FUNCTION_ALIGNMENT_16B
 	select GENERIC_BUG_FRAME
 	select GENERIC_UART_INIT
-	select HAS_DEVICE_TREE
+	select HAS_DEVICE_TREE_DISCOVERY
 	select HAS_PMAP
 	select HAS_UBSAN
 	select HAS_VMAP
xen/common/Kconfig +10 -5
index 64865112a1..2539a635f1 100644
@@ -12,9 +12,14 @@ config CORE_PARKING
 	bool
 	depends on NR_CPUS > 1
 
+config DEVICE_TREE_PARSE
+	bool
+	select LIBFDT
+
 config DOM0LESS_BOOT
 	bool "Dom0less boot support" if EXPERT
-	depends on HAS_DOM0LESS && HAS_DEVICE_TREE && DOMAIN_BUILD_HELPERS
+	depends on HAS_DOM0LESS && DOMAIN_BUILD_HELPERS
+	select DEVICE_TREE_PARSE
 	default y
 	help
 	  Dom0less boot support enables Xen to create and start domU guests during
@@ -85,9 +90,9 @@ config HAS_ALTERNATIVE
 config HAS_COMPAT
 	bool
 
-config HAS_DEVICE_TREE
+config HAS_DEVICE_TREE_DISCOVERY
 	bool
-	select LIBFDT
+	select DEVICE_TREE_PARSE
 
 config HAS_DOM0LESS
 	bool
@@ -154,7 +159,7 @@ config NUMA
 
 config STATIC_MEMORY
 	bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED
-	depends on DOM0LESS_BOOT
+	depends on DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY
 	help
 	  Static Allocation refers to system or sub-system(domains) for
 	  which memory areas are pre-defined by configuration using physical
@@ -553,7 +558,7 @@ config DOM0_MEM
 
 config DTB_FILE
 	string "Absolute path to device tree blob"
-	depends on HAS_DEVICE_TREE
+	depends on HAS_DEVICE_TREE_DISCOVERY
 	help
 	  When using a bootloader that has no device tree support or when there
 	  is no bootloader at all, use this option to specify the absolute path
xen/common/Makefile +2 -2
index 15ab048244..c6e8a36cd8 100644
@@ -6,9 +6,9 @@ obj-$(CONFIG_HYPFS_CONFIG) += config_data.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
 obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o
-obj-$(CONFIG_HAS_DEVICE_TREE) += device.o
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device.o
 obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o
-obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device-tree/
 obj-$(CONFIG_IOREQ_SERVER) += dm.o
 obj-y += domain.o
 obj-y += event_2l.o
xen/common/device.c +2 -2
index 33e0d58f2f..0c0afad49f 100644
@@ -11,7 +11,7 @@
 
 #include <asm/device.h>
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 
 extern const struct device_desc _sdevice[], _edevice[];
 
@@ -56,7 +56,7 @@ enum device_class device_get_class(const struct dt_device_node *dev)
     return DEVICE_UNKNOWN;
 }
 
-#endif
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 
 #ifdef CONFIG_ACPI
 
xen/common/efi/boot.c +1 -1
index 1019de6950..df29444220 100644
@@ -623,7 +623,7 @@ static int __init __maybe_unused set_color(uint32_t mask, int bpp,
    return max(*pos + *sz, bpp);
 }
 
-#ifndef CONFIG_HAS_DEVICE_TREE
+#ifndef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 static int __init efi_check_dt_boot(const EFI_LOADED_IMAGE *loaded_image)
 {
     return 0;
xen/common/sched/Kconfig +1 -1
index 18ca1ce7ab..1fb622e6cf 100644
@@ -67,7 +67,7 @@ endmenu
 
 config BOOT_TIME_CPUPOOLS
 	bool "Create cpupools at boot time"
-	depends on HAS_DEVICE_TREE
+	depends on HAS_DEVICE_TREE_DISCOVERY
 	help
 	  Creates cpupools during boot time and assigns cpus to them. Cpupools
 	  options can be specified in the device tree.
xen/drivers/char/ns16550.c +3 -3
index 6b4fb4ad31..c1c08b235e 100644
@@ -34,7 +34,7 @@
 #include <xen/8250-uart.h>
 #include <xen/vmap.h>
 #include <asm/io.h>
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 #include <asm/device.h>
 #endif
 #ifdef CONFIG_X86
@@ -1766,7 +1766,7 @@ void __init ns16550_init(int index, struct ns16550_defaults *defaults)
 
 #endif /* CONFIG_X86 */
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 static int __init ns16550_uart_dt_init(struct dt_device_node *dev,
                                        const void *data)
 {
@@ -1845,7 +1845,7 @@ DT_DEVICE_START(ns16550, "NS16550 UART", DEVICE_SERIAL)
         .init = ns16550_uart_dt_init,
 DT_DEVICE_END
 
-#endif /* HAS_DEVICE_TREE */
+#endif /* HAS_DEVICE_TREE_DISCOVERY */
 
 #if defined(CONFIG_ACPI) && defined(CONFIG_ARM)
 #include <xen/acpi.h>
xen/drivers/passthrough/Makefile +1 -1
index a1621540b7..eb4aeafb42 100644
@@ -5,6 +5,6 @@ obj-$(CONFIG_ARM) += arm/
 
 obj-y += iommu.o
 obj-$(CONFIG_HAS_PCI) += pci.o
-obj-$(CONFIG_HAS_DEVICE_TREE) += device_tree.o
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device_tree.o
 obj-$(CONFIG_HAS_PCI) += ats.o
 obj-$(CONFIG_HAS_PCI_MSI) += msi.o
xen/drivers/passthrough/iommu.c +1 -1
index 16aad86973..c9425d6971 100644
@@ -638,7 +638,7 @@ int iommu_do_domctl(
     ret = iommu_do_pci_domctl(domctl, d, u_domctl);
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     if ( ret == -ENODEV )
         ret = iommu_do_dt_domctl(domctl, d, u_domctl);
 #endif
xen/include/asm-generic/device.h +5 -5
index 1acd1ba1d8..3bd97e33c5 100644
@@ -6,7 +6,7 @@
 
 enum device_type
 {
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     DEV_DT,
 #endif
     DEV_PCI
@@ -26,7 +26,7 @@ enum device_class
 struct device
 {
     enum device_type type;
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     struct dt_device_node *of_node; /* Used by drivers imported from Linux */
 #endif
 #ifdef CONFIG_HAS_PASSTHROUGH
@@ -37,7 +37,7 @@ struct device
 
 typedef struct device device_t;
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 
 #include <xen/device_tree.h>
 
@@ -87,9 +87,9 @@ struct device_desc {
     int (*init)(struct dt_device_node *dev, const void *data);
 };
 
-#else /* !CONFIG_HAS_DEVICE_TREE */
+#else /* !CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 #define dev_is_dt(dev) ((void)(dev), false)
-#endif /* CONFIG_HAS_DEVICE_TREE */
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 
 #define dev_is_pci(dev) ((dev)->type == DEV_PCI)
 
xen/include/xen/iommu.h +4 -4
index 57f338e2a0..37c4a1dc82 100644
@@ -232,7 +232,7 @@ struct msi_msg;
 #define PT_IRQ_TIME_OUT MILLISECS(8)
 #endif /* HAS_PCI */
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 #include <xen/device_tree.h>
 
 #ifdef CONFIG_HAS_PASSTHROUGH
@@ -309,7 +309,7 @@ static inline int iommu_add_dt_pci_sideband_ids(struct pci_dev *pdev)
 
 #endif /* HAS_PASSTHROUGH */
 
-#endif /* HAS_DEVICE_TREE */
+#endif /* HAS_DEVICE_TREE_DISCOVERY */
 
 struct page_info;
 
@@ -376,7 +376,7 @@ struct iommu_ops {
     int (*get_reserved_device_memory)(iommu_grdm_t *func, void *ctxt);
     void (*dump_page_tables)(struct domain *d);
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     /*
      * All IOMMU drivers which support generic IOMMU DT bindings should use
      * this callback. This is a way for the framework to provide the driver
@@ -424,7 +424,7 @@ struct domain_iommu {
     /* iommu_ops */
     const struct iommu_ops *platform_ops;
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     /* List of DT devices assigned to this domain */
     struct list_head dt_devices;
 #endif
xen/include/xsm/dummy.h +2 -2
index 9227205fcd..12792c3a43 100644
@@ -423,7 +423,7 @@ static XSM_INLINE int cf_check xsm_deassign_device(
 
 #endif /* HAS_PASSTHROUGH && HAS_PCI */
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
 static XSM_INLINE int cf_check xsm_assign_dtdevice(
     XSM_DEFAULT_ARG struct domain *d, const char *dtpath)
 {
@@ -438,7 +438,7 @@ static XSM_INLINE int cf_check xsm_deassign_dtdevice(
     return xsm_default_action(action, current->domain, d);
 }
 
-#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */
+#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */
 
 static XSM_INLINE int cf_check xsm_resource_plug_core(XSM_DEFAULT_VOID)
 {
xen/include/xsm/xsm.h +6 -6
index 6e1789c314..9a23d2827c 100644
@@ -127,7 +127,7 @@ struct xsm_ops {
     int (*deassign_device)(struct domain *d, uint32_t machine_bdf);
 #endif
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
     int (*assign_dtdevice)(struct domain *d, const char *dtpath);
     int (*deassign_dtdevice)(struct domain *d, const char *dtpath);
 #endif
@@ -549,7 +549,7 @@ static inline int xsm_deassign_device(
 }
 #endif /* HAS_PASSTHROUGH && HAS_PCI) */
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
 static inline int xsm_assign_dtdevice(
     xsm_default_t def, struct domain *d, const char *dtpath)
 {
@@ -562,7 +562,7 @@ static inline int xsm_deassign_dtdevice(
     return alternative_call(xsm_ops.deassign_dtdevice, d, dtpath);
 }
 
-#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */
+#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */
 
 static inline int xsm_resource_plug_pci(xsm_default_t def, uint32_t machine_bdf)
 {
@@ -807,7 +807,7 @@ int xsm_multiboot_policy_init(
     struct boot_info *bi, void **policy_buffer, size_t *policy_size);
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 /*
  * Initialize XSM
  *
@@ -857,7 +857,7 @@ static inline int xsm_multiboot_init(struct boot_info *bi)
 }
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 static inline int xsm_dt_init(void)
 {
     return 0;
@@ -867,7 +867,7 @@ static inline bool has_xsm_magic(paddr_t start)
 {
     return false;
 }
-#endif /* CONFIG_HAS_DEVICE_TREE */
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 
 #endif /* CONFIG_XSM */
 
xen/xsm/dummy.c +1 -1
index 8d44f5bfb6..8b7e01b506 100644
@@ -85,7 +85,7 @@ static const struct xsm_ops __initconst_cf_clobber dummy_ops = {
     .deassign_device               = xsm_deassign_device,
 #endif
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
     .assign_dtdevice               = xsm_assign_dtdevice,
     .deassign_dtdevice             = xsm_deassign_dtdevice,
 #endif
xen/xsm/flask/hooks.c +3 -3
index a7cb33a718..b0308e1b26 100644
@@ -1464,7 +1464,7 @@ static int cf_check flask_deassign_device(
 }
 #endif /* HAS_PASSTHROUGH && HAS_PCI */
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
 static int flask_test_assign_dtdevice(const char *dtpath)
 {
     uint32_t rsid;
@@ -1525,7 +1525,7 @@ static int cf_check flask_deassign_dtdevice(
     return avc_current_has_perm(rsid, SECCLASS_RESOURCE, RESOURCE__REMOVE_DEVICE,
                                 NULL);
 }
-#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE */
+#endif /* HAS_PASSTHROUGH && HAS_DEVICE_TREE_DISCOVERY */
 
 static int cf_check flask_platform_op(uint32_t op)
 {
@@ -1995,7 +1995,7 @@ static const struct xsm_ops __initconst_cf_clobber flask_ops = {
     .deassign_device = flask_deassign_device,
 #endif
 
-#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE)
+#if defined(CONFIG_HAS_PASSTHROUGH) && defined(CONFIG_HAS_DEVICE_TREE_DISCOVERY)
     .assign_dtdevice = flask_assign_dtdevice,
     .deassign_dtdevice = flask_deassign_dtdevice,
 #endif
xen/xsm/xsm_core.c +2 -2
index f255fb63bf..b7e864a874 100644
@@ -25,7 +25,7 @@
 #include <asm/setup.h>
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 #include <asm/setup.h>
 #endif
 
@@ -166,7 +166,7 @@ int __init xsm_multiboot_init(struct boot_info *bi)
 }
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 int __init xsm_dt_init(void)
 {
     int ret = 0;
xen/xsm/xsm_policy.c +2 -2
index 27bfc3b995..cb4f54b542 100644
@@ -24,7 +24,7 @@
 #include <asm/setup.h>
 #endif
 #include <xen/bitops.h>
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 # include <asm/setup.h>
 # include <xen/device_tree.h>
 #endif
@@ -65,7 +65,7 @@ int __init xsm_multiboot_policy_init(
 }
 #endif
 
-#ifdef CONFIG_HAS_DEVICE_TREE
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 int __init xsm_dt_policy_init(void **policy_buffer, size_t *policy_size)
 {
     struct boot_module *mod = boot_module_find_by_kind(BOOTMOD_XSM_POLICY);
Signature · 1 line
2.43.0
#11 lore raw

PATCH v8 10/11 xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h}

In reply to Alejandro Vallejo

Architectures that don't discover devices via DT may skip anything to do with device_t during the DT unflattening phase. Make device-tree.c stop requiring CONFIG_HAS_DEVICE_TREE_DISCOVERY so it may function with CONFIG_DEVICE_TREE_PARSE alone.

This allows CONFIG_DEVICE_TREE_PARSE to unflatten a DT ignoring its devices if CONFIG_HAS_DEVICE_TREE_DISCOVERY is not selected.

---
 xen/common/device-tree/device-tree.c | 2 ++
 xen/include/xen/device_tree.h        | 4 ++++
 2 files changed, 6 insertions(+)
xen/common/device-tree/device-tree.c +2 -0
index 4ebdb2e52e..84daa3f0ed 100644
@@ -2030,9 +2030,11 @@ static unsigned long unflatten_dt_node(const void *fdt,
             ((char *)pp->value)[sz - 1] = 0;
             dt_dprintk("fixed up name for %s -> %s\n", pathp,
                        (char *)pp->value);
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
             /* Generic device initialization */
             np->dev.type = DEV_DT;
             np->dev.of_node = np;
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
         }
     }
     if ( allnextpp )
xen/include/xen/device_tree.h +4 -0
index 8a39a60c54..06d7643622 100644
@@ -108,9 +108,12 @@ struct dt_device_node {
      */
     struct list_head domain_list;
 
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
     struct device dev;
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 };
 
+#ifdef CONFIG_HAS_DEVICE_TREE_DISCOVERY
 #define dt_to_dev(dt_node)  (&(dt_node)->dev)
 
 static inline struct dt_device_node *dev_to_dt(struct device *dev)
@@ -119,6 +122,7 @@ static inline struct dt_device_node *dev_to_dt(struct device *dev)
 
     return container_of(dev, struct dt_device_node, dev);
 }
+#endif /* CONFIG_HAS_DEVICE_TREE_DISCOVERY */
 
 #define MAX_PHANDLE_ARGS 16
 struct dt_phandle_args {
Signature · 1 line
2.43.0
#12 lore raw

PATCH v8 11/11 xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/

In reply to Alejandro Vallejo

This allows bootfdt.c and device-tree.c to be usable without CONFIG_HAS_DEVICE_TREE_DISCOVERY.

Gate everything else on CONFIG_HAS_DEVICE_TREE_DISCOVERY.

---
v8:
* Remove duplicate obj-y introduced in v7

---
 xen/common/Makefile             | 2 +-
 xen/common/device-tree/Makefile | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
xen/common/Makefile +1 -1
index c6e8a36cd8..8dce771970 100644
@@ -8,7 +8,7 @@ obj-y += cpu.o
 obj-$(CONFIG_DEBUG_TRACE) += debugtrace.o
 obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device.o
 obj-$(filter-out $(CONFIG_X86),$(CONFIG_ACPI)) += device.o
-obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += device-tree/
+obj-$(CONFIG_DEVICE_TREE_PARSE) += device-tree/
 obj-$(CONFIG_IOREQ_SERVER) += dm.o
 obj-y += domain.o
 obj-y += event_2l.o
xen/common/device-tree/Makefile +3 -3
index 8abc069c4b..e399242cdf 100644
@@ -1,11 +1,11 @@
 obj-y += bootfdt.init.o
-obj-y += bootinfo-fdt.init.o
-obj-y += bootinfo.init.o
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += bootinfo-fdt.init.o
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += bootinfo.init.o
 obj-y += device-tree.o
 obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += domain-build.init.o
 obj-$(CONFIG_DOM0LESS_BOOT) += dom0less-build.init.o
 obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o
-obj-y += intc.o
+obj-$(CONFIG_HAS_DEVICE_TREE_DISCOVERY) += intc.o
 obj-$(CONFIG_DOMAIN_BUILD_HELPERS) += kernel.o
 obj-$(CONFIG_STATIC_EVTCHN) += static-evtchn.init.o
 obj-$(CONFIG_STATIC_MEMORY) += static-memory.init.o
Signature · 1 line
2.43.0
#14 lore raw
In reply to Alejandro Vallejo
Quoted 19 lines · Alejandro Vallejo

Hi,

Really minor changes wrt v7

1. s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/
2. Remove stale obj-y statements in the last patch

pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1940366600

v7: https://lore.kernel.org/xen-devel/[email protected]>
v6: https://lore.kernel.org/xen-devel/[email protected]/
v5: https://lore.kernel.org/xen-devel/[email protected]/
v4: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v2: https://lore.kernel.org/xen-devel/[email protected]/
v1: https://lore.kernel.org/xen-devel/[email protected]/

Quoted 12 lines

Alejandro Vallejo (11):
x86: Replace arch-specific boot_module with common one
xen: Refactor kernel_info to have a header like boot_domain
x86: Replace arch-specific boot_domain with the common one xen/dt: Move bootfdt functions to xen/bootfdt.h xen/dt: Move bootinfo functions to a new bootinfo.h xen/dt: Rename bootfdt.c -> bootinfo-fdt.c
xen/dt: Extract bootinfo-independent functions to bootfdt.c xen/dt: Extract helper to map nodes to module kinds
xen: Split HAS_DEVICE_TREE in two
xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/

Pretty clearly, as per the build-each-commit job in CI, there must have been an issue in the middle of the series:

In file included from ./arch/x86/include/asm/bootinfo.h:15,

                 from arch/x86/cpu/microcode/core.c:37:
./arch/x86/include/asm/boot-domain.h:13:8: error: redefinition of 'struct boot_domain'
   13 | struct boot_domain {
      |        ^~~~~~~~~~~
In file included from ./arch/x86/include/asm/bootinfo.h:11:
./include/xen/bootfdt.h:103:8: note: originally defined here
  103 | struct boot_domain {
      |        ^~~~~~~~~~~

and similarly

In file included from ./arch/x86/include/asm/bootinfo.h:15,

                 from arch/x86/pv/dom0_build.c:17:
./arch/x86/include/asm/boot-domain.h:13:8: error: redefinition of 'struct boot_domain'
   13 | struct boot_domain {
      |        ^~~~~~~~~~~
In file included from ./arch/x86/include/asm/bootinfo.h:11:
./include/xen/bootfdt.h:103:8: note: originally defined here
  103 | struct boot_domain {
      |        ^~~~~~~~~~~

Jan

#15 lore raw
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Alejandro Vallejo

Hi,

Really minor changes wrt v7

1. s/BOOTMOD_XSM/BOOTMOD_XSM_POLICY/
2. Remove stale obj-y statements in the last patch

This pipeline turned green on the build each commit job, so...

Quoted 25 lines
Quoted 12 lines

pipeline: https://gitlab.com/xen-project/people/agvallejo/xen/-/pipelines/1940366600

v7: https://lore.kernel.org/xen-devel/[email protected]>
v6: https://lore.kernel.org/xen-devel/[email protected]/
v5: https://lore.kernel.org/xen-devel/[email protected]/
v4: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v3: https://lore.kernel.org/xen-devel/[email protected]/
v2: https://lore.kernel.org/xen-devel/[email protected]/
v1: https://lore.kernel.org/xen-devel/[email protected]/

Quoted 12 lines

Alejandro Vallejo (11):
x86: Replace arch-specific boot_module with common one
xen: Refactor kernel_info to have a header like boot_domain
x86: Replace arch-specific boot_domain with the common one xen/dt: Move bootfdt functions to xen/bootfdt.h xen/dt: Move bootinfo functions to a new bootinfo.h xen/dt: Rename bootfdt.c -> bootinfo-fdt.c
xen/dt: Extract bootinfo-independent functions to bootfdt.c xen/dt: Extract helper to map nodes to module kinds
xen: Split HAS_DEVICE_TREE in two
xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} xen/dt: Allow CONFIG_DEVICE_TREE_PARSE to include device-tree/

Quoted 2 lines

Pretty clearly, as per the build-each-commit job in CI, there must have been an issue in the middle of the series:

... I'm not sure what happened. Let me try to repro locally.

Quoted 23 lines

In file included from ./arch/x86/include/asm/bootinfo.h:15,

                 from arch/x86/cpu/microcode/core.c:37:
./arch/x86/include/asm/boot-domain.h:13:8: error: redefinition of 'struct boot_domain'
   13 | struct boot_domain {
      |        ^~~~~~~~~~~
In file included from ./arch/x86/include/asm/bootinfo.h:11:
./include/xen/bootfdt.h:103:8: note: originally defined here
  103 | struct boot_domain {
      |        ^~~~~~~~~~~

and similarly

In file included from ./arch/x86/include/asm/bootinfo.h:15,

                 from arch/x86/pv/dom0_build.c:17:
./arch/x86/include/asm/boot-domain.h:13:8: error: redefinition of 'struct boot_domain'
   13 | struct boot_domain {
      |        ^~~~~~~~~~~
In file included from ./arch/x86/include/asm/bootinfo.h:11:
./include/xen/bootfdt.h:103:8: note: originally defined here
  103 | struct boot_domain {
      |        ^~~~~~~~~~~
Quoted 1 line

Jan

Cheers,
Alejandro