Skip to contentSkip to conversation

Load ipxe from a standalone file

PATCH Superseded Wei Liu 2 participants 20 messages Jun 26, 2018 – Jul 5, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

v3 cover Load ipxe from a standalone file

Addressed Jan and Roger's comments.

Wei Liu (6):
Tools.mk.in: drop unused variables
ipxe: produce a single binary from its build
libxc: allow HVM guest to have modules
tools: load IPXE from standalone file
tools: provide --with-system-ipxe
tools: --with-system-{ovmf,seabios,ipxe} should provide absolute paths

 config/Tools.mk.in                   |  3 +-
 tools/config.h.in                    |  3 ++
 tools/configure                      | 65 ++++++++++++++++++++++++++++++++++--
 tools/configure.ac                   | 30 +++++++++++++++--
 tools/firmware/Makefile              |  6 ++++
 tools/firmware/etherboot/Makefile    |  7 +++-
 tools/firmware/hvmloader/Makefile    |  9 +----
 tools/firmware/hvmloader/config.h    |  3 +-
 tools/firmware/hvmloader/hvmloader.c | 10 ++++--
 tools/firmware/hvmloader/ovmf.c      |  3 +-
 tools/firmware/hvmloader/rombios.c   | 24 +++++++++----
 tools/firmware/hvmloader/seabios.c   |  3 +-
 tools/libxc/xc_dom_x86.c             | 32 ++++++++++--------
 tools/libxl/libxl_dom.c              | 13 ++++++++
 tools/libxl/libxl_internal.h         |  1 +
 tools/libxl/libxl_paths.c            |  9 +++++
 16 files changed, 180 insertions(+), 41 deletions(-)
Signature · 7 lines
2.11.0


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

PATCH v3 1/6 Tools.mk.in: drop unused variables

---
Cc: Ian Jackson <[email protected]>

---
 config/Tools.mk.in | 2 --
 1 file changed, 2 deletions(-)
config/Tools.mk.in +0 -2
index 2d6c440324..4cc9f29090 100644
@@ -20,8 +20,6 @@ BCC                 := @BCC@
 IASL                := @IASL@
 AWK                 := @AWK@
 FETCHER             := @FETCHER@
-SEABIOS_PATH        := @seabios_path@
-OVMF_PATH           := @ovmf_path@
 
 # Extra folder for libs/includes
 PREPEND_INCLUDES    := @PREPEND_INCLUDES@
Signature · 7 lines
2.11.0


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

PATCH v3 2/6 ipxe: produce a single binary from its build

In reply to Wei Liu

And switch hvmloader/Makefile to use that binary. This will help later when we change hvmloader to pick a user provided binary.

No functional change.

---
v2: use intermediary file

Cc Ian Jackson <[email protected]>
---
 tools/firmware/etherboot/Makefile | 7 ++++++-
 tools/firmware/hvmloader/Makefile | 8 ++++----
 2 files changed, 10 insertions(+), 5 deletions(-)
tools/firmware/etherboot/Makefile +6 -1
index e33458d2fe..4de6d24a13 100644
@@ -18,11 +18,16 @@ D=ipxe
 T=ipxe.tar.gz
 
 ROMS = $(addprefix $D/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS)))
+ROM = $D/src/bin/ipxe.bin
 
 .NOTPARALLEL:
 
 .PHONY: all
-all: $(ROMS)
+all: $(ROM)
+
+$(ROM): $(ROMS)
+	cat $^ > [email protected]
+	mv -f [email protected] $@
 
 %.rom: $D/src/arch/i386/Makefile
 	$(MAKE) -C $D/src bin/$(*F).rom
tools/firmware/hvmloader/Makefile +4 -4
index a5b4c32c1a..16255ebddd 100644
@@ -51,7 +51,7 @@ CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin
 else
 CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin
 endif
-ETHERBOOT_ROMS := $(addprefix ../etherboot/ipxe/src/bin/, $(addsuffix .rom, $(ETHERBOOT_NICS)))
+ETHERBOOT_ROM := ../etherboot/ipxe/src/bin/ipxe.bin
 endif
 
 ROMS := 
@@ -60,7 +60,7 @@ ifeq ($(CONFIG_ROMBIOS),y)
 OBJS += optionroms.o 32bitbios_support.o rombios.o
 CFLAGS += -DENABLE_ROMBIOS
 ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
-ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
+ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROM)
 endif
 
 .PHONY: all
@@ -105,9 +105,9 @@ ifneq ($(CIRRUSVGA_ROM),)
 	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
-ifneq ($(ETHERBOOT_ROMS),)
+ifneq ($(ETHERBOOT_ROM),)
 	echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> [email protected]
-	sh ../../misc/mkhex etherboot $(ETHERBOOT_ROMS) >> [email protected]
+	sh ../../misc/mkhex etherboot $(ETHERBOOT_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
 
Signature · 7 lines
2.11.0


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

PATCH v3 3/6 libxc: allow HVM guest to have modules

In reply to Wei Liu

Lift the loading code out of PVH specific branch. Take the chance to make the debug message more useful. Now the code needs to take into account virt_base.

IPXE will be loaded as a module of Rombios.

---
Cc: Ian Jackson <[email protected]>

---
 tools/libxc/xc_dom_x86.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
tools/libxc/xc_dom_x86.c +18 -14
index e33a28847d..ed4973a997 100644
@@ -1698,20 +1698,6 @@ static int bootlate_hvm(struct xc_dom_image *dom)
                                 ((uintptr_t)cmdline - (uintptr_t)start_info);
         }
 
-        for ( i = 0; i < dom->num_modules; i++ )
-        {
-            struct xc_hvm_firmware_module mod;
-
-            DOMPRINTF("Adding module %u", i);
-            mod.guest_addr_out =
-                dom->modules[i].seg.vstart - dom->parms.virt_base;
-            mod.length =
-                dom->modules[i].seg.vend - dom->modules[i].seg.vstart;
-
-            add_module_to_list(dom, &mod, dom->modules[i].cmdline,
-                               modlist, start_info);
-        }
-
         /* ACPI module 0 is the RSDP */
         start_info->rsdp_paddr = dom->acpi_modules[0].guest_addr_out ? : 0;
     }
@@ -1721,6 +1707,24 @@ static int bootlate_hvm(struct xc_dom_image *dom)
                            modlist, start_info);
     }
 
+    for ( i = 0; i < dom->num_modules; i++ )
+    {
+        struct xc_hvm_firmware_module mod;
+        uint64_t base = dom->parms.virt_base != UNSET_ADDR ?
+            dom->parms.virt_base : 0;
+
+        mod.guest_addr_out =
+            dom->modules[i].seg.vstart - base;
+        mod.length =
+            dom->modules[i].seg.vend - dom->modules[i].seg.vstart;
+
+        DOMPRINTF("Adding module %u guest_addr %"PRIx64" len %u",
+                  i, mod.guest_addr_out, mod.length);
+
+        add_module_to_list(dom, &mod, dom->modules[i].cmdline,
+                           modlist, start_info);
+    }
+
     if ( start_info->nr_modules )
     {
         start_info->modlist_paddr = (dom->start_info_seg.pfn << PAGE_SHIFT) +
Signature · 7 lines
2.11.0


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

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

Wei Liu writes ("[PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 3 lines

Lift the loading code out of PVH specific branch. Take the chance to make the debug message more useful. Now the code needs to take into account virt_base.

I'm afraid this commit message's note about virt_base is a bit opaque, and looks wrong to me.

AIUI you mean something more like

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guests. In that case seg.vstart is interpreted by ??? as an ??? offset from zero ???

(As you can tell, I'm not very familiar with this area fo the code.)

Thanks,
Ian.

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

author
#5 lore raw

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

Quoted 5 lines · Ian Jackson

Wei Liu writes ("[PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 3 lines

Lift the loading code out of PVH specific branch. Take the chance to make the debug message more useful. Now the code needs to take into account virt_base.

Quoted 8 lines

I'm afraid this commit message's note about virt_base is a bit opaque, and looks wrong to me.

AIUI you mean something more like

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guests. In that case seg.vstart is interpreted by ??? as an ??? offset from zero ???

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guest. In case PVH and PV, virt_base is set by the respective loader by parsing the binary.

Wei.

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

author
#6 lore raw

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

Quoted 11 lines · Wei Liu
Quoted 10 lines · Ian Jackson

Wei Liu writes ("[PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 3 lines

Lift the loading code out of PVH specific branch. Take the chance to make the debug message more useful. Now the code needs to take into account virt_base.

I'm afraid this commit message's note about virt_base is a bit opaque, and looks wrong to me.

AIUI you mean something more like

Quoted 7 lines
Quoted 3 lines

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guests. In that case seg.vstart is interpreted by ??? as an ??? offset from zero ???

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guest. In case PVH and PV, virt_base is set by the respective loader by parsing the binary.

In case virt_base is not set, it should be treated as zero.

Wei.

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

author
#8 lore raw

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

Quoted 4 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 1 line

In case virt_base is not set, it should be treated as zero.

Why ?

Virt_base is the virtual address base for loading a binary. If it is not set it should be treated as 0, otherwise nothing good will come out from it.

Wei.

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

#9 lore raw

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

In reply to Wei Liu

Wei Liu writes ("Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 10 lines · Ian Jackson
Quoted 5 lines

AIUI you mean something more like

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guests. In that case seg.vstart is interpreted by ??? as an ??? offset from zero ???

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guest. In case PVH and PV, virt_base is set by the respective loader by parsing the binary.

That doesn't explain how the necessary value of seg.vstart can be calculated without needing to know the not-yet-calculated value of virt_base.

Thanks,
Ian.

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

author
#10 lore raw

Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules

Quoted 8 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH v3 3/6] libxc: allow HVM guest to have modules"):

Quoted 7 lines · Ian Jackson
Quoted 5 lines

AIUI you mean something more like

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guests. In that case seg.vstart is interpreted by ??? as an ??? offset from zero ???

Quoted 7 lines
Quoted 3 lines

Now the code needs to handle virt_base being UNSET_ADDR, which it is for HVM guest. In case PVH and PV, virt_base is set by the respective loader by parsing the binary.

That doesn't explain how the necessary value of seg.vstart can be calculated without needing to know the not-yet-calculated value of virt_base.

virt_base should already be calculated at this point. It is either set or not. There is possibility for setting 0 at some point but it doesn't change how we interpret UNSET_ADDR.

Wei.

Quoted 3 lines

Thanks,
Ian.

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

author
#11 lore raw

PATCH v3 4/6 tools: load IPXE from standalone file

In reply to Wei Liu

Do not embed IPXE into Rombios anymore. Instead, it is loaded by the toolstack from a file as a separate module.

Ability to let user specify an IPXE blob will come later.

No user visible change.

---
v3: adjust libxl code a bit, addressed Jan's comment and added his ack.

---
 tools/firmware/Makefile              |  6 ++++++
 tools/firmware/hvmloader/Makefile    |  9 +--------
 tools/firmware/hvmloader/config.h    |  3 ++-
 tools/firmware/hvmloader/hvmloader.c | 10 ++++++++--
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 tools/firmware/hvmloader/rombios.c   | 24 +++++++++++++++++-------
 tools/firmware/hvmloader/seabios.c   |  3 ++-
 tools/libxl/libxl_dom.c              | 13 +++++++++++++
 tools/libxl/libxl_internal.h         |  1 +
 tools/libxl/libxl_paths.c            |  5 +++++
 10 files changed, 57 insertions(+), 20 deletions(-)
tools/firmware/Makefile +6 -0
index 5a7cf7766d..0bef579637 100644
@@ -55,6 +55,9 @@ endif
 ifeq ($(CONFIG_OVMF),y)
 	$(INSTALL_DATA) ovmf-dir/ovmf.bin $(INST_DIR)/ovmf.bin
 endif
+ifeq ($(CONFIG_IPXE),y)
+	$(INSTALL_DATA) etherboot/ipxe/src/bin/ipxe.bin $(INST_DIR)/ipxe.bin
+endif
 ifeq ($(CONFIG_PV_SHIM),y)
 	$(INSTALL_DATA) xen-dir/xen-shim $(INST_DIR)/xen-shim
 	$(INSTALL_DATA) xen-dir/xen-shim-syms $(DEBG_DIR)/xen-shim-syms
@@ -69,6 +72,9 @@ endif
 ifeq ($(CONFIG_OVMF),y)
 	rm -f $(INST_DIR)/ovmf.bin
 endif
+ifeq ($(CONFIG_IPXE),y)
+	rm -r $(INST_DIR)/ipxe.bin
+endif
 ifeq ($(CONFIG_PV_SHIM),y)
 	rm -f $(INST_DIR)/xen-shim
 	rm -f $(DEBG_DIR)/xen-shim-syms
tools/firmware/hvmloader/Makefile +1 -8
index 16255ebddd..496ac72b77 100644
@@ -51,7 +51,6 @@ CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin
 else
 CIRRUSVGA_ROM := ../vgabios/VGABIOS-lgpl-latest.cirrus.bin
 endif
-ETHERBOOT_ROM := ../etherboot/ipxe/src/bin/ipxe.bin
 endif
 
 ROMS := 
@@ -60,7 +59,7 @@ ifeq ($(CONFIG_ROMBIOS),y)
 OBJS += optionroms.o 32bitbios_support.o rombios.o
 CFLAGS += -DENABLE_ROMBIOS
 ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
-ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROM)
+ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM)
 endif
 
 .PHONY: all
@@ -105,12 +104,6 @@ ifneq ($(CIRRUSVGA_ROM),)
 	sh ../../misc/mkhex vgabios_cirrusvga $(CIRRUSVGA_ROM) >> [email protected]
 	echo "#endif" >> [email protected]
 endif
-ifneq ($(ETHERBOOT_ROM),)
-	echo "#ifdef ROM_INCLUDE_ETHERBOOT" >> [email protected]
-	sh ../../misc/mkhex etherboot $(ETHERBOOT_ROM) >> [email protected]
-	echo "#endif" >> [email protected]
-endif
-
 	mv [email protected] $@
 
 .PHONY: clean
tools/firmware/hvmloader/config.h +2 -1
index 6e00413f2e..d9b4713d63 100644
@@ -22,7 +22,8 @@ struct bios_config {
     /* ROMS */
     void (*load_roms)(void);
 
-    void (*bios_load)(const struct bios_config *config, void *addr, uint32_t size);
+    void (*bios_load)(const struct bios_config *config, void *addr,
+                      uint32_t size, void *extra_addr);
 
     void (*bios_info_setup)(void);
     void (*bios_info_finish)(void);
tools/firmware/hvmloader/hvmloader.c +8 -2
index f603f68ded..598a226278 100644
@@ -363,12 +363,18 @@ int main(void)
     {
         uint32_t paddr = bios_module->paddr;
 
-        bios->bios_load(bios, (void*)paddr, bios_module->size);
+        bios->bios_load(bios, (void *)paddr, bios_module->size, NULL);
     }
 #ifdef ENABLE_ROMBIOS
     else if ( bios == &rombios_config )
     {
-        bios->bios_load(bios, NULL, 0);
+        const struct hvm_modlist_entry *ipxe;
+        uint32_t paddr = 0;
+
+        ipxe = get_module_entry(hvm_start_info, "ipxe");
+        if ( ipxe )
+            paddr = ipxe->paddr;
+        bios->bios_load(bios, NULL, 0, (void *)paddr);
     }
 #endif
     else
tools/firmware/hvmloader/ovmf.c +2 -1
index a17a11c2f9..23610a0717 100644
@@ -85,7 +85,8 @@ static void ovmf_finish_bios_info(void)
 }
 
 static void ovmf_load(const struct bios_config *config,
-                      void *bios_addr, uint32_t bios_length)
+                      void *bios_addr, uint32_t bios_length,
+                      void *unused_addr)
 {
     xen_pfn_t mfn;
     uint64_t addr = OVMF_END
tools/firmware/hvmloader/rombios.c +17 -7
index c736fd9dea..46f331e465 100644
@@ -63,6 +63,8 @@ static void rombios_setup_bios_info(void)
     memset(info, 0, sizeof(*info));
 }
 
+static void *ipxe_module_addr;
+
 static void rombios_load_roms(void)
 {
     int option_rom_sz = 0, vgabios_sz = 0, etherboot_sz = 0;
@@ -95,13 +97,17 @@ static void rombios_load_roms(void)
     etherboot_phys_addr = VGABIOS_PHYSICAL_ADDRESS + vgabios_sz;
     if ( etherboot_phys_addr < OPTIONROM_PHYSICAL_ADDRESS )
         etherboot_phys_addr = OPTIONROM_PHYSICAL_ADDRESS;
-    etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
-                                      etherboot_phys_addr,
-                                      etherboot);
 
-    option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
-    option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
-                                         option_rom_phys_addr);
+    if ( ipxe_module_addr )
+    {
+        etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
+                                          etherboot_phys_addr,
+                                          ipxe_module_addr);
+
+        option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
+        option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
+                                             option_rom_phys_addr);
+    }
 
     printf("Option ROMs:\n");
     if ( vgabios_sz )
@@ -119,7 +125,8 @@ static void rombios_load_roms(void)
 }
 
 static void rombios_load(const struct bios_config *config,
-                         void *unused_addr, uint32_t unused_size)
+                         void *unused_addr, uint32_t unused_size,
+                         void *ipxe_addr)
 {
     uint32_t bioshigh;
     struct rombios_info *info;
@@ -133,6 +140,9 @@ static void rombios_load(const struct bios_config *config,
 
     info = (struct rombios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
     info->bios32_entry = bioshigh;
+
+    /* Stash ipxe address */
+    ipxe_module_addr = ipxe_addr;
 }
 
 /*
tools/firmware/hvmloader/seabios.c +2 -1
index 801516daf7..444d118ddb 100644
@@ -131,7 +131,8 @@ static void seabios_setup_e820(void)
 }
 
 static void seabios_load(const struct bios_config *bios,
-                         void *bios_addr, uint32_t bios_length)
+                         void *bios_addr, uint32_t bios_length,
+                         void *unused_addr)
 {
     unsigned int bios_dest = 0x100000 - bios_length;
 
tools/libxl/libxl_dom.c +13 -0
index f0fd5fd3a3..3cfe0d4808 100644
@@ -1128,6 +1128,19 @@ static int libxl__domain_firmware(libxl__gc *gc,
         if (rc) goto out;
     }
 
+    if (info->type == LIBXL_DOMAIN_TYPE_HVM &&
+        info->u.hvm.bios == LIBXL_BIOS_TYPE_ROMBIOS &&
+        libxl__ipxe_path()) {
+        const char *fp = libxl__ipxe_path();
+        rc = xc_dom_module_file(dom, fp, "ipxe");
+
+        if (rc) {
+            LOGE(ERROR, "failed to load IPXE %s (%d)", fp, rc);
+            rc = ERROR_FAIL;
+            goto out;
+        }
+    }
+
     if (info->type == LIBXL_DOMAIN_TYPE_HVM &&
         info->u.hvm.smbios_firmware) {
         data = NULL;
tools/libxl/libxl_internal.h +1 -0
index c582894589..518b75592c 100644
@@ -2362,6 +2362,7 @@ _hidden const char *libxl__lock_dir_path(void);
 _hidden const char *libxl__run_dir_path(void);
 _hidden const char *libxl__seabios_path(void);
 _hidden const char *libxl__ovmf_path(void);
+_hidden const char *libxl__ipxe_path(void);
 
 /*----- subprocess execution with timeout -----*/
 
tools/libxl/libxl_paths.c +5 -0
index 0643c1b3a4..8498f82781 100644
@@ -53,6 +53,11 @@ const char *libxl__ovmf_path(void)
 #endif
 }
 
+const char *libxl__ipxe_path(void)
+{
+    return XENFIRMWAREDIR "/ipxe.bin";
+}
+
 /*
  * Local variables:
  * mode: C
Signature · 7 lines
2.11.0


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

Re: [PATCH v3 4/6] tools: load IPXE from standalone file

Wei Liu writes ("[Xen-devel] [PATCH v3 4/6] tools: load IPXE from standalone file"):

Quoted 2 lines

Do not embed IPXE into Rombios anymore. Instead, it is loaded by the toolstack from a file as a separate module.

...

Quoted 3 lines
tools/firmware/hvmloader/config.h +2 -1
-    void (*bios_load)(const struct bios_config *config, void *addr, uint32_t size);
+    void (*bios_load)(const struct bios_config *config, void *addr,
+                      uint32_t size, void *extra_addr);

...

Quoted 11 lines
 #ifdef ENABLE_ROMBIOS
     else if ( bios == &rombios_config )
     {
tools/firmware/hvmloader/hvmloader.c +7 -1
-        bios->bios_load(bios, NULL, 0);
+        const struct hvm_modlist_entry *ipxe;
+        uint32_t paddr = 0;
+
+        ipxe = get_module_entry(hvm_start_info, "ipxe");
+        if ( ipxe )
+            paddr = ipxe->paddr;
+        bios->bios_load(bios, NULL, 0, (void *)paddr);

...

Quoted 4 lines

static void ovmf_load(const struct bios_config *config,

tools/firmware/hvmloader/ovmf.c +2 -1
-                      void *bios_addr, uint32_t bios_length)
+                      void *bios_addr, uint32_t bios_length,
+                      void *unused_addr)

...

Quoted 1 line

+static void *ipxe_module_addr;

...

Quoted 10 lines
tools/firmware/hvmloader/rombios.c +10 -0
+    if ( ipxe_module_addr )
+    {
+        etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
+                                          etherboot_phys_addr,
+                                          ipxe_module_addr);
+
+        option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
+        option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
+                                             option_rom_phys_addr);
+    }

...

Quoted 8 lines

static void rombios_load(const struct bios_config *config,

tools/firmware/hvmloader/rombios.c +2 -1
-                         void *unused_addr, uint32_t unused_size)
+                         void *unused_addr, uint32_t unused_size,
+                         void *ipxe_addr)
 {
     uint32_t bioshigh;
     struct rombios_info *info;

tools/firmware/hvmloader/rombios.c static void rombios_load(const struct bios_config *config, · line 145

Quoted 6 lines
tools/firmware/hvmloader/rombios.c +3 -0
@@ -133,6 +140,9 @@ static void rombios_load(const struct bios_config *config,
 
     info = (struct rombios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
     info->bios32_entry = bioshigh;
+
+    /* Stash ipxe address */
+    ipxe_module_addr = ipxe_addr;

This seems to me to be a layering violation, and quite an ugly one at that. I'm afraid that at the very least, IMO this needs to be better documented both in the code and the commit message.

Is ipxe rombios-specific ? Forgive my ignorance.

Thanks,
Ian.

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

author
#13 lore raw

Re: [PATCH v3 4/6] tools: load IPXE from standalone file

Quoted 47 lines · Ian Jackson

Wei Liu writes ("[Xen-devel] [PATCH v3 4/6] tools: load IPXE from standalone file"):

Quoted 2 lines

Do not embed IPXE into Rombios anymore. Instead, it is loaded by the toolstack from a file as a separate module.

...

Quoted 3 lines
tools/firmware/hvmloader/config.h +2 -1
-    void (*bios_load)(const struct bios_config *config, void *addr, uint32_t size);
+    void (*bios_load)(const struct bios_config *config, void *addr,
+                      uint32_t size, void *extra_addr);

...

Quoted 11 lines
 #ifdef ENABLE_ROMBIOS
     else if ( bios == &rombios_config )
     {
tools/firmware/hvmloader/hvmloader.c +7 -1
-        bios->bios_load(bios, NULL, 0);
+        const struct hvm_modlist_entry *ipxe;
+        uint32_t paddr = 0;
+
+        ipxe = get_module_entry(hvm_start_info, "ipxe");
+        if ( ipxe )
+            paddr = ipxe->paddr;
+        bios->bios_load(bios, NULL, 0, (void *)paddr);

...

Quoted 4 lines

static void ovmf_load(const struct bios_config *config,

tools/firmware/hvmloader/ovmf.c +2 -1
-                      void *bios_addr, uint32_t bios_length)
+                      void *bios_addr, uint32_t bios_length,
+                      void *unused_addr)

...

Quoted 1 line

+static void *ipxe_module_addr;

...

Quoted 10 lines
tools/firmware/hvmloader/rombios.c +10 -0
+    if ( ipxe_module_addr )
+    {
+        etherboot_sz = scan_etherboot_nic(OPTIONROM_PHYSICAL_END,
+                                          etherboot_phys_addr,
+                                          ipxe_module_addr);
+
+        option_rom_phys_addr = etherboot_phys_addr + etherboot_sz;
+        option_rom_sz = pci_load_option_roms(OPTIONROM_PHYSICAL_END,
+                                             option_rom_phys_addr);
+    }

...

Quoted 9 lines

static void rombios_load(const struct bios_config *config,

tools/firmware/hvmloader/rombios.c +2 -1
-                         void *unused_addr, uint32_t unused_size)
+                         void *unused_addr, uint32_t unused_size,
+                         void *ipxe_addr)
 {
     uint32_t bioshigh;
     struct rombios_info *info;
@@ -133,6 +140,9 @@ static void rombios_load(const struct bios_config *config,
 
Quoted 10 lines

tools/firmware/hvmloader/rombios.c static void rombios_load(const struct bios_config *config, · line 145

Quoted 5 lines
tools/firmware/hvmloader/rombios.c +3 -0
     info = (struct rombios_info *)BIOS_INFO_PHYSICAL_ADDRESS;
     info->bios32_entry = bioshigh;
+
+    /* Stash ipxe address */
+    ipxe_module_addr = ipxe_addr;

This seems to me to be a layering violation, and quite an ugly one at that. I'm afraid that at the very least, IMO this needs to be better documented both in the code and the commit message.

There isn't a better way to do this at the moment. Plus that ...

Quoted 1 line

Is ipxe rombios-specific ? Forgive my ignorance.

... ipxe is rombios-specific at the moment, so Jan is fine with changes like this.

Wei.

Quoted 3 lines

Thanks,
Ian.

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

author
#14 lore raw

PATCH v3 5/6 tools: provide --with-system-ipxe

In reply to Wei Liu

---
v3: ipxe should require rombios

Cc Ian Jackson <[email protected]>
---
 config/Tools.mk.in        |  1 +
 tools/config.h.in         |  3 +++
 tools/configure           | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/configure.ac        | 23 +++++++++++++++++++
 tools/libxl/libxl_paths.c |  6 ++++-
 5 files changed, 90 insertions(+), 1 deletion(-)
config/Tools.mk.in +1 -0
index 4cc9f29090..0964f6f9e9 100644
@@ -50,6 +50,7 @@ FLASK_POLICY        := @xsmpolicy@
 CONFIG_OVMF         := @ovmf@
 CONFIG_ROMBIOS      := @rombios@
 CONFIG_SEABIOS      := @seabios@
+CONFIG_IPXE         := @ipxe@
 CONFIG_QEMU_TRAD    := @qemu_traditional@
 CONFIG_QEMU_XEN     := @qemu_xen@
 CONFIG_BLKTAP2      := @blktap2@
tools/config.h.in +3 -0
index c66a78c9b3..5987f087b8 100644
@@ -96,6 +96,9 @@
 /* libutil header file name */
 #undef INCLUDE_LIBUTIL_H
 
+/* IPXE path */
+#undef IPXE_PATH
+
 /* OVMF path */
 #undef OVMF_PATH
 
tools/configure +58 -0

100 lines not on this page · raw message

tools/configure.ac +23 -0
index 0826af8cbc..2db2356380 100644
@@ -84,6 +84,7 @@ AX_ARG_DEFAULT_ENABLE([ocamltools], [Disable Ocaml tools])
 AX_ARG_DEFAULT_ENABLE([xsmpolicy], [Disable XSM policy compilation])
 AX_ARG_DEFAULT_DISABLE([ovmf], [Enable OVMF])
 AX_ARG_DEFAULT_ENABLE([seabios], [Disable SeaBIOS])
+AX_ARG_DEFAULT_ENABLE([ipxe], [Disable IPXE])
 
 AC_ARG_WITH([linux-backend-modules],
     AS_HELP_STRING([--with-linux-backend-modules="mod1 mod2"],
@@ -241,6 +242,28 @@ AS_IF([test "x$ovmf" = "xy" -o -n "$ovmf_path" ], [
                        [OVMF path])
 ])
 
+AC_ARG_WITH([system-ipxe],
+    AS_HELP_STRING([--with-system-ipxe@<:@=PATH@:>@],
+       [Use system supplied IPXE PATH instead of building and installing
+        our own version]),[
+    # Disable compilation of IPXE.
+    ipxe=n
+    case $withval in
+        no) ipxe_path= ;;
+        *)  ipxe_path=$withval ;;
+    esac
+
+    # IPXE depends on Rombios
+    if test "x$enable_rombios" = "xno"; then
+        AC_MSG_ERROR([Rombios is required for using IPXE])
+    fi
+],[])
+AS_IF([test "x$ipxe" = "xy" -o -n "$ipxe_path" ], [
+    AC_DEFINE_UNQUOTED([IPXE_PATH],
+                       ["${ipxe_path:-$XENFIRMWAREDIR/ipxe.bin}"],
+                       [IPXE path])
+])
+
 AC_ARG_WITH([extra-qemuu-configure-args],
     AS_HELP_STRING([--with-extra-qemuu-configure-args@<:@="--ARG1 ..."@:>@],
        [List of additional configure options for upstream qemu]),[
tools/libxl/libxl_paths.c +5 -1
index 8498f82781..3f6a33628e 100644
@@ -55,7 +55,11 @@ const char *libxl__ovmf_path(void)
 
 const char *libxl__ipxe_path(void)
 {
-    return XENFIRMWAREDIR "/ipxe.bin";
+#ifdef IPXE_PATH
+    return IPXE_PATH;
+#else
+    return NULL;
+#endif
 }
 
 /*
Signature · 7 lines
2.11.0


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

Re: [PATCH v3 5/6] tools: provide --with-system-ipxe

Wei Liu writes ("[PATCH v3 5/6] tools: provide --with-system-ipxe"):

Quoted 1 line

But actually I think the effect of --with-system-ipxe is to simply not load any ipxe. Surely that isn't right ?

Perhaps I am just misunderstanding something, in which case more words (perhaps in the commit message) are necessary.

Thanks,
Ian.

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

author
#16 lore raw

Re: [PATCH v3 5/6] tools: provide --with-system-ipxe

Quoted 5 lines · Ian Jackson

Wei Liu writes ("[PATCH v3 5/6] tools: provide --with-system-ipxe"):

Quoted 1 line

But actually I think the effect of --with-system-ipxe is to simply not load any ipxe. Surely that isn't right ?

Its purpose is for packager to provide an ipxe binary to be loaded for rombios. That also means we don't need to build the in-tree ipxe anymore. Just like --with-system-qemu.

Wei.

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

author
#17 lore raw

PATCH v3 6/6 tools: --with-system-{ovmf, seabios, ipxe} should provide absolute paths

In reply to Wei Liu

The paths shouldn't be set to "yes".

---
v3: really check for absolute paths.

Cc Ian Jackson <[email protected]>

new in v2

---
 tools/configure    | 9 ++++++---
 tools/configure.ac | 9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)
tools/configure +6 -3
index 4bff2c02fd..3b55fb2e36 100755
@@ -4564,7 +4564,8 @@ if test "${with_system_seabios+set}" = set; then :
     seabios=n
     case $withval in
         no) seabios_path= ;;
-        *)  seabios_path=$withval ;;
+        /*)  seabios_path=$withval ;;
+        *) as_fn_error $? "Seabios specified, but is not an absolute path" "$LINENO" 5 ;;
     esac
 
 fi
@@ -4587,7 +4588,8 @@ if test "${with_system_ovmf+set}" = set; then :
     ovmf=n
     case $withval in
         no) ovmf_path= ;;
-        *)  ovmf_path=$withval ;;
+        /*)  ovmf_path=$withval ;;
+        *) as_fn_error $? "OVMF specified, but is not an absolute path" "$LINENO" 5 ;;
     esac
 
 fi
@@ -4610,7 +4612,8 @@ if test "${with_system_ipxe+set}" = set; then :
     ipxe=n
     case $withval in
         no) ipxe_path= ;;
-        *)  ipxe_path=$withval ;;
+        /*)  ipxe_path=$withval ;;
+        *) as_fn_error $? "IPXE specified, but is not an absolute path" "$LINENO" 5 ;;
     esac
 
     # IPXE depends on Rombios
tools/configure.ac +6 -3
index 2db2356380..0f85472602 100644
@@ -216,7 +216,8 @@ AC_ARG_WITH([system-seabios],
     seabios=n
     case $withval in
         no) seabios_path= ;;
-        *)  seabios_path=$withval ;;
+        /*)  seabios_path=$withval ;;
+        *) AC_MSG_ERROR([Seabios specified, but is not an absolute path]) ;;
     esac
 ],[])
 AS_IF([test "x$seabios" = "xy" -o -n "$seabios_path" ], [
@@ -233,7 +234,8 @@ AC_ARG_WITH([system-ovmf],
     ovmf=n
     case $withval in
         no) ovmf_path= ;;
-        *)  ovmf_path=$withval ;;
+        /*)  ovmf_path=$withval ;;
+        *) AC_MSG_ERROR([OVMF specified, but is not an absolute path]) ;;
     esac
 ],[])
 AS_IF([test "x$ovmf" = "xy" -o -n "$ovmf_path" ], [
@@ -250,7 +252,8 @@ AC_ARG_WITH([system-ipxe],
     ipxe=n
     case $withval in
         no) ipxe_path= ;;
-        *)  ipxe_path=$withval ;;
+        /*)  ipxe_path=$withval ;;
+        *) AC_MSG_ERROR([IPXE specified, but is not an absolute path]) ;;
     esac
 
     # IPXE depends on Rombios
Signature · 7 lines
2.11.0


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

Re: [PATCH v3 6/6] tools: --with-system-{ovmf, seabios, ipxe} should provide absolute paths

Wei Liu writes ("[PATCH v3 6/6] tools: --with-system-{ovmf,seabios,ipxe} should provide absolute paths"):

Quoted 1 line

The paths shouldn't be set to "yes".

This is rather anomalous compared to the way that --with-system-blah normally works. Surely, instead, we should search for the right thing and use it ?

Ian.

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

author
#19 lore raw

Re: [PATCH v3 6/6] tools: --with-system-{ovmf, seabios, ipxe} should provide absolute paths

Quoted 6 lines · Ian Jackson

Wei Liu writes ("[PATCH v3 6/6] tools: --with-system-{ovmf,seabios,ipxe} should provide absolute paths"):

Quoted 1 line

The paths shouldn't be set to "yes".

This is rather anomalous compared to the way that --with-system-blah normally works. Surely, instead, we should search for the right thing and use it ?

How can we know where to search?

Wei.

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