Skip to contentSkip to conversation

xen/arm: Shrink down Xen on Arm

PATCH Superseded Julien Grall 3 participants 17 messages Jun 5, 2018 – Jul 2, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/7 xen/arm: Remove the variable dom0_11_mapping and open-code the value

In reply to Julien Grall

Dom0 (aka hardware domain on Arm) is always direct mapped. Rather than using a global variable to store a const, directly open-code it or replace the use with is_domain_direct_mapped(...) macros.

This will also help a follow-up patch to move all domain_build.c in init.

---
 xen/arch/arm/domain_build.c  | 4 +---
 xen/include/asm-arm/domain.h | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
xen/arch/arm/domain_build.c +1 -3
index 11cdf05091..3c414c7f73 100644
@@ -28,8 +28,6 @@
 static unsigned int __initdata opt_dom0_max_vcpus;
 integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
-int dom0_11_mapping = 1;
-
 static u64 __initdata dom0_mem;
 
 static int __init parse_dom0_mem(const char *s)
@@ -261,7 +259,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
      * TODO: Implement memory bank allocation when DOM0 is not direct
      * mapped
      */
-    BUG_ON(!dom0_11_mapping);
+    BUG_ON(!is_domain_direct_mapped(d));
 
     printk("Allocating 1:1 mappings totalling %ldMB for dom0:\n",
            /* Don't want format this as PRIpaddr (16 digit hex) */
xen/include/asm-arm/domain.h +2 -2
index 7ba6528a74..280c3951fd 100644
@@ -31,8 +31,8 @@ enum domain_type {
 #define is_64bit_domain(d) (0)
 #endif
 
-extern int dom0_11_mapping;
-#define is_domain_direct_mapped(d) ((d) == hardware_domain && dom0_11_mapping)
+/* The hardware domain has always its memory direct mapped. */
+#define is_domain_direct_mapped(d) ((d) == hardware_domain)
 
 struct vtimer {
         struct vcpu *v;
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw

PATCH 4/7 xen/arm: Drop support for loading ELF Dom0 kernel

In reply to Julien Grall

The code has been around since the beginning of Xen Arm. However, I am not aware of any user and the code is pretty bogus:
1) It is assuming virtual address == physical address.
2) The cache is not cleaned after the Image is loaded but the Image is started with Cache disabled.
3) There are not clear ABI with the guest.

Xen is currently supporting 3 other formats (zImage, Image, U-boot Image) as well as gzip compressed version of each formats. All of them are well documented and widely use.

---
Given the state, I doubt anyone is using the ELF format with Xen on Arm. By dropping this code, it also allows us to remove the built-in libelf (~1.2K lines) from Xen.

---
 xen/arch/arm/kernel.c | 77 ---------------------------------------------------
 xen/arch/arm/kernel.h | 10 +------
 2 files changed, 1 insertion(+), 86 deletions(-)
xen/arch/arm/kernel.c +0 -77
index b29028f7d0..000d9397e1 100644
@@ -421,81 +421,6 @@ static int __init kernel_zimage32_probe(struct kernel_info *info,
     return 0;
 }
 
-static void __init kernel_elf_load(struct kernel_info *info)
-{
-    /*
-     * TODO: can the ELF header be used to find the physical address
-     * to load the image to?  Instead of assuming virt == phys.
-     */
-    info->entry = info->elf.parms.virt_entry;
-
-    place_modules(info,
-                  info->elf.parms.virt_kstart,
-                  info->elf.parms.virt_kend);
-
-    printk("Loading ELF image into guest memory\n");
-    info->elf.elf.dest_base = (void*)(unsigned long)info->elf.parms.virt_kstart;
-    info->elf.elf.dest_size =
-         info->elf.parms.virt_kend - info->elf.parms.virt_kstart;
-
-    elf_load_binary(&info->elf.elf);
-
-    printk("Free temporary kernel buffer\n");
-    free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
-}
-
-static int __init kernel_elf_probe(struct kernel_info *info,
-                                   paddr_t addr, paddr_t size)
-{
-    int rc;
-
-    memset(&info->elf.elf, 0, sizeof(info->elf.elf));
-
-    info->elf.kernel_order = get_order_from_bytes(size);
-    info->elf.kernel_img = alloc_xenheap_pages(info->elf.kernel_order, 0);
-    if ( info->elf.kernel_img == NULL )
-        panic("Cannot allocate temporary buffer for kernel");
-
-    copy_from_paddr(info->elf.kernel_img, addr, size);
-
-    if ( (rc = elf_init(&info->elf.elf, info->elf.kernel_img, size )) != 0 )
-        goto err;
-#ifdef CONFIG_VERBOSE_DEBUG
-    elf_set_verbose(&info->elf.elf);
-#endif
-    elf_parse_binary(&info->elf.elf);
-    if ( (rc = elf_xen_parse(&info->elf.elf, &info->elf.parms)) != 0 )
-        goto err;
-
-#ifdef CONFIG_ARM_64
-    if ( elf_32bit(&info->elf.elf) )
-        info->type = DOMAIN_32BIT;
-    else if ( elf_64bit(&info->elf.elf) )
-        info->type = DOMAIN_64BIT;
-    else
-    {
-        printk("Unknown ELF class\n");
-        rc = -EINVAL;
-        goto err;
-    }
-#endif
-
-    info->load = kernel_elf_load;
-
-    if ( elf_check_broken(&info->elf.elf) )
-        printk("Xen: warning: ELF kernel broken: %s\n",
-               elf_check_broken(&info->elf.elf));
-
-    return 0;
-err:
-    if ( elf_check_broken(&info->elf.elf) )
-        printk("Xen: ELF kernel broken: %s\n",
-               elf_check_broken(&info->elf.elf));
-
-    free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
-    return rc;
-}
-
 int __init kernel_probe(struct kernel_info *info)
 {
     struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
@@ -528,8 +453,6 @@ int __init kernel_probe(struct kernel_info *info)
         rc = kernel_uimage_probe(info, mod->start, mod->size);
     if (rc < 0)
         rc = kernel_zimage32_probe(info, mod->start, mod->size);
-    if (rc < 0)
-        rc = kernel_elf_probe(info, mod->start, mod->size);
 
     return rc;
 }
xen/arch/arm/kernel.h +1 -9
index 6d695097b5..47eacb5ba9 100644
@@ -6,7 +6,6 @@
 #ifndef __ARCH_ARM_KERNEL_H__
 #define __ARCH_ARM_KERNEL_H__
 
-#include <xen/libelf.h>
 #include <xen/device_tree.h>
 #include <asm/setup.h>
 
@@ -45,13 +44,6 @@ struct kernel_info {
 #endif
             paddr_t start; /* 32-bit zImage only */
         } zimage;
-
-        struct {
-            struct elf_binary elf;
-            struct elf_dom_parms parms;
-            unsigned kernel_order;
-            void *kernel_img;
-        } elf;
     };
 };
 
@@ -60,7 +52,7 @@ struct kernel_info {
  *
  * Sets in info:
  *  ->type
- *  ->load hook, and sets loader specific variables ->{zimage,elf}
+ *  ->load hook, and sets loader specific variables ->zimage
  */
 int kernel_probe(struct kernel_info *info);
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#9 lore raw

PATCH 5/7 xen: Don't build libelf for Arm

In reply to Julien Grall

Now that ELF support has been dropped to boot Dom0, no-one is using libelf within the hypervisor.

Introduce a config option to select libelf on x86 and keep unselected for Arm.

---
 xen/arch/x86/Kconfig | 1 +
 xen/common/Kconfig   | 3 +++
 xen/common/Makefile  | 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)
xen/arch/x86/Kconfig +1 -0
index f64fc56739..3d388133ef 100644
@@ -12,6 +12,7 @@ config X86
 	select HAS_CPUFREQ
 	select HAS_EHCI
 	select HAS_EX_TABLE
+	select HAS_ELF
 	select HAS_GDBSX
 	select HAS_IOPORTS
 	select HAS_KEXEC
xen/common/Kconfig +3 -0
index 9043dce937..3cf551c736 100644
@@ -17,6 +17,9 @@ config HAS_ALTERNATIVE
 config HAS_DEVICE_TREE
 	bool
 
+config HAS_ELF
+    bool
+
 config HAS_EX_TABLE
 	bool
 
xen/common/Makefile +1 -1
index 24d4752ccc..3cc808bd83 100644
@@ -78,5 +78,5 @@ obj-$(CONFIG_TMEM) += $(tmem-y)
 subdir-$(CONFIG_COVERAGE) += coverage
 subdir-$(CONFIG_UBSAN) += ubsan
 
-subdir-y += libelf
+subdir-$(CONFIG_HAS_ELF) += libelf
 subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#13 lore raw

PATCH 6/7 xen/libfdt: Put all libfdt in init

In reply to Julien Grall

Libfdt is used for:
- Unflatten the Flatten Device-Tree (FDT) blob
- Create Device-Tree for the Hardware-Domain

Both use are done during the initialization of Xen. So move all the libfdt to init.

Note that the runes was borrowed from libelf Makefile.

---
 xen/common/libfdt/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
xen/common/libfdt/Makefile +9 -1
index 7578fe9c50..d81f54b6b8 100644
@@ -1,5 +1,13 @@
 include Makefile.libfdt
 
-obj-y += $(LIBFDT_OBJS)
+SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
+
+obj-y += libfdt.o
 
 CFLAGS += -I$(BASEDIR)/include/xen/libfdt/
+
+libfdt.o: libfdt-temp.o Makefile
+	$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+
+libfdt-temp.o: $(LIBFDT_OBJS)
+	$(LD) $(LDFLAGS) -r -o $@ $^
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#15 lore raw

PATCH 7/7 xen/arm: setup: Move in init code only used at boot in setup.c

In reply to Julien Grall

Some of the functions implemented in setup.c are only used at boot but not yet marked as such.

---
 xen/arch/arm/setup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/setup.c +5 -5
index 1d6f6bf37e..fe7384fd30 100644
@@ -175,7 +175,7 @@ static void __init processor_id(void)
     check_local_cpu_errata();
 }
 
-void dt_unreserved_regions(paddr_t s, paddr_t e,
+void __init dt_unreserved_regions(paddr_t s, paddr_t e,
                                   void (*cb)(paddr_t, paddr_t), int first)
 {
     int i, nr = fdt_num_mem_rsv(device_tree_flattened);
@@ -201,9 +201,9 @@ void dt_unreserved_regions(paddr_t s, paddr_t e,
     cb(s, e);
 }
 
-struct bootmodule *add_boot_module(bootmodule_kind kind,
-                                   paddr_t start, paddr_t size,
-                                   const char *cmdline)
+struct bootmodule __init *add_boot_module(bootmodule_kind kind,
+                                          paddr_t start, paddr_t size,
+                                         const char *cmdline)
 {
     struct bootmodules *mods = &bootinfo.modules;
     struct bootmodule *mod;
@@ -434,7 +434,7 @@ static paddr_t __init get_xen_paddr(void)
     return paddr;
 }
 
-static void init_pdx(void)
+static void __init init_pdx(void)
 {
     paddr_t bank_start, bank_size, bank_end;
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#0 lore raw

cover xen/arm: Shrink down Xen on Arm

Hi all,

This series remove some unused code from Xen and also move some part under __init if only used during boot.

The major change of this patch is removing support libelf in Xen (see #4 and #5).

Cheers,

Julien Grall (7):
xen/arm: Remove the variable dom0_11_mapping and open-code the value xen/arm: domain_build: Move in init all code/data of domain_build.c xen/arm: kernel: Move in init all the code/data of kernel.c xen/arm: Drop support for loading ELF Dom0 kernel
xen: Don't build libelf for Arm
xen/libfdt: Put all libfdt in init
xen/arm: setup: Move in init code only used at boot in setup.c

 xen/arch/arm/Makefile        |   4 +-
 xen/arch/arm/domain_build.c  | 137 ++++++++++++++++++++++---------------------
 xen/arch/arm/kernel.c        | 103 ++++----------------------------
 xen/arch/arm/kernel.h        |  10 +---
 xen/arch/arm/setup.c         |  10 ++--
 xen/arch/x86/Kconfig         |   1 +
 xen/common/Kconfig           |   3 +
 xen/common/Makefile          |   2 +-
 xen/common/libfdt/Makefile   |  10 +++-
 xen/include/asm-arm/domain.h |   4 +-
 10 files changed, 107 insertions(+), 177 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#3 lore raw

PATCH 2/7 xen/arm: domain_build: Move in init all code/data of domain_build.c

The file domain_build.c only contains code/data used during the initialization. So move everything to init and mark the file as such.

---
 xen/arch/arm/Makefile       |   2 +-
 xen/arch/arm/domain_build.c | 133 +++++++++++++++++++++++---------------------
 2 files changed, 70 insertions(+), 65 deletions(-)
xen/arch/arm/Makefile +1 -1
index a9533b107e..6c4afe27cc 100644
@@ -12,7 +12,7 @@ obj-y += cpufeature.o
 obj-y += decode.o
 obj-y += device.o
 obj-y += domain.o
-obj-y += domain_build.o
+obj-y += domain_build.init.o
 obj-y += domctl.o
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += gic.o
xen/arch/arm/domain_build.c +69 -64

355 lines not on this page · raw message

Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH 3/7 xen/arm: kernel: Move in init all the code/data of kernel.c

In reply to Julien Grall

The file kernel.c only contains code/data used during the initialization. So move everything to init and mark the file as such.

---
 xen/arch/arm/Makefile |  2 +-
 xen/arch/arm/kernel.c | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)
xen/arch/arm/Makefile +1 -1
index 6c4afe27cc..a5bd44e59d 100644
@@ -25,7 +25,7 @@ obj-y += guest_walk.o
 obj-y += hvm.o
 obj-y += io.o
 obj-y += irq.o
-obj-y += kernel.o
+obj-y += kernel.init.o
 obj-$(CONFIG_LIVEPATCH) += livepatch.o
 obj-y += mem_access.o
 obj-y += mm.o
xen/arch/arm/kernel.c +16 -16
index 8fdfd91543..b29028f7d0 100644
@@ -46,7 +46,7 @@ struct minimal_dtb_header {
  * @paddr: source physical address
  * @len: length to copy
  */
-void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
+void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
 {
     void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
 
@@ -68,8 +68,8 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
     clear_fixmap(FIXMAP_MISC);
 }
 
-static void place_modules(struct kernel_info *info,
-                          paddr_t kernbase, paddr_t kernend)
+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 bootmodule *mod = info->initrd_bootmodule;
@@ -122,7 +122,7 @@ static void place_modules(struct kernel_info *info,
     info->initrd_paddr = info->dtb_paddr + dtb_len;
 }
 
-static paddr_t kernel_zimage_place(struct kernel_info *info)
+static paddr_t __init kernel_zimage_place(struct kernel_info *info)
 {
     paddr_t load_addr;
 
@@ -154,7 +154,7 @@ static paddr_t kernel_zimage_place(struct kernel_info *info)
     return load_addr;
 }
 
-static void kernel_zimage_load(struct kernel_info *info)
+static void __init kernel_zimage_load(struct kernel_info *info)
 {
     paddr_t load_addr = kernel_zimage_place(info);
     paddr_t paddr = info->zimage.kernel_addr;
@@ -190,8 +190,8 @@ static void kernel_zimage_load(struct kernel_info *info)
 /*
  * Check if the image is a uImage and setup kernel_info
  */
-static int kernel_uimage_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_uimage_probe(struct kernel_info *info,
+                                      paddr_t addr, paddr_t size)
 {
     struct {
         __be32 magic;   /* Image Header Magic Number */
@@ -318,8 +318,8 @@ static __init int kernel_decompress(struct bootmodule *mod)
 /*
  * Check if the image is a 64-bit Image.
  */
-static int kernel_zimage64_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_zimage64_probe(struct kernel_info *info,
+                                        paddr_t addr, paddr_t size)
 {
     /* linux/Documentation/arm64/booting.txt */
     struct {
@@ -372,8 +372,8 @@ static int kernel_zimage64_probe(struct kernel_info *info,
 /*
  * Check if the image is a 32-bit zImage and setup kernel_info
  */
-static int kernel_zimage32_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_zimage32_probe(struct kernel_info *info,
+                                        paddr_t addr, paddr_t size)
 {
     uint32_t zimage[ZIMAGE32_HEADER_LEN/4];
     uint32_t start, end;
@@ -421,7 +421,7 @@ static int kernel_zimage32_probe(struct kernel_info *info,
     return 0;
 }
 
-static void kernel_elf_load(struct kernel_info *info)
+static void __init kernel_elf_load(struct kernel_info *info)
 {
     /*
      * TODO: can the ELF header be used to find the physical address
@@ -444,8 +444,8 @@ static void kernel_elf_load(struct kernel_info *info)
     free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
 }
 
-static int kernel_elf_probe(struct kernel_info *info,
-                            paddr_t addr, paddr_t size)
+static int __init kernel_elf_probe(struct kernel_info *info,
+                                   paddr_t addr, paddr_t size)
 {
     int rc;
 
@@ -496,7 +496,7 @@ err:
     return rc;
 }
 
-int kernel_probe(struct kernel_info *info)
+int __init kernel_probe(struct kernel_info *info)
 {
     struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
     int rc;
@@ -534,7 +534,7 @@ int kernel_probe(struct kernel_info *info)
     return rc;
 }
 
-void kernel_load(struct kernel_info *info)
+void __init kernel_load(struct kernel_info *info)
 {
     info->load(info);
 }
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#10 lore raw

Re: [PATCH 5/7] xen: Don't build libelf for Arm

In reply to Julien Grall

xen/common/Kconfig config HAS_ALTERNATIVE · line 22

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 05.06.18 at 19:12, <[email protected]> wrote:
xen/common/Kconfig +3 -0
@@ -17,6 +17,9 @@ config HAS_ALTERNATIVE
 config HAS_DEVICE_TREE
 	bool
 
+config HAS_ELF
+    bool
+

HAS_LIBELF (or NEEDS_LIBELF) would seem better to me.

Also please not the difference in indentation between what you add and surrounding code.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] xen/arm: Remove the variable dom0_11_mapping and open-code the value

In reply to Julien Grall
Quoted 8 lines · Julien Grall

Dom0 (aka hardware domain on Arm) is always direct mapped. Rather than using a global variable to store a const, directly open-code it or replace the use with is_domain_direct_mapped(...) macros.

This will also help a follow-up patch to move all domain_build.c in init.

Quoted 45 lines
---
 xen/arch/arm/domain_build.c  | 4 +---
 xen/include/asm-arm/domain.h | 4 ++--
 2 files changed, 3 insertions(+), 5 deletions(-)
xen/arch/arm/domain_build.c +1 -3
index 11cdf05091..3c414c7f73 100644
@@ -28,8 +28,6 @@
 static unsigned int __initdata opt_dom0_max_vcpus;
 integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
-int dom0_11_mapping = 1;
-
 static u64 __initdata dom0_mem;
 
 static int __init parse_dom0_mem(const char *s)
@@ -261,7 +259,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
      * TODO: Implement memory bank allocation when DOM0 is not direct
      * mapped
      */
-    BUG_ON(!dom0_11_mapping);
+    BUG_ON(!is_domain_direct_mapped(d));
 
     printk("Allocating 1:1 mappings totalling %ldMB for dom0:\n",
            /* Don't want format this as PRIpaddr (16 digit hex) */
xen/include/asm-arm/domain.h +2 -2
index 7ba6528a74..280c3951fd 100644
@@ -31,8 +31,8 @@ enum domain_type {
 #define is_64bit_domain(d) (0)
 #endif
 
-extern int dom0_11_mapping;
-#define is_domain_direct_mapped(d) ((d) == hardware_domain && dom0_11_mapping)
+/* The hardware domain has always its memory direct mapped. */
+#define is_domain_direct_mapped(d) ((d) == hardware_domain)
 
 struct vtimer {
         struct vcpu *v;
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] xen/arm: domain_build: Move in init all code/data of domain_build.c

In reply to Julien Grall
Quoted 4 lines · Julien Grall

The file domain_build.c only contains code/data used during the initialization. So move everything to init and mark the file as such.

Quoted 416 lines
---
 xen/arch/arm/Makefile       |   2 +-
 xen/arch/arm/domain_build.c | 133 +++++++++++++++++++++++---------------------
 2 files changed, 70 insertions(+), 65 deletions(-)
xen/arch/arm/Makefile +1 -1
index a9533b107e..6c4afe27cc 100644
@@ -12,7 +12,7 @@ obj-y += cpufeature.o
 obj-y += decode.o
 obj-y += device.o
 obj-y += domain.o
-obj-y += domain_build.o
+obj-y += domain_build.init.o
 obj-y += domctl.o
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += gic.o
xen/arch/arm/domain_build.c +69 -64
index 3c414c7f73..1351572da1 100644
@@ -77,7 +77,7 @@ struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0)
     return alloc_vcpu(dom0, 0, 0);
 }
 
-static unsigned int get_11_allocation_size(paddr_t size)
+static unsigned int __init get_11_allocation_size(paddr_t size)
 {
     /*
      * get_order_from_bytes returns the order greater than or equal to
@@ -95,10 +95,10 @@ static unsigned int get_11_allocation_size(paddr_t size)
  * Returns false if the memory would be below bank 0 or we have run
  * out of banks. In this case it will free the pages.
  */
-static bool insert_11_bank(struct domain *d,
-                           struct kernel_info *kinfo,
-                           struct page_info *pg,
-                           unsigned int order)
+static bool __init insert_11_bank(struct domain *d,
+                                  struct kernel_info *kinfo,
+                                  struct page_info *pg,
+                                  unsigned int order)
 {
     int res, i;
     mfn_t smfn;
@@ -243,7 +243,7 @@ fail:
  * (as described above) we allow higher allocations and continue until
  * that runs out (or we have allocated sufficient dom0 memory).
  */
-static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
+static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo)
 {
     const unsigned int min_low_order =
         get_order_from_bytes(min_t(paddr_t, dom0_mem, MB(128)));
@@ -367,8 +367,8 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo)
     }
 }
 
-static int write_properties(struct domain *d, struct kernel_info *kinfo,
-                            const struct dt_device_node *node)
+static int __init write_properties(struct domain *d, struct kernel_info *kinfo,
+                                   const struct dt_device_node *node)
 {
     const char *bootargs = NULL;
     const struct dt_property *prop, *status = NULL;
@@ -494,8 +494,10 @@ static int write_properties(struct domain *d, struct kernel_info *kinfo,
 
 typedef __be32 gic_interrupt_t[3];
 
-static void set_interrupt_ppi(gic_interrupt_t interrupt, unsigned int irq,
-                              unsigned int cpumask, unsigned int level)
+static void __init set_interrupt_ppi(gic_interrupt_t interrupt,
+                                     unsigned int irq,
+                                     unsigned int cpumask,
+                                     unsigned int level)
 {
     __be32 *cells = interrupt;
 
@@ -514,8 +516,8 @@ static void set_interrupt_ppi(gic_interrupt_t interrupt, unsigned int irq,
  *  "interrupts": contains the list of interrupts
  *  "interrupt-parent": link to the GIC
  */
-static int fdt_property_interrupts(void *fdt, gic_interrupt_t *intr,
-                                   unsigned num_irq)
+static int __init fdt_property_interrupts(void *fdt, gic_interrupt_t *intr,
+                                          unsigned num_irq)
 {
     int res;
 
@@ -529,10 +531,10 @@ static int fdt_property_interrupts(void *fdt, gic_interrupt_t *intr,
     return res;
 }
 
-static int make_memory_node(const struct domain *d,
-                            void *fdt,
-                            const struct dt_device_node *parent,
-                            const struct kernel_info *kinfo)
+static int __init make_memory_node(const struct domain *d,
+                                   void *fdt,
+                                   const struct dt_device_node *parent,
+                                   const struct kernel_info *kinfo)
 {
     int res, i;
     int reg_size = dt_child_n_addr_cells(parent) + dt_child_n_size_cells(parent);
@@ -575,9 +577,9 @@ static int make_memory_node(const struct domain *d,
 
 static void evtchn_allocate(struct domain *d);
 
-static int make_hypervisor_node(struct domain *d,
-                                const struct kernel_info *kinfo,
-                                const struct dt_device_node *parent)
+static int __init make_hypervisor_node(struct domain *d,
+                                       const struct kernel_info *kinfo,
+                                       const struct dt_device_node *parent)
 {
     const char compat[] =
         "xen,xen-"__stringify(XEN_VERSION)"."__stringify(XEN_SUBVERSION)"\0"
@@ -641,7 +643,8 @@ static int make_hypervisor_node(struct domain *d,
     return res;
 }
 
-static int make_psci_node(void *fdt, const struct dt_device_node *parent)
+static int __init make_psci_node(void *fdt,
+                                 const struct dt_device_node *parent)
 {
     int res;
     const char compat[] =
@@ -677,8 +680,8 @@ static int make_psci_node(void *fdt, const struct dt_device_node *parent)
     return res;
 }
 
-static int make_cpus_node(const struct domain *d, void *fdt,
-                          const struct dt_device_node *parent)
+static int __init make_cpus_node(const struct domain *d, void *fdt,
+                                 const struct dt_device_node *parent)
 {
     int res;
     const struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
@@ -791,8 +794,8 @@ static int make_cpus_node(const struct domain *d, void *fdt,
     return res;
 }
 
-static int make_gic_node(const struct domain *d, void *fdt,
-                         const struct dt_device_node *node)
+static int __init make_gic_node(const struct domain *d, void *fdt,
+                                const struct dt_device_node *node)
 {
     const struct dt_device_node *gic = dt_interrupt_controller;
     int res = 0;
@@ -860,8 +863,8 @@ static int make_gic_node(const struct domain *d, void *fdt,
     return res;
 }
 
-static int make_timer_node(const struct domain *d, void *fdt,
-                           const struct dt_device_node *node)
+static int __init make_timer_node(const struct domain *d, void *fdt,
+                                  const struct dt_device_node *node)
 {
     static const struct dt_device_match timer_ids[] __initconst =
     {
@@ -935,9 +938,8 @@ static int make_timer_node(const struct domain *d, void *fdt,
     return res;
 }
 
-static int map_irq_to_domain(struct domain *d, unsigned int irq,
-                             bool need_mapping, const char *devname)
-
+static int __init map_irq_to_domain(struct domain *d, unsigned int irq,
+                                    bool need_mapping, const char *devname)
 {
     int res;
 
@@ -971,9 +973,9 @@ static int map_irq_to_domain(struct domain *d, unsigned int irq,
     return 0;
 }
 
-static int map_dt_irq_to_domain(const struct dt_device_node *dev,
-                                const struct dt_irq *dt_irq,
-                                void *data)
+static int __init map_dt_irq_to_domain(const struct dt_device_node *dev,
+                                       const struct dt_irq *dt_irq,
+                                       void *data)
 {
     struct domain *d = data;
     unsigned int irq = dt_irq->irq;
@@ -1002,9 +1004,9 @@ static int map_dt_irq_to_domain(const struct dt_device_node *dev,
     return 0;
 }
 
-static int map_range_to_domain(const struct dt_device_node *dev,
-                               u64 addr, u64 len,
-                               void *data)
+static int __init map_range_to_domain(const struct dt_device_node *dev,
+                                      u64 addr, u64 len,
+                                      void *data)
 {
     struct map_range_data *mr_data = data;
     struct domain *d = mr_data->d;
@@ -1051,9 +1053,9 @@ static int map_range_to_domain(const struct dt_device_node *dev,
  * then we may need to perform additional mappings in order to make
  * the child resources available to domain 0.
  */
-static int map_device_children(struct domain *d,
-                               const struct dt_device_node *dev,
-                               p2m_type_t p2mt)
+static int __init map_device_children(struct domain *d,
+                                      const struct dt_device_node *dev,
+                                      p2m_type_t p2mt)
 {
     struct map_range_data mr_data = { .d = d, .p2mt = p2mt };
     int ret;
@@ -1083,8 +1085,8 @@ static int map_device_children(struct domain *d,
  *  - Assign the device to the guest if it's protected by an IOMMU
  *  - Map the IRQs and iomem regions to DOM0
  */
-static int handle_device(struct domain *d, struct dt_device_node *dev,
-                         p2m_type_t p2mt)
+static int __init handle_device(struct domain *d, struct dt_device_node *dev,
+                                p2m_type_t p2mt)
 {
     unsigned int nirq;
     unsigned int naddr;
@@ -1171,9 +1173,9 @@ static int handle_device(struct domain *d, struct dt_device_node *dev,
     return 0;
 }
 
-static int handle_node(struct domain *d, struct kernel_info *kinfo,
-                       struct dt_device_node *node,
-                       p2m_type_t p2mt)
+static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
+                              struct dt_device_node *node,
+                              p2m_type_t p2mt)
 {
     static const struct dt_device_match skip_matches[] __initconst =
     {
@@ -1317,7 +1319,7 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo,
     return res;
 }
 
-static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
+static int __init prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 {
     const p2m_type_t default_p2mt = p2m_mmio_direct_c;
     const void *fdt;
@@ -1358,7 +1360,7 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
-static int acpi_iomem_deny_access(struct domain *d)
+static int __init acpi_iomem_deny_access(struct domain *d)
 {
     acpi_status status;
     struct acpi_table_spcr *spcr = NULL;
@@ -1390,7 +1392,7 @@ static int acpi_iomem_deny_access(struct domain *d)
     return gic_iomem_deny_access(d);
 }
 
-static int acpi_route_spis(struct domain *d)
+static int __init acpi_route_spis(struct domain *d)
 {
     int i, res;
     struct irq_desc *desc;
@@ -1418,7 +1420,7 @@ static int acpi_route_spis(struct domain *d)
     return 0;
 }
 
-static int acpi_make_chosen_node(const struct kernel_info *kinfo)
+static int __init acpi_make_chosen_node(const struct kernel_info *kinfo)
 {
     int res;
     const char *bootargs = NULL;
@@ -1459,8 +1461,8 @@ static int acpi_make_chosen_node(const struct kernel_info *kinfo)
     return res;
 }
 
-static int acpi_make_hypervisor_node(const struct kernel_info *kinfo,
-                                     struct membank tbl_add[])
+static int __init acpi_make_hypervisor_node(const struct kernel_info *kinfo,
+                                            struct membank tbl_add[])
 {
     const char compat[] =
         "xen,xen-"__stringify(XEN_VERSION)"."__stringify(XEN_SUBVERSION)"\0"
@@ -1494,7 +1496,8 @@ static int acpi_make_hypervisor_node(const struct kernel_info *kinfo,
  * Prepare a minimal DTB for Dom0 which contains bootargs, initrd, memory
  * information, EFI table.
  */
-static int create_acpi_dtb(struct kernel_info *kinfo, struct membank tbl_add[])
+static int __init create_acpi_dtb(struct kernel_info *kinfo,
+                                  struct membank tbl_add[])
 {
     int new_size;
     int ret;
@@ -1554,7 +1557,7 @@ static int create_acpi_dtb(struct kernel_info *kinfo, struct membank tbl_add[])
     return -EINVAL;
 }
 
-static void acpi_map_other_tables(struct domain *d)
+static void __init acpi_map_other_tables(struct domain *d)
 {
     int i;
     unsigned long res;
@@ -1579,7 +1582,7 @@ static void acpi_map_other_tables(struct domain *d)
     }
 }
 
-static int acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
+static int __init acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
 {
 
     struct acpi_table_rsdp *rsdp = NULL;
@@ -1613,8 +1616,9 @@ static int acpi_create_rsdp(struct domain *d, struct membank tbl_add[])
     return 0;
 }
 
-static void acpi_xsdt_modify_entry(u64 entry[], unsigned long entry_count,
-                                   char *signature, u64 addr)
+static void __init acpi_xsdt_modify_entry(u64 entry[],
+                                          unsigned long entry_count,
+                                          char *signature, u64 addr)
 {
     int i;
     struct acpi_table_header *table;
@@ -1633,7 +1637,7 @@ static void acpi_xsdt_modify_entry(u64 entry[], unsigned long entry_count,
     }
 }
 
-static int acpi_create_xsdt(struct domain *d, struct membank tbl_add[])
+static int __init acpi_create_xsdt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
     struct acpi_table_rsdp *rsdp_tbl;
@@ -1681,7 +1685,7 @@ static int acpi_create_xsdt(struct domain *d, struct membank tbl_add[])
     return 0;
 }
 
-static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
+static int __init acpi_create_stao(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
     struct acpi_table_stao *stao = NULL;
@@ -1718,7 +1722,7 @@ static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
     return 0;
 }
 
-static int acpi_create_madt(struct domain *d, struct membank tbl_add[])
+static int __init acpi_create_madt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
     struct acpi_table_madt *madt = NULL;
@@ -1775,7 +1779,7 @@ static int acpi_create_madt(struct domain *d, struct membank tbl_add[])
     return 0;
 }
 
-static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
+static int __init acpi_create_fadt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
     struct acpi_table_fadt *fadt = NULL;
@@ -1812,7 +1816,8 @@ static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
     return 0;
 }
 
-static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
+static int __init estimate_acpi_efi_size(struct domain *d,
+                                         struct kernel_info *kinfo)
 {
     size_t efi_size, acpi_size, madt_size;
     u64 addr;
@@ -1861,7 +1866,7 @@ static int estimate_acpi_efi_size(struct domain *d, struct kernel_info *kinfo)
     return 0;
 }
 
-static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
+static int __init prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 {
     int rc = 0;
     int order;
@@ -1960,14 +1965,14 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     return 0;
 }
 #else
-static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
+static int __init prepare_acpi(struct domain *d, struct kernel_info *kinfo)
 {
     /* Only booting with ACPI will hit here */
     BUG();
     return -EINVAL;
 }
 #endif
-static void dtb_load(struct kernel_info *kinfo)
+static void __init dtb_load(struct kernel_info *kinfo)
 {
     unsigned long left;
 
@@ -1983,7 +1988,7 @@ static void dtb_load(struct kernel_info *kinfo)
     xfree(kinfo->fdt);
 }
 
-static void initrd_load(struct kernel_info *kinfo)
+static void __init initrd_load(struct kernel_info *kinfo)
 {
     const struct bootmodule *mod = kinfo->initrd_bootmodule;
     paddr_t load_addr = kinfo->initrd_paddr;
@@ -2039,7 +2044,7 @@ static void initrd_load(struct kernel_info *kinfo)
  * Note that this should only be called once all PPIs used by the
  * hardware domain have been registered.
  */
-static void evtchn_allocate(struct domain *d)
+static void __init evtchn_allocate(struct domain *d)
 {
     int res;
     u64 val;
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 3/7
#6 lore raw

Re: [PATCH 3/7] xen/arm: kernel: Move in init all the code/data of kernel.c

In reply to Julien Grall
Quoted 4 lines · Julien Grall

The file kernel.c only contains code/data used during the initialization. So move everything to init and mark the file as such.

Quoted 134 lines
---
 xen/arch/arm/Makefile |  2 +-
 xen/arch/arm/kernel.c | 32 ++++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)
xen/arch/arm/Makefile +1 -1
index 6c4afe27cc..a5bd44e59d 100644
@@ -25,7 +25,7 @@ obj-y += guest_walk.o
 obj-y += hvm.o
 obj-y += io.o
 obj-y += irq.o
-obj-y += kernel.o
+obj-y += kernel.init.o
 obj-$(CONFIG_LIVEPATCH) += livepatch.o
 obj-y += mem_access.o
 obj-y += mm.o
xen/arch/arm/kernel.c +16 -16
index 8fdfd91543..b29028f7d0 100644
@@ -46,7 +46,7 @@ struct minimal_dtb_header {
  * @paddr: source physical address
  * @len: length to copy
  */
-void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
+void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
 {
     void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
 
@@ -68,8 +68,8 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
     clear_fixmap(FIXMAP_MISC);
 }
 
-static void place_modules(struct kernel_info *info,
-                          paddr_t kernbase, paddr_t kernend)
+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 bootmodule *mod = info->initrd_bootmodule;
@@ -122,7 +122,7 @@ static void place_modules(struct kernel_info *info,
     info->initrd_paddr = info->dtb_paddr + dtb_len;
 }
 
-static paddr_t kernel_zimage_place(struct kernel_info *info)
+static paddr_t __init kernel_zimage_place(struct kernel_info *info)
 {
     paddr_t load_addr;
 
@@ -154,7 +154,7 @@ static paddr_t kernel_zimage_place(struct kernel_info *info)
     return load_addr;
 }
 
-static void kernel_zimage_load(struct kernel_info *info)
+static void __init kernel_zimage_load(struct kernel_info *info)
 {
     paddr_t load_addr = kernel_zimage_place(info);
     paddr_t paddr = info->zimage.kernel_addr;
@@ -190,8 +190,8 @@ static void kernel_zimage_load(struct kernel_info *info)
 /*
  * Check if the image is a uImage and setup kernel_info
  */
-static int kernel_uimage_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_uimage_probe(struct kernel_info *info,
+                                      paddr_t addr, paddr_t size)
 {
     struct {
         __be32 magic;   /* Image Header Magic Number */
@@ -318,8 +318,8 @@ static __init int kernel_decompress(struct bootmodule *mod)
 /*
  * Check if the image is a 64-bit Image.
  */
-static int kernel_zimage64_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_zimage64_probe(struct kernel_info *info,
+                                        paddr_t addr, paddr_t size)
 {
     /* linux/Documentation/arm64/booting.txt */
     struct {
@@ -372,8 +372,8 @@ static int kernel_zimage64_probe(struct kernel_info *info,
 /*
  * Check if the image is a 32-bit zImage and setup kernel_info
  */
-static int kernel_zimage32_probe(struct kernel_info *info,
-                                 paddr_t addr, paddr_t size)
+static int __init kernel_zimage32_probe(struct kernel_info *info,
+                                        paddr_t addr, paddr_t size)
 {
     uint32_t zimage[ZIMAGE32_HEADER_LEN/4];
     uint32_t start, end;
@@ -421,7 +421,7 @@ static int kernel_zimage32_probe(struct kernel_info *info,
     return 0;
 }
 
-static void kernel_elf_load(struct kernel_info *info)
+static void __init kernel_elf_load(struct kernel_info *info)
 {
     /*
      * TODO: can the ELF header be used to find the physical address
@@ -444,8 +444,8 @@ static void kernel_elf_load(struct kernel_info *info)
     free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
 }
 
-static int kernel_elf_probe(struct kernel_info *info,
-                            paddr_t addr, paddr_t size)
+static int __init kernel_elf_probe(struct kernel_info *info,
+                                   paddr_t addr, paddr_t size)
 {
     int rc;
 
@@ -496,7 +496,7 @@ err:
     return rc;
 }
 
-int kernel_probe(struct kernel_info *info)
+int __init kernel_probe(struct kernel_info *info)
 {
     struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
     int rc;
@@ -534,7 +534,7 @@ int kernel_probe(struct kernel_info *info)
     return rc;
 }
 
-void kernel_load(struct kernel_info *info)
+void __init kernel_load(struct kernel_info *info)
 {
     info->load(info);
 }
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 4/7
#8 lore raw

Re: [PATCH 4/7] xen/arm: Drop support for loading ELF Dom0 kernel

In reply to Julien Grall
Quoted 7 lines · Julien Grall

The code has been around since the beginning of Xen Arm. However, I am not aware of any user and the code is pretty bogus:
1) It is assuming virtual address == physical address.
2) The cache is not cleaned after the Image is loaded but the Image is started with Cache disabled.
3) There are not clear ABI with the guest.

Quoted 5 lines

Xen is currently supporting 3 other formats (zImage, Image, U-boot Image) as well as gzip compressed version of each formats. All of them are well documented and widely use.

Quoted 142 lines

---
Given the state, I doubt anyone is using the ELF format with Xen on Arm. By dropping this code, it also allows us to remove the built-in libelf (~1.2K lines) from Xen.

---
 xen/arch/arm/kernel.c | 77 ---------------------------------------------------
 xen/arch/arm/kernel.h | 10 +------
 2 files changed, 1 insertion(+), 86 deletions(-)
xen/arch/arm/kernel.c +0 -77
index b29028f7d0..000d9397e1 100644
@@ -421,81 +421,6 @@ static int __init kernel_zimage32_probe(struct kernel_info *info,
     return 0;
 }
 
-static void __init kernel_elf_load(struct kernel_info *info)
-{
-    /*
-     * TODO: can the ELF header be used to find the physical address
-     * to load the image to?  Instead of assuming virt == phys.
-     */
-    info->entry = info->elf.parms.virt_entry;
-
-    place_modules(info,
-                  info->elf.parms.virt_kstart,
-                  info->elf.parms.virt_kend);
-
-    printk("Loading ELF image into guest memory\n");
-    info->elf.elf.dest_base = (void*)(unsigned long)info->elf.parms.virt_kstart;
-    info->elf.elf.dest_size =
-         info->elf.parms.virt_kend - info->elf.parms.virt_kstart;
-
-    elf_load_binary(&info->elf.elf);
-
-    printk("Free temporary kernel buffer\n");
-    free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
-}
-
-static int __init kernel_elf_probe(struct kernel_info *info,
-                                   paddr_t addr, paddr_t size)
-{
-    int rc;
-
-    memset(&info->elf.elf, 0, sizeof(info->elf.elf));
-
-    info->elf.kernel_order = get_order_from_bytes(size);
-    info->elf.kernel_img = alloc_xenheap_pages(info->elf.kernel_order, 0);
-    if ( info->elf.kernel_img == NULL )
-        panic("Cannot allocate temporary buffer for kernel");
-
-    copy_from_paddr(info->elf.kernel_img, addr, size);
-
-    if ( (rc = elf_init(&info->elf.elf, info->elf.kernel_img, size )) != 0 )
-        goto err;
-#ifdef CONFIG_VERBOSE_DEBUG
-    elf_set_verbose(&info->elf.elf);
-#endif
-    elf_parse_binary(&info->elf.elf);
-    if ( (rc = elf_xen_parse(&info->elf.elf, &info->elf.parms)) != 0 )
-        goto err;
-
-#ifdef CONFIG_ARM_64
-    if ( elf_32bit(&info->elf.elf) )
-        info->type = DOMAIN_32BIT;
-    else if ( elf_64bit(&info->elf.elf) )
-        info->type = DOMAIN_64BIT;
-    else
-    {
-        printk("Unknown ELF class\n");
-        rc = -EINVAL;
-        goto err;
-    }
-#endif
-
-    info->load = kernel_elf_load;
-
-    if ( elf_check_broken(&info->elf.elf) )
-        printk("Xen: warning: ELF kernel broken: %s\n",
-               elf_check_broken(&info->elf.elf));
-
-    return 0;
-err:
-    if ( elf_check_broken(&info->elf.elf) )
-        printk("Xen: ELF kernel broken: %s\n",
-               elf_check_broken(&info->elf.elf));
-
-    free_xenheap_pages(info->elf.kernel_img, info->elf.kernel_order);
-    return rc;
-}
-
 int __init kernel_probe(struct kernel_info *info)
 {
     struct bootmodule *mod = boot_module_find_by_kind(BOOTMOD_KERNEL);
@@ -528,8 +453,6 @@ int __init kernel_probe(struct kernel_info *info)
         rc = kernel_uimage_probe(info, mod->start, mod->size);
     if (rc < 0)
         rc = kernel_zimage32_probe(info, mod->start, mod->size);
-    if (rc < 0)
-        rc = kernel_elf_probe(info, mod->start, mod->size);
 
     return rc;
 }
xen/arch/arm/kernel.h +1 -9
index 6d695097b5..47eacb5ba9 100644
@@ -6,7 +6,6 @@
 #ifndef __ARCH_ARM_KERNEL_H__
 #define __ARCH_ARM_KERNEL_H__
 
-#include <xen/libelf.h>
 #include <xen/device_tree.h>
 #include <asm/setup.h>
 
@@ -45,13 +44,6 @@ struct kernel_info {
 #endif
             paddr_t start; /* 32-bit zImage only */
         } zimage;
-
-        struct {
-            struct elf_binary elf;
-            struct elf_dom_parms parms;
-            unsigned kernel_order;
-            void *kernel_img;
-        } elf;
     };
 };
 
@@ -60,7 +52,7 @@ struct kernel_info {
  *
  * Sets in info:
  *  ->type
- *  ->load hook, and sets loader specific variables ->{zimage,elf}
+ *  ->load hook, and sets loader specific variables ->zimage
  */
 int kernel_probe(struct kernel_info *info);
 
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 5/7
#12 lore raw

Re: [PATCH 5/7] xen: Don't build libelf for Arm

In reply to Julien Grall
Quoted 7 lines · Julien Grall

Now that ELF support has been dropped to boot Dom0, no-one is using libelf within the hypervisor.

Introduce a config option to select libelf on x86 and keep unselected for Arm.

Quoted 46 lines
---
 xen/arch/x86/Kconfig | 1 +
 xen/common/Kconfig   | 3 +++
 xen/common/Makefile  | 2 +-
 3 files changed, 5 insertions(+), 1 deletion(-)
xen/arch/x86/Kconfig +1 -0
index f64fc56739..3d388133ef 100644
@@ -12,6 +12,7 @@ config X86
 	select HAS_CPUFREQ
 	select HAS_EHCI
 	select HAS_EX_TABLE
+	select HAS_ELF
 	select HAS_GDBSX
 	select HAS_IOPORTS
 	select HAS_KEXEC
xen/common/Kconfig +3 -0
index 9043dce937..3cf551c736 100644
@@ -17,6 +17,9 @@ config HAS_ALTERNATIVE
 config HAS_DEVICE_TREE
 	bool
 
+config HAS_ELF
+    bool
+
 config HAS_EX_TABLE
 	bool
 
xen/common/Makefile +1 -1
index 24d4752ccc..3cc808bd83 100644
@@ -78,5 +78,5 @@ obj-$(CONFIG_TMEM) += $(tmem-y)
 subdir-$(CONFIG_COVERAGE) += coverage
 subdir-$(CONFIG_UBSAN) += ubsan
 
-subdir-y += libelf
+subdir-$(CONFIG_HAS_ELF) += libelf
 subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 7/7
#16 lore raw

Re: [PATCH 7/7] xen/arm: setup: Move in init code only used at boot in setup.c

In reply to Julien Grall
Quoted 4 lines · Julien Grall

Some of the functions implemented in setup.c are only used at boot but not yet marked as such.

Quoted 42 lines
---
 xen/arch/arm/setup.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
xen/arch/arm/setup.c +5 -5
index 1d6f6bf37e..fe7384fd30 100644
@@ -175,7 +175,7 @@ static void __init processor_id(void)
     check_local_cpu_errata();
 }
 
-void dt_unreserved_regions(paddr_t s, paddr_t e,
+void __init dt_unreserved_regions(paddr_t s, paddr_t e,
                                   void (*cb)(paddr_t, paddr_t), int first)
 {
     int i, nr = fdt_num_mem_rsv(device_tree_flattened);
@@ -201,9 +201,9 @@ void dt_unreserved_regions(paddr_t s, paddr_t e,
     cb(s, e);
 }
 
-struct bootmodule *add_boot_module(bootmodule_kind kind,
-                                   paddr_t start, paddr_t size,
-                                   const char *cmdline)
+struct bootmodule __init *add_boot_module(bootmodule_kind kind,
+                                          paddr_t start, paddr_t size,
+                                         const char *cmdline)
 {
     struct bootmodules *mods = &bootinfo.modules;
     struct bootmodule *mod;
@@ -434,7 +434,7 @@ static paddr_t __init get_xen_paddr(void)
     return paddr;
 }
 
-static void init_pdx(void)
+static void __init init_pdx(void)
 {
     paddr_t bank_start, bank_size, bank_end;
 
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 6/7
#14 lore raw

Re: [PATCH 6/7] xen/libfdt: Put all libfdt in init

In reply to Julien Grall
Quoted 10 lines · Julien Grall

Libfdt is used for:
- Unflatten the Flatten Device-Tree (FDT) blob
- Create Device-Tree for the Hardware-Domain

Both use are done during the initialization of Xen. So move all the libfdt to init.

Note that the runes was borrowed from libelf Makefile.

Quoted 26 lines
---
 xen/common/libfdt/Makefile | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
xen/common/libfdt/Makefile +9 -1
index 7578fe9c50..d81f54b6b8 100644
@@ -1,5 +1,13 @@
 include Makefile.libfdt
 
-obj-y += $(LIBFDT_OBJS)
+SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
+
+obj-y += libfdt.o
 
 CFLAGS += -I$(BASEDIR)/include/xen/libfdt/
+
+libfdt.o: libfdt-temp.o Makefile
+	$(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@
+
+libfdt-temp.o: $(LIBFDT_OBJS)
+	$(LD) $(LDFLAGS) -r -o $@ $^
Signature · 1 line
2.11.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw

Re: [PATCH 5/7] xen: Don't build libelf for Arm

In reply to Jan Beulich

Hi Jan,

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 05.06.18 at 19:12, <[email protected]> wrote:
xen/common/Kconfig +0 -0
@@ -17,6 +17,9 @@ config HAS_ALTERNATIVE
  config HAS_DEVICE_TREE
  	bool
 
Quoted 5 lines

xen/common/Kconfig config HAS_ALTERNATIVE · line 22

Quoted 3 lines
xen/common/Kconfig +3 -0
+config HAS_ELF
+    bool
+

HAS_LIBELF (or NEEDS_LIBELF) would seem better to me.

Agreed, I will rename it.

Quoted 3 lines

Also please not the difference in indentation between what you add and surrounding code.

Whoops. I will fix it.

Quoted 4 lines

Jan

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel