Skip to contentSkip to conversation

Load BIOS via toolstack instead of been embedded in hvmloader.

PATCH Superseded Anthony PERARD 5 participants 58 messages Feb 25, 2016 – Mar 8, 2016

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Load BIOS via toolstack instead of been embedded in hvmloader.

Hi all,

Many changes in V3:
no more cmdline, but use each modules' cmdline to provide a name for it. in libxc:
- use xc_dom_alloc_segment() to load modules. see patch #1.
- avoid duplication of code between PVHv2 and hvmloader for the initialisation of hvm_start_info.
in xl/libxl:
- only one new option, bios_firmware. acpi_firmware is reused, see patch #6.
in hvmloader:
- handle rombios as separate case.
more detail in each patches.

I've look at loading the BIOS and the ACPI tables via the toolstack instead of having them embedded in the hvmloader binary. After this patch series, hvmloader compilation would be indenpendant from SeaBIOS and OVMF compilation.

Here is a general view of the few step to load the BIOS:
- libxl load the BIOS blob into it's memory and add it to struct xc_hvm_build_args.bios_module
- libxc load the blob into the guest memory and fill the struct hvm_start_info and store a name for each module into the module cmdline.
- hvmloader read the addresses from the hvm_start_info, find out which module to load and copy the blob to the right place.

A git tree can be found here:
git://xenbits.xen.org/people/aperard/xen-unstable.git
tag: hvmloader-with-separated-bios-v3

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Cc Andrew Cooper <[email protected]>
Cc Jan Beulich <[email protected]>

Regards,

Anthony PERARD (16):
libxc: Rework extra module initialisation
libxc: Load BIOS and ACPI table into guest memory
configure: #define SEABIOS_PATH and OVMF_PATH firmware/makefile: install BIOS and ACPI blob ...
libxl: Load guest BIOS from file
libxl: Load guest ACPI table from file
hvmloader: Grab the hvm_start_info pointer
hvmloader: Locate the BIOS blob
hvmloader: Check modules whereabouts
hvmloader: Load SeaBIOS from hvm_start_info modules
hvmloader: Load OVMF from modules
hvmloader: Specific bios_load function required
hvmloader: Load ACPI tables from hvm_start_info module
hvmloader: Compile out the qemu-xen ACPI tables
hvmloader: Always build-in SeaBIOS and OVMF loader
hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH ...

 .gitignore                                |   1 +
 tools/configure.ac                        |  12 ++-
 tools/firmware/Makefile                   |  15 +++-
 tools/firmware/hvmloader/Makefile         |  39 +--------
 tools/firmware/hvmloader/acpi/Makefile    |   9 ++-
 tools/firmware/hvmloader/config.h         |   4 +-
 tools/firmware/hvmloader/hvm_start_info.h |  32 ++++++++
 tools/firmware/hvmloader/hvmloader.c      |  85 ++++++++++++++++---
 tools/firmware/hvmloader/ovmf.c           |  39 ++++-----
 tools/firmware/hvmloader/rombios.c        |   6 +-
 tools/firmware/hvmloader/seabios.c        |  33 ++++----
 tools/firmware/hvmloader/util.h           |   2 +
 tools/libxc/include/xc_dom.h              |   4 +
 tools/libxc/xc_dom_hvmloader.c            | 128 ++++++++---------------------
 tools/libxc/xc_dom_x86.c                  | 130 ++++++++++++++++++++----------
 tools/libxl/libxl.h                       |   8 ++
 tools/libxl/libxl_dom.c                   |  83 +++++++++++++++++++
 tools/libxl/libxl_internal.h              |   2 +
 tools/libxl/libxl_paths.c                 |  10 +++
 tools/libxl/libxl_types.idl               |   1 +
 tools/libxl/xl_cmdimpl.c                  |  11 ++-
 21 files changed, 415 insertions(+), 239 deletions(-)
 create mode 100644 tools/firmware/hvmloader/hvm_start_info.h
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

PATCH v3 1/16 libxc: Rework extra module initialisation

This patch use xc_dom_alloc_segment() to allocate the memory space for the ACPI modules and the SMBIOS modules. This is to replace the arbitrary placement of 1MB after the hvmloader image.

In later patches, while trying to load a firmware such as OVMF, the later could easily be loaded past the address 4MB (OVMF is a 2MB binary), but hvmloader use a range of memory from 4MB to 8MB to perform tests and in the process, clear the memory, before loading the modules.

---
New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 124 +++++++++++------------------------------
 1 file changed, 31 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +31 -93
index 330d5e8..54e096c 100644
@@ -129,98 +129,45 @@ static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom)
     return rc;
 }
 
-static int modules_init(struct xc_dom_image *dom,
-                        uint64_t vend, struct elf_binary *elf,
-                        uint64_t *mstart_out, uint64_t *mend_out)
+static int module_init_one(struct xc_dom_image *dom,
+                           struct xc_hvm_firmware_module *module,
+                           char *name)
 {
-#define MODULE_ALIGN 1UL << 7
-#define MB_ALIGN     1UL << 20
-#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1))
-    uint64_t total_len = 0, offset1 = 0;
+    struct xc_dom_seg seg;
+    void *dest;
 
-    if ( dom->acpi_module.length == 0 && dom->smbios_module.length == 0 )
-        return 0;
-
-    /* Find the total length for the firmware modules with a reasonable large
-     * alignment size to align each the modules.
-     */
-    total_len = MKALIGN(dom->acpi_module.length, MODULE_ALIGN);
-    offset1 = total_len;
-    total_len += MKALIGN(dom->smbios_module.length, MODULE_ALIGN);
-
-    /* Want to place the modules 1Mb+change behind the loader image. */
-    *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN);
-    *mend_out = *mstart_out + total_len;
-
-    if ( *mend_out > vend )
-        return -1;
-
-    if ( dom->acpi_module.length != 0 )
-        dom->acpi_module.guest_addr_out = *mstart_out;
-    if ( dom->smbios_module.length != 0 )
-        dom->smbios_module.guest_addr_out = *mstart_out + offset1;
+    if ( module->length )
+    {
+        if ( xc_dom_alloc_segment(dom, &seg, name, 0, module->length) )
+            goto err;
+        dest = xc_dom_seg_to_ptr(dom, &seg);
+        if ( dest == NULL )
+        {
+            DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &seg) => NULL",
+                      __FUNCTION__);
+            goto err;
+        }
+        memcpy(dest, module->data, module->length);
+        module->guest_addr_out = seg.vstart;
+    }
 
     return 0;
+err:
+    return -1;
 }
 
-static int loadmodules(struct xc_dom_image *dom,
-                       uint64_t mstart, uint64_t mend,
-                       uint32_t domid)
+static int modules_init(struct xc_dom_image *dom)
 {
-    privcmd_mmap_entry_t *entries = NULL;
-    unsigned long pfn_start;
-    unsigned long pfn_end;
-    size_t pages;
-    uint32_t i;
-    uint8_t *dest;
-    int rc = -1;
-    xc_interface *xch = dom->xch;
-
-    if ( mstart == 0 || mend == 0 )
-        return 0;
-
-    pfn_start = (unsigned long)(mstart >> PAGE_SHIFT);
-    pfn_end = (unsigned long)((mend + PAGE_SIZE - 1) >> PAGE_SHIFT);
-    pages = pfn_end - pfn_start;
-
-    /* Map address space for module list. */
-    entries = calloc(pages, sizeof(privcmd_mmap_entry_t));
-    if ( entries == NULL )
-        goto error_out;
-
-    for ( i = 0; i < pages; i++ )
-        entries[i].mfn = (mstart >> PAGE_SHIFT) + i;
-
-    dest = xc_map_foreign_ranges(
-        xch, domid, pages << PAGE_SHIFT, PROT_READ | PROT_WRITE, 1 << PAGE_SHIFT,
-        entries, pages);
-    if ( dest == NULL )
-        goto error_out;
-
-    /* Zero the range so padding is clear between modules */
-    memset(dest, 0, pages << PAGE_SHIFT);
-
-    /* Load modules into range */
-    if ( dom->acpi_module.length != 0 )
-    {
-        memcpy(dest,
-               dom->acpi_module.data,
-               dom->acpi_module.length);
-    }
-    if ( dom->smbios_module.length != 0 )
-    {
-        memcpy(dest + (dom->smbios_module.guest_addr_out - mstart),
-               dom->smbios_module.data,
-               dom->smbios_module.length);
-    }
-
-    munmap(dest, pages << PAGE_SHIFT);
-    rc = 0;
+    int rc;
 
- error_out:
-    free(entries);
+    rc = module_init_one(dom, &dom->acpi_module, "acpi module");
+    if ( rc ) goto err;
+    rc = module_init_one(dom, &dom->smbios_module, "smbios module");
+    if ( rc ) goto err;
 
-    return rc;
+    return 0;
+err:
+    return -1;
 }
 
 static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom)
@@ -229,7 +176,6 @@ static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom)
     privcmd_mmap_entry_t *entries = NULL;
     size_t pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT;
     elf_errorstatus rc;
-    uint64_t m_start = 0, m_end = 0;
     int i;
 
     /* Map address space for initial elf image. */
@@ -262,15 +208,7 @@ static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom)
 
     munmap(elf->dest_base, elf->dest_size);
 
-    rc = modules_init(dom, dom->total_pages << PAGE_SHIFT, elf, &m_start,
-                      &m_end);
-    if ( rc != 0 )
-    {
-        DOMPRINTF("%s: insufficient space to load modules.", __func__);
-        goto error;
-    }
-
-    rc = loadmodules(dom, m_start, m_end, dom->guest_domid);
+    rc = modules_init(dom);
     if ( rc != 0 )
     {
         DOMPRINTF("%s: unable to load modules.", __func__);
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH v3 01/16] libxc: Rework extra module initialisation

Quoted 63 lines · Anthony PERARD

This patch use xc_dom_alloc_segment() to allocate the memory space for the ACPI modules and the SMBIOS modules. This is to replace the arbitrary placement of 1MB after the hvmloader image.

In later patches, while trying to load a firmware such as OVMF, the later could easily be loaded past the address 4MB (OVMF is a 2MB binary), but hvmloader use a range of memory from 4MB to 8MB to perform tests and in the process, clear the memory, before loading the modules.

---
New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 124 +++++++++++------------------------------
 1 file changed, 31 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +8 -28
index 330d5e8..54e096c 100644
@@ -129,98 +129,45 @@ static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom)
     return rc;
 }
 
-static int modules_init(struct xc_dom_image *dom,
-                        uint64_t vend, struct elf_binary *elf,
-                        uint64_t *mstart_out, uint64_t *mend_out)
+static int module_init_one(struct xc_dom_image *dom,
+                           struct xc_hvm_firmware_module *module,
+                           char *name)
 {
-#define MODULE_ALIGN 1UL << 7
-#define MB_ALIGN     1UL << 20
-#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1))
-    uint64_t total_len = 0, offset1 = 0;
+    struct xc_dom_seg seg;
+    void *dest;
 
-    if ( dom->acpi_module.length == 0 && dom->smbios_module.length == 0 )
-        return 0;
-
-    /* Find the total length for the firmware modules with a reasonable large
-     * alignment size to align each the modules.
-     */
-    total_len = MKALIGN(dom->acpi_module.length, MODULE_ALIGN);
-    offset1 = total_len;
-    total_len += MKALIGN(dom->smbios_module.length, MODULE_ALIGN);
-
-    /* Want to place the modules 1Mb+change behind the loader image. */
-    *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN);
-    *mend_out = *mstart_out + total_len;
-
-    if ( *mend_out > vend )
-        return -1;
-
-    if ( dom->acpi_module.length != 0 )
-        dom->acpi_module.guest_addr_out = *mstart_out;
-    if ( dom->smbios_module.length != 0 )
-        dom->smbios_module.guest_addr_out = *mstart_out + offset1;
+    if ( module->length )
+    {
+        if ( xc_dom_alloc_segment(dom, &seg, name, 0, module->length) )

tools/libxc/xc_dom_hvmloader.c static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom) · line 151

Quoted 10 lines
tools/libxc/xc_dom_hvmloader.c +10 -0
+            goto err;
+        dest = xc_dom_seg_to_ptr(dom, &seg);
+        if ( dest == NULL )
+        {
+            DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &seg) => NULL",
+                      __FUNCTION__);
+            goto err;
+        }
+        memcpy(dest, module->data, module->length);
+        module->guest_addr_out = seg.vstart;

One thing you might want to take care is that the guest_addr_out is actually within a reasonable range that hvmloader can access?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH v3 01/16] libxc: Rework extra module initialisation

Quoted 69 lines · Wei Liu
Quoted 68 lines · Anthony PERARD

This patch use xc_dom_alloc_segment() to allocate the memory space for the ACPI modules and the SMBIOS modules. This is to replace the arbitrary placement of 1MB after the hvmloader image.

In later patches, while trying to load a firmware such as OVMF, the later could easily be loaded past the address 4MB (OVMF is a 2MB binary), but hvmloader use a range of memory from 4MB to 8MB to perform tests and in the process, clear the memory, before loading the modules.

---
New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 124 +++++++++++------------------------------
 1 file changed, 31 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +13 -28
index 330d5e8..54e096c 100644
@@ -129,98 +129,45 @@ static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom)
     return rc;
 }
 
-static int modules_init(struct xc_dom_image *dom,
-                        uint64_t vend, struct elf_binary *elf,
-                        uint64_t *mstart_out, uint64_t *mend_out)
+static int module_init_one(struct xc_dom_image *dom,
+                           struct xc_hvm_firmware_module *module,
+                           char *name)
 {
-#define MODULE_ALIGN 1UL << 7
-#define MB_ALIGN     1UL << 20
-#define MKALIGN(x, a) (((uint64_t)(x) + (a) - 1) & ~(uint64_t)((a) - 1))
-    uint64_t total_len = 0, offset1 = 0;
+    struct xc_dom_seg seg;
+    void *dest;
 
-    if ( dom->acpi_module.length == 0 && dom->smbios_module.length == 0 )
-        return 0;
-
-    /* Find the total length for the firmware modules with a reasonable large
-     * alignment size to align each the modules.
-     */
-    total_len = MKALIGN(dom->acpi_module.length, MODULE_ALIGN);
-    offset1 = total_len;
-    total_len += MKALIGN(dom->smbios_module.length, MODULE_ALIGN);
-
-    /* Want to place the modules 1Mb+change behind the loader image. */
-    *mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN);
-    *mend_out = *mstart_out + total_len;
-
-    if ( *mend_out > vend )
-        return -1;
-
-    if ( dom->acpi_module.length != 0 )
-        dom->acpi_module.guest_addr_out = *mstart_out;
-    if ( dom->smbios_module.length != 0 )
-        dom->smbios_module.guest_addr_out = *mstart_out + offset1;
+    if ( module->length )
+    {
+        if ( xc_dom_alloc_segment(dom, &seg, name, 0, module->length) )
+            goto err;
+        dest = xc_dom_seg_to_ptr(dom, &seg);
+        if ( dest == NULL )
+        {
+            DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &seg) => NULL",
Quoted 8 lines

tools/libxc/xc_dom_hvmloader.c static elf_errorstatus xc_dom_parse_hvm_kernel(struct xc_dom_image *dom) · line 151

Quoted 5 lines
tools/libxc/xc_dom_hvmloader.c +5 -0
+                      __FUNCTION__);
+            goto err;
+        }
+        memcpy(dest, module->data, module->length);
+        module->guest_addr_out = seg.vstart;

One thing you might want to take care is that the guest_addr_out is actually within a reasonable range that hvmloader can access?

I guest that would be a good idee. So maybe they should be bellow 3GB.

Signature · 6 lines
Anthony PERARD

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

PATCH v3 2/16 libxc: Load BIOS and ACPI table into guest memory

In reply to Anthony PERARD

This adds two new firmware module, bios_module and full_acpi_module. They are loaded in the guest memory and final location is provided to hvmloader via the hvm_start_info struct.

This patch create the hvm_start_info struct for HVM guest that have a device model, so this is now common code with HVM guest without device model.

---
Change in V3:
- rename acpi_table_module to full_acpi_module.
- factorise module loading, using new function to load existing optinal module, this should not change anything
- should now use the same code to loads modules as for HVMlite VMs. this avoid duplication of code.
- no more generic cmdline with a list of modules, each module have its name in the module specific cmdline.
- scope change for common code between hvmlite and hvmloader

---
 tools/libxc/include/xc_dom.h   |   4 ++
 tools/libxc/xc_dom_hvmloader.c |   4 ++
 tools/libxc/xc_dom_x86.c       | 130 ++++++++++++++++++++++++++++-------------
 3 files changed, 96 insertions(+), 42 deletions(-)
tools/libxc/include/xc_dom.h +4 -0
index 6ebe946..7dc3fe7 100644
@@ -209,6 +209,10 @@ struct xc_dom_image {
     /* If unset disables the setup of the IOREQ pages. */
     bool device_model;
 
+    /* BIOS and ACPI tables passed to HVMLOADER */
+    struct xc_hvm_firmware_module bios_module;
+    struct xc_hvm_firmware_module full_acpi_module;
+
     /* Extra ACPI tables passed to HVMLOADER */
     struct xc_hvm_firmware_module acpi_module;
 
tools/libxc/xc_dom_hvmloader.c +4 -0
index 54e096c..2c965c9 100644
@@ -160,6 +160,10 @@ static int modules_init(struct xc_dom_image *dom)
 {
     int rc;
 
+    rc = module_init_one(dom, &dom->bios_module, "bios module");
+    if ( rc ) goto err;
+    rc = module_init_one(dom, &dom->full_acpi_module, "acpi table module");
+    if ( rc ) goto err;
     rc = module_init_one(dom, &dom->acpi_module, "acpi module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "smbios module");
tools/libxc/xc_dom_x86.c +88 -42

186 lines not on this page · raw message

Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v3 02/16] libxc: Load BIOS and ACPI table into guest memory

Quoted 8 lines · Anthony PERARD

This adds two new firmware module, bios_module and full_acpi_module. They are loaded in the guest memory and final location is provided to hvmloader via the hvm_start_info struct.

This patch create the hvm_start_info struct for HVM guest that have a device model, so this is now common code with HVM guest without device model.

I think you also need to update the relevant headers to say the structures is now used by both PVHv2 and HVM.

Quoted 22 lines

---
Change in V3:
- rename acpi_table_module to full_acpi_module.
- factorise module loading, using new function to load existing optinal module, this should not change anything
- should now use the same code to loads modules as for HVMlite VMs. this avoid duplication of code.
- no more generic cmdline with a list of modules, each module have its name in the module specific cmdline.
- scope change for common code between hvmlite and hvmloader

---
 tools/libxc/include/xc_dom.h   |   4 ++
 tools/libxc/xc_dom_hvmloader.c |   4 ++
 tools/libxc/xc_dom_x86.c       | 130 ++++++++++++++++++++++++++++-------------
 3 files changed, 96 insertions(+), 42 deletions(-)
tools/libxc/include/xc_dom.h +0 -0
index 6ebe946..7dc3fe7 100644

tools/libxc/include/xc_dom.h struct xc_dom_image { · line 218

Quoted 10 lines
tools/libxc/include/xc_dom.h +4 -0
@@ -209,6 +209,10 @@ struct xc_dom_image {
     /* If unset disables the setup of the IOREQ pages. */
     bool device_model;
 
+    /* BIOS and ACPI tables passed to HVMLOADER */
+    struct xc_hvm_firmware_module bios_module;
+    struct xc_hvm_firmware_module full_acpi_module;
+
     /* Extra ACPI tables passed to HVMLOADER */
     struct xc_hvm_firmware_module acpi_module;
 

What is the difference between "ACPI tables" and "Extra ACPI tables"?

Quoted 7 lines
tools/libxc/xc_dom_hvmloader.c +0 -0
index 54e096c..2c965c9 100644
@@ -160,6 +160,10 @@ static int modules_init(struct xc_dom_image *dom)
 {
     int rc;

[...]

tools/libxc/xc_dom_hvmloader.c

Quoted 7 lines
     }
     else
     {
tools/libxc/xc_dom_hvmloader.c +4 -0
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size += 10 * HVMLOADER_MODULE_MAX_COUNT;

Why magic number 10? I guess this is the length limit of the name? Can you have a #define somewhere?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw

Re: [PATCH v3 02/16] libxc: Load BIOS and ACPI table into guest memory

Quoted 5 lines · Wei Liu
Quoted 4 lines · Anthony PERARD

This adds two new firmware module, bios_module and full_acpi_module. They are loaded in the guest memory and final location is provided to hvmloader via the hvm_start_info struct.

Quoted 7 lines
Quoted 4 lines

This patch create the hvm_start_info struct for HVM guest that have a device model, so this is now common code with HVM guest without device model.

I think you also need to update the relevant headers to say the structures is now used by both PVHv2 and HVM.

Yes, I can do that.

Quoted 25 lines
Quoted 25 lines

---
Change in V3:
- rename acpi_table_module to full_acpi_module.
- factorise module loading, using new function to load existing optinal module, this should not change anything
- should now use the same code to loads modules as for HVMlite VMs. this avoid duplication of code.
- no more generic cmdline with a list of modules, each module have its name in the module specific cmdline.
- scope change for common code between hvmlite and hvmloader

---
 tools/libxc/include/xc_dom.h   |   4 ++
 tools/libxc/xc_dom_hvmloader.c |   4 ++
 tools/libxc/xc_dom_x86.c       | 130 ++++++++++++++++++++++++++++-------------
 3 files changed, 96 insertions(+), 42 deletions(-)
tools/libxc/include/xc_dom.h +0 -0
index 6ebe946..7dc3fe7 100644
@@ -209,6 +209,10 @@ struct xc_dom_image {
     /* If unset disables the setup of the IOREQ pages. */
     bool device_model;
 
Quoted 9 lines

tools/libxc/include/xc_dom.h struct xc_dom_image { · line 218

Quoted 7 lines
tools/libxc/include/xc_dom.h +4 -0
+    /* BIOS and ACPI tables passed to HVMLOADER */
+    struct xc_hvm_firmware_module bios_module;
+    struct xc_hvm_firmware_module full_acpi_module;
+
     /* Extra ACPI tables passed to HVMLOADER */
     struct xc_hvm_firmware_module acpi_module;
 

What is the difference between "ACPI tables" and "Extra ACPI tables"?

The first one is a DSDT table that we generate and compile into AML that is currently embedded into hvmloader.

The extra one are tables that a user can provide via the "acpi_firmware" option from xl.

Quoted 16 lines
Quoted 7 lines
tools/libxc/xc_dom_hvmloader.c +0 -0
index 54e096c..2c965c9 100644
@@ -160,6 +160,10 @@ static int modules_init(struct xc_dom_image *dom)
 {
     int rc;

[...]

tools/libxc/xc_dom_hvmloader.c

Quoted 7 lines
     }
     else
     {
tools/libxc/xc_dom_hvmloader.c +4 -0
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size += 10 * HVMLOADER_MODULE_MAX_COUNT;
Quoted 2 lines

Why magic number 10? I guess this is the length limit of the name? Can you have a #define somewhere?

I wanted to reserve some space to write the names of the modules without knowing the actual size. I can add a define for it.

Signature · 6 lines
Anthony PERARD

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

PATCH v3 3/16 configure: #define SEABIOS_PATH and OVMF_PATH

In reply to Anthony PERARD

Those paths are to be used by libxl, in order to load the firmware in memory. If a system path is not define, then this default to the Xen firmware directory.

---
Please, run ./autogen.sh on this patch.

---
 tools/configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)
tools/configure.ac +6 -0
index 6c70040..6929006 100644
@@ -212,6 +212,9 @@ AC_ARG_WITH([system-seabios],
     esac
 ],[])
 AC_SUBST(seabios_path)
+AC_DEFINE_UNQUOTED([SEABIOS_PATH],
+                   ["${seabios_path:-$XENFIRMWAREDIR/seabios.bin}"],
+                   [SeaBIOS path])
 
 AC_ARG_WITH([system-ovmf],
     AS_HELP_STRING([--with-system-ovmf@<:@=PATH@:>@],
@@ -223,6 +226,9 @@ AC_ARG_WITH([system-ovmf],
     esac
 ],[])
 AC_SUBST(ovmf_path)
+AC_DEFINE_UNQUOTED([OVMF_PATH],
+                   ["${ovmf_path:-$XENFIRMWAREDIR/ovmf.bin}"],
+                   [OVMF path])
 
 AC_ARG_WITH([extra-qemuu-configure-args],
     AS_HELP_STRING([--with-extra-qemuu-configure-args@<:@="--ARG1 ..."@:>@],
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#8 lore raw

Re: [PATCH v3 03/16] configure: #define SEABIOS_PATH and OVMF_PATH

Quoted 6 lines · Anthony PERARD

Those paths are to be used by libxl, in order to load the firmware in memory. If a system path is not define, then this default to the Xen firmware directory.

There is already --with-system-seabios and --with-system-ovmf that you can use.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#9 lore raw

Re: [PATCH v3 03/16] configure: #define SEABIOS_PATH and OVMF_PATH

Quoted 10 lines · Wei Liu
Quoted 6 lines · Anthony PERARD

Those paths are to be used by libxl, in order to load the firmware in memory. If a system path is not define, then this default to the Xen firmware directory.

There is already --with-system-seabios and --with-system-ovmf that you can use.

The path generated by --with-system-seabios is only for the benefit of the Makefiles. With this patch, I'm exporting the value to the .c files. And in the case where --with-system-* is not used, it provide a default path to where we are going to install the firmware we compiled.

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v3 03/16] configure: #define SEABIOS_PATH and OVMF_PATH

Quoted 9 lines · Anthony PERARD
Quoted 8 lines · Wei Liu
Quoted 6 lines · Anthony PERARD

Those paths are to be used by libxl, in order to load the firmware in memory. If a system path is not define, then this default to the Xen firmware directory.

Quoted 8 lines
Quoted 2 lines

There is already --with-system-seabios and --with-system-ovmf that you can use.

The path generated by --with-system-seabios is only for the benefit of the Makefiles. With this patch, I'm exporting the value to the .c files. And in the case where --with-system-* is not used, it provide a default path to where we are going to install the firmware we compiled.

I see. SEABIOS_PATH and OVMF_PATH are already defined in Tools.mk.in. This approach is fine then.

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#11 lore raw

PATCH v3 4/16 firmware/makefile: install BIOS and ACPI blob ...

In reply to Anthony PERARD

... into the firmware directory, along with hvmloader.

This introduce a rules for dsdt_anycpu_qemu_xen.aml, and change the rule for dsdt_anycpu_qemu_xen.c to temporarly generate both .c and .aml. The generation of dsdt_anycpu_qemu_xen.c will go away in a future patch.

---
Change in V3:
- do not check if ROMs file exist before installing, they should exist
- change rules for dsdt_anycpu_qemu_xen.c in oder to generate both .c and .aml files without changing temporarly the other dsdt_*.c rules.

---
 .gitignore                             |  1 +
 tools/firmware/Makefile                | 15 +++++++++++++++
 tools/firmware/hvmloader/acpi/Makefile | 11 +++++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)
.gitignore +1 -0
index 91f690c..abd0dce 100644
@@ -127,6 +127,7 @@ tools/firmware/hvmloader/acpi/mk_dsdt
 tools/firmware/hvmloader/acpi/dsdt*.c
 tools/firmware/hvmloader/acpi/dsdt_*.asl
 tools/firmware/hvmloader/acpi/ssdt_*.h
+tools/firmware/hvmloader/acpi/dsdt_anycpu_qemu_xen.aml
 tools/firmware/hvmloader/hvmloader
 tools/firmware/hvmloader/roms.h
 tools/firmware/hvmloader/roms.inc
tools/firmware/Makefile +15 -0
index 6cc86ce..aa1ab54 100644
@@ -19,6 +19,10 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+ACPI_TABLE_QEMU_PC_I440FX = hvmloader/acpi/dsdt_anycpu_qemu_xen.aml
+
 ovmf-dir:
 	GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir
 	cp ovmf-makefile ovmf-dir/Makefile;
@@ -45,6 +49,17 @@ endif
 install: all
 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET) $(INST_DIR)
+ifeq ($(CONFIG_SEABIOS),y)
+ifeq ($(SEABIOS_PATH),)
+	$(INSTALL_DATA) $(SEABIOS_ROM) $(INST_DIR)/seabios.bin
+endif
+endif
+ifeq ($(CONFIG_OVMF),y)
+ifeq ($(OVMF_PATH),)
+	$(INSTALL_DATA) $(OVMF_ROM) $(INST_DIR)/ovmf.bin
+endif
+endif
+	$(INSTALL_DATA) $(ACPI_TABLE_QEMU_PC_I440FX) $(INST_DIR)
 
 .PHONY: clean
 clean: subdirs-clean
tools/firmware/hvmloader/acpi/Makefile +9 -2
index d3e882a..a3041d3 100644
@@ -23,7 +23,7 @@ OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 CFLAGS += $(CFLAGS_xeninclude)
 
 vpath iasl $(PATH)
-all: acpi.a
+all: acpi.a dsdt_anycpu_qemu_xen.aml
 
 ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
 	iasl -vs -p $* -tc $<
@@ -42,12 +42,19 @@ dsdt_%cpu.asl: dsdt.asl mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
 	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
+$(filter dsdt_%cpu.c,$(C_SRC)): %.c: iasl %.asl
 	iasl -vs -p $* -tc $*.asl
 	sed -e 's/AmlCode/$*/g' $*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
 	rm -f $*.aml $*.hex
 
+dsdt_anycpu_qemu_xen.c: dsdt_anycpu_qemu_xen.aml
+dsdt_anycpu_qemu_xen.aml: %.aml: iasl %.asl
+	iasl -vs -p $* -tc $*.asl
+	sed -e 's/AmlCode/$*/g' $*.hex >$*.c
+	echo "int $*_len=sizeof($*);" >>$*.c
+	rm -f $*.hex
+
 iasl:
 	@echo
 	@echo "ACPI ASL compiler (iasl) is needed"
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v3 4/16
#12 lore raw

Re: [PATCH v3 04/16] firmware/makefile: install BIOS and ACPI blob ...

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 45

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/Makefile +1 -1
@@ -42,12 +42,19 @@ dsdt_%cpu.asl: dsdt.asl mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
 	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
+$(filter dsdt_%cpu.c,$(C_SRC)): %.c: iasl %.asl

Would there be anything wrong with leaving this alone and ...

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 49

Quoted 4 lines
tools/firmware/hvmloader/acpi/Makefile +0 -0
 	iasl -vs -p $* -tc $*.asl
 	sed -e 's/AmlCode/$*/g' $*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
 	rm -f $*.aml $*.hex

... simply dropping the deletion of $*.aml here, plus ...

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 51

Quoted 1 line
tools/firmware/hvmloader/acpi/Makefile +1 -0
+dsdt_anycpu_qemu_xen.c: dsdt_anycpu_qemu_xen.aml

... an equivalent of this added?

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 53

Quoted 2 lines
tools/firmware/hvmloader/acpi/Makefile +2 -0
+dsdt_anycpu_qemu_xen.aml: %.aml: iasl %.asl
+	iasl -vs -p $* -tc $*.asl

Otherwise, if this is the rule to remain long term, then please make use of $< here, which aiui would require flipping around the two dependencies.

Whichever route you chose, with a respective adjustment

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

Re: [PATCH v3 04/16] firmware/makefile: install BIOS and ACPI blob ...

Quoted 19 lines · Jan Beulich

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 45

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/acpi/Makefile +1 -1
@@ -42,12 +42,19 @@ dsdt_%cpu.asl: dsdt.asl mk_dsdt
 	awk 'NR > 1 {print s} {s=$$0}' $< > $@
 	./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
 
-$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
+$(filter dsdt_%cpu.c,$(C_SRC)): %.c: iasl %.asl

Would there be anything wrong with leaving this alone and ...

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 49

Quoted 4 lines
tools/firmware/hvmloader/acpi/Makefile +0 -0
 	iasl -vs -p $* -tc $*.asl
 	sed -e 's/AmlCode/$*/g' $*.hex >$@
 	echo "int $*_len=sizeof($*);" >>$@
 	rm -f $*.aml $*.hex

... simply dropping the deletion of $*.aml here, plus ...

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 51

Quoted 1 line
tools/firmware/hvmloader/acpi/Makefile +1 -0
+dsdt_anycpu_qemu_xen.c: dsdt_anycpu_qemu_xen.aml
Quoted 8 lines

... an equivalent of this added?

tools/firmware/hvmloader/acpi/Makefile dsdt_%cpu.asl: dsdt.asl mk_dsdt · line 53

Quoted 2 lines
tools/firmware/hvmloader/acpi/Makefile +2 -0
+dsdt_anycpu_qemu_xen.aml: %.aml: iasl %.asl
+	iasl -vs -p $* -tc $*.asl

Otherwise, if this is the rule to remain long term, then please make use of $< here, which aiui would require flipping around the two dependencies.

Yes, this rules is here to stay. The dsdt_anycpu_qemu_xen.c won't be needed anymore after the patch series. The rule change in patch #14. I will use $<.

Quoted 2 lines

Whichever route you chose, with a respective adjustment

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#14 lore raw

PATCH v3 5/16 libxl: Load guest BIOS from file

In reply to Anthony PERARD

The path to the BIOS blob can be override by the xl's bios_override option, or provided by u.hvm.bios_firmware in the domain_build_info struct by other libxl user.

---
Change in V3:
- move seabios_path and ovmf_path to libxl_path.c (with renaming)
- fix some coding style
- warn for empty file
- remove rombios stuff (will still be built-in hvmloader)
- rename field bios_filename in domain_build_info to bios_firmware to follow naming of acpi and smbios.
- log an error after libxl_read_file_contents() only when it return ENOENT
- return an error on empty file.
- added #define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE

---
 tools/libxl/libxl.h          |  8 +++++++
 tools/libxl/libxl_dom.c      | 57 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  2 ++
 tools/libxl/libxl_paths.c    | 10 ++++++++
 tools/libxl/libxl_types.idl  |  1 +
 tools/libxl/xl_cmdimpl.c     | 11 ++++++---
 6 files changed, 86 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +8 -0
index fa87f53..d223c35 100644
@@ -876,6 +876,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
  */
 #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+ *
+ * libxl_domain_build_info has u.hvm.bios_firmware field which can be use
+ * to provide a different bios blob (like SeaBIOS or OVMF).
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
tools/libxl/libxl_dom.c +57 -0

75 lines not on this page · raw message

tools/libxl/libxl_internal.h +2 -0
index 650a958..0dbff27 100644
@@ -2265,6 +2265,8 @@ _hidden const char *libxl__xen_config_dir_path(void);
 _hidden const char *libxl__xen_script_dir_path(void);
 _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);
 
 /*----- subprocess execution with timeout -----*/
 
tools/libxl/libxl_paths.c +10 -0
index 9b7b0d5..6972b90 100644
@@ -35,6 +35,16 @@ const char *libxl__run_dir_path(void)
     return XEN_RUN_DIR;
 }
 
+const char *libxl__seabios_path(void)
+{
+    return SEABIOS_PATH;
+}
+
+const char *libxl__ovmf_path(void)
+{
+    return OVMF_PATH;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_types.idl +1 -0
index 9ad7eba..95bacd2 100644
@@ -487,6 +487,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("timer_mode",       libxl_timer_mode),
                                        ("nested_hvm",       libxl_defbool),
                                        ("altp2m",           libxl_defbool),
+                                       ("bios_firmware",    string),
                                        ("smbios_firmware",  string),
                                        ("acpi_firmware",    string),
                                        ("hdtype",           libxl_hdtype),
tools/libxl/xl_cmdimpl.c +8 -3
index f40af51..201cff6 100644
@@ -1500,12 +1500,17 @@ static void parse_config_data(const char *config_source,
 
         xlu_cfg_replace_string (config, "firmware_override",
                                 &b_info->u.hvm.firmware, 0);
-        if (!xlu_cfg_get_string(config, "bios", &buf, 0) &&
-            libxl_bios_type_from_string(buf, &b_info->u.hvm.bios)) {
+        xlu_cfg_replace_string (config, "bios_override",
+                                &b_info->u.hvm.bios_firmware, 0);
+        if (!xlu_cfg_get_string(config, "bios", &buf, 0)) {
+            if (libxl_bios_type_from_string(buf, &b_info->u.hvm.bios)) {
                 fprintf(stderr, "ERROR: invalid value \"%s\" for \"bios\"\n",
                     buf);
                 exit (1);
-        }
+            }
+        } else if (b_info->u.hvm.bios_firmware)
+            fprintf(stderr, "WARNING: "
+                    "bios_override given without specific bios name\n");
 
         xlu_cfg_get_defbool(config, "pae", &b_info->u.hvm.pae, 0);
         xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0);
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v3 05/16] libxl: Load guest BIOS from file

Quoted 17 lines · Anthony PERARD

The path to the BIOS blob can be override by the xl's bios_override option, or provided by u.hvm.bios_firmware in the domain_build_info struct by other libxl user.

---
Change in V3:
- move seabios_path and ovmf_path to libxl_path.c (with renaming)
- fix some coding style
- warn for empty file
- remove rombios stuff (will still be built-in hvmloader)
- rename field bios_filename in domain_build_info to bios_firmware to follow naming of acpi and smbios.
- log an error after libxl_read_file_contents() only when it return ENOENT
- return an error on empty file.
- added #define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE

Quoted 7 lines
---
 tools/libxl/libxl.h          |  8 +++++++
 tools/libxl/libxl_dom.c      | 57 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  2 ++
 tools/libxl/libxl_paths.c    | 10 ++++++++
 tools/libxl/libxl_types.idl  |  1 +
 tools/libxl/xl_cmdimpl.c     | 11 ++++++---

You also need to patch manpage for this new option.

How does this new option interacts with bios= option?

Quoted 47 lines
 6 files changed, 86 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +8 -0
index fa87f53..d223c35 100644
@@ -876,6 +876,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
  */
 #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+ *
+ * libxl_domain_build_info has u.hvm.bios_firmware field which can be use
+ * to provide a different bios blob (like SeaBIOS or OVMF).
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
tools/libxl/libxl_dom.c +18 -0
index 2269998..50abfbc 100644
@@ -863,6 +863,38 @@ err:
     return ret;
 }
 
+static int libxl__load_hvm_firmware_module(libxl__gc *gc,
+                                           const char *filename,
+                                           const char *what,
+                                           struct xc_hvm_firmware_module *m)
+{
+    int datalen = 0;
+    void *data = NULL;
+    int e;
+
+    LOG(DEBUG, "Loading %s: %s", what, filename);
+    e = libxl_read_file_contents(CTX, filename, &data, &datalen);
+    if (e) {
+        /*
+         * Print a message only on ENOENT, other error are logged by the
+         * function libxl_read_file_contents().
+         */
+        if (e == ENOENT)
+            LOGEV(ERROR, e, "failed to read %s file", what);

tools/libxl/libxl_dom.c err: · line 893

Quoted 10 lines
tools/libxl/libxl_dom.c +10 -0
+        return ERROR_FAIL;
+    }
+    libxl__ptr_add(gc, data);
+    if (datalen) {
+        /* Only accept non-empty files */
+        m->data = data;
+        m->length = datalen;
+    } else {
+        LOG(ERROR, "file %s for %s is empty", filename, what);
+        return ERROR_FAIL;

ERROR_INVAL is more appropriate.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#16 lore raw

Re: [PATCH v3 05/16] libxl: Load guest BIOS from file

Quoted 26 lines · Wei Liu
Quoted 17 lines · Anthony PERARD

The path to the BIOS blob can be override by the xl's bios_override option, or provided by u.hvm.bios_firmware in the domain_build_info struct by other libxl user.

---
Change in V3:
- move seabios_path and ovmf_path to libxl_path.c (with renaming)
- fix some coding style
- warn for empty file
- remove rombios stuff (will still be built-in hvmloader)
- rename field bios_filename in domain_build_info to bios_firmware to follow naming of acpi and smbios.
- log an error after libxl_read_file_contents() only when it return ENOENT
- return an error on empty file.
- added #define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE

Quoted 7 lines
---
 tools/libxl/libxl.h          |  8 +++++++
 tools/libxl/libxl_dom.c      | 57 ++++++++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_internal.h |  2 ++
 tools/libxl/libxl_paths.c    | 10 ++++++++
 tools/libxl/libxl_types.idl  |  1 +
 tools/libxl/xl_cmdimpl.c     | 11 ++++++---
Quoted 1 line

You also need to patch manpage for this new option.

Yes, I'll do that.

Quoted 1 line

How does this new option interacts with bios= option?

That would be the same interaction that there is between device_model_version and device_model_override.

If someone provide bios_override without bios, the guest could fail to boot.

Quoted 51 lines
Quoted 51 lines
 6 files changed, 86 insertions(+), 3 deletions(-)
tools/libxl/libxl.h +8 -0
index fa87f53..d223c35 100644
@@ -876,6 +876,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
  */
 #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+ *
+ * libxl_domain_build_info has u.hvm.bios_firmware field which can be use
+ * to provide a different bios blob (like SeaBIOS or OVMF).
+ */
+#define LIBXL_HAVE_BUILDINFO_HVM_BIOS_FIRMWARE
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
tools/libxl/libxl_dom.c +22 -0
index 2269998..50abfbc 100644
@@ -863,6 +863,38 @@ err:
     return ret;
 }
 
+static int libxl__load_hvm_firmware_module(libxl__gc *gc,
+                                           const char *filename,
+                                           const char *what,
+                                           struct xc_hvm_firmware_module *m)
+{
+    int datalen = 0;
+    void *data = NULL;
+    int e;
+
+    LOG(DEBUG, "Loading %s: %s", what, filename);
+    e = libxl_read_file_contents(CTX, filename, &data, &datalen);
+    if (e) {
+        /*
+         * Print a message only on ENOENT, other error are logged by the
+         * function libxl_read_file_contents().
+         */
+        if (e == ENOENT)
+            LOGEV(ERROR, e, "failed to read %s file", what);
+        return ERROR_FAIL;
+    }
+    libxl__ptr_add(gc, data);
+    if (datalen) {
Quoted 8 lines

tools/libxl/libxl_dom.c err: · line 893

Quoted 6 lines
tools/libxl/libxl_dom.c +6 -0
+        /* Only accept non-empty files */
+        m->data = data;
+        m->length = datalen;
+    } else {
+        LOG(ERROR, "file %s for %s is empty", filename, what);
+        return ERROR_FAIL;

ERROR_INVAL is more appropriate.

OK.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#17 lore raw

PATCH v3 6/16 libxl: Load guest ACPI table from file

In reply to Anthony PERARD

A user can provide a different ACPI tables than the default one by using the existing "acpi_firmware" xl's config option or the field u.hvm.acpi_firmware.

libxl will check if the provided table is a DSDT or not.

---
Change in V3:
- use existing acpi_firmware option to provide an override for the acpi tables. Will check if it's a DSDT or an extra tables.

---
 tools/libxl/libxl_dom.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
tools/libxl/libxl_dom.c +26 -0
index 50abfbc..87853fd 100644
@@ -905,6 +905,7 @@ static int libxl__domain_firmware(libxl__gc *gc,
     int datalen = 0;
     void *data;
     const char *bios_filename = NULL;
+    const char *full_acpi_tables_filename = NULL;
 
     if (info->u.hvm.firmware)
         firmware = info->u.hvm.firmware;
@@ -964,6 +965,10 @@ static int libxl__domain_firmware(libxl__gc *gc,
                 abort();
             }
         }
+
+        full_acpi_tables_filename =
+            libxl__abs_path(gc, "dsdt_anycpu_qemu_xen.aml",
+                            libxl__xenfirmwaredir_path());
     }
 
     if (bios_filename) {
@@ -1008,6 +1013,27 @@ static int libxl__domain_firmware(libxl__gc *gc,
         }
     }
 
+    /*
+     * Check if the user supplied ACPI tables are the full tables, or if
+     * there are only extra tables. The full tables start with the DSDT
+     * table, and the signature is in the first four bytes.
+     */
+    if (!dom->acpi_module.length
+          || strncmp("DSDT", (char*)dom->acpi_module.data, 4)) {
+        if (full_acpi_tables_filename) {
+            rc = libxl__load_hvm_firmware_module(gc, full_acpi_tables_filename,
+                                                 "ACPI tables",
+                                                 &dom->full_acpi_module);
+            if (rc) goto out;
+        }
+    } else {
+        /* Use user supplied DSDT tables. */
+        dom->full_acpi_module.data = dom->acpi_module.data;
+        dom->full_acpi_module.length = dom->acpi_module.length;
+        dom->acpi_module.length = 0;
+        dom->acpi_module.data = NULL;
+    }
+
     return 0;
 out:
     assert(rc != 0);
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v3 06/16] libxl: Load guest ACPI table from file

Quoted 6 lines · Anthony PERARD

A user can provide a different ACPI tables than the default one by using the existing "acpi_firmware" xl's config option or the field u.hvm.acpi_firmware.

libxl will check if the provided table is a DSDT or not.

According to xl.cfg manpage, acpi_firmware= cann't be used to override DSDT, so you seem to be changing the semantics of existing option.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#19 lore raw

Re: [PATCH v3 06/16] libxl: Load guest ACPI table from file

Quoted 10 lines · Wei Liu
Quoted 6 lines · Anthony PERARD

A user can provide a different ACPI tables than the default one by using the existing "acpi_firmware" xl's config option or the field u.hvm.acpi_firmware.

libxl will check if the provided table is a DSDT or not.

According to xl.cfg manpage, acpi_firmware= cann't be used to override DSDT, so you seem to be changing the semantics of existing option.

Yes, that was an idea from Ian Campbell <[email protected]> I should at least change the manual.

Would it be OK to reuse this options? Or should I add a new option, maybe acpi_dsdt_override, or some other name?

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#20 lore raw

Re: [PATCH v3 06/16] libxl: Load guest ACPI table from file

Quoted 9 lines · Anthony PERARD
Quoted 8 lines · Wei Liu
Quoted 6 lines · Anthony PERARD

A user can provide a different ACPI tables than the default one by using the existing "acpi_firmware" xl's config option or the field u.hvm.acpi_firmware.

libxl will check if the provided table is a DSDT or not.

Quoted 9 lines
Quoted 2 lines

According to xl.cfg manpage, acpi_firmware= cann't be used to override DSDT, so you seem to be changing the semantics of existing option.

Yes, that was an idea from Ian Campbell <[email protected]> I should at least change the manual.

Would it be OK to reuse this options? Or should I add a new option, maybe acpi_dsdt_override, or some other name?

If repurposing the old option won't break existing guest then that's fine, otherwise a new option is required.

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#21 lore raw

PATCH v3 7/16 hvmloader: Grab the hvm_start_info pointer

In reply to Anthony PERARD

---
Change in V3:
- remove cmdline parser
- load hvm_start_info pointer earlier, before calling main().
- Add struct hvm_start_info definition to hvmloader.

---
 tools/firmware/hvmloader/hvm_start_info.h | 32 +++++++++++++++++++++++++++++++
 tools/firmware/hvmloader/hvmloader.c      |  6 ++++++
 2 files changed, 38 insertions(+)
 create mode 100644 tools/firmware/hvmloader/hvm_start_info.h
tools/firmware/hvmloader/hvm_start_info.h new file +32 -0
new file mode 100644
index 0000000..b95d60d
@@ -0,0 +1,32 @@
+#ifndef __HVM_START_INFO_H__
+#define __HVM_START_INFO_H__
+
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout resides in public/xen.h, this
+ * is just a way to represent the layout described there using C types.
+ *
+ * NB: the packed attribute is not really needed, but it helps us enforce
+ * the fact this this is just a representation, and it might indeed
+ * be required in the future if there are alignment changes.
+ */
+struct hvm_start_info {
+    uint32_t magic;             /* Contains the magic value 0x336ec578       */
+                                /* ("xEn3" with the 0x80 bit of the "E" set).*/
+    uint32_t version;           /* Version of this structure.                */
+    uint32_t flags;             /* SIF_xxx flags.                            */
+    uint32_t cmdline_paddr;     /* Physical address of the command line.     */
+    uint32_t nr_modules;        /* Number of modules passed to the kernel.   */
+    uint32_t modlist_paddr;     /* Physical address of an array of           */
+                                /* hvm_modlist_entry.                        */
+    uint32_t rsdp_paddr;        /* Physical address of the RSDP ACPI data    */
+                                /* structure.                                */
+} __attribute__((packed));
+
+struct hvm_modlist_entry {
+    uint64_t paddr;             /* Physical address of the module.           */
+    uint64_t size;              /* Size of the module in bytes.              */
+    uint64_t cmdline_paddr;     /* Physical address of the command line.     */
+    uint64_t reserved;
+} __attribute__((packed));
+#endif /* __HVM_START_INFO_H__ */
tools/firmware/hvmloader/hvmloader.c +6 -0
index 716d03c..20ec8dc 100644
@@ -28,6 +28,9 @@
 #include "vnuma.h"
 #include <xen/version.h>
 #include <xen/hvm/params.h>
+#include "hvm_start_info.h"
+
+const struct hvm_start_info *hvm_start_info;
 
 asm (
     "    .text                       \n"
@@ -46,6 +49,8 @@ asm (
     "    ljmp $"STR(SEL_CODE32)",$1f \n"
     "1:  movl $stack_top,%esp        \n"
     "    movl %esp,%ebp              \n"
+    /* store HVM start info ptr */
+    "    mov  %ebx, hvm_start_info   \n"
     "    call main                   \n"
     /* Relocate real-mode trampoline to 0x0. */
     "    mov  $trampoline_start,%esi \n"
@@ -258,6 +263,7 @@ int main(void)
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
 
     printf("HVM Loader\n");
+    BUG_ON(hvm_start_info->magic != XEN_HVM_START_MAGIC_VALUE);
 
     init_hypercalls();
 
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#22 lore raw

Re: [PATCH v3 07/16] hvmloader: Grab the hvm_start_info pointer

Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvm_start_info.h new file +22 -0
@@ -0,0 +1,32 @@
+#ifndef __HVM_START_INFO_H__
+#define __HVM_START_INFO_H__
+
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout resides in public/xen.h, this
+ * is just a way to represent the layout described there using C types.
+ *
+ * NB: the packed attribute is not really needed, but it helps us enforce
+ * the fact this this is just a representation, and it might indeed
+ * be required in the future if there are alignment changes.
+ */
+struct hvm_start_info {
+    uint32_t magic;             /* Contains the magic value 0x336ec578       */
+                                /* ("xEn3" with the 0x80 bit of the "E" set).*/
+    uint32_t version;           /* Version of this structure.                */
+    uint32_t flags;             /* SIF_xxx flags.                            */
+    uint32_t cmdline_paddr;     /* Physical address of the command line.     */
+    uint32_t nr_modules;        /* Number of modules passed to the kernel.   */
+    uint32_t modlist_paddr;     /* Physical address of an array of           */
+                                /* hvm_modlist_entry.                        */
+    uint32_t rsdp_paddr;        /* Physical address of the RSDP ACPI data    */

tools/firmware/hvmloader/hvm_start_info.h line 32

Quoted 10 lines
tools/firmware/hvmloader/hvm_start_info.h new file +10 -0
+                                /* structure.                                */
+} __attribute__((packed));
+
+struct hvm_modlist_entry {
+    uint64_t paddr;             /* Physical address of the module.           */
+    uint64_t size;              /* Size of the module in bytes.              */
+    uint64_t cmdline_paddr;     /* Physical address of the command line.     */
+    uint64_t reserved;
+} __attribute__((packed));
+#endif /* __HVM_START_INFO_H__ */

With there already being such a C representation in libxc, can't we make sure we have only one instance that will need adjustment upon future enhancements? (Perhaps it would still have been a good idea to expose such a C representation in public/xen.h.)

tools/firmware/hvmloader/hvm_start_info.h int main(void) · line 266

Quoted 5 lines
tools/firmware/hvmloader/hvm_start_info.h new file +1 -0
@@ -258,6 +263,7 @@ int main(void)
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
 
     printf("HVM Loader\n");
+    BUG_ON(hvm_start_info->magic != XEN_HVM_START_MAGIC_VALUE);

Wait - public/xen.h clearly says this is being handed for PVH guests only. How can you even de-reference the pointer unconditionally?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#23 lore raw

Re: [PATCH v3 07/16] hvmloader: Grab the hvm_start_info pointer

Quoted 10 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 266

Quoted 7 lines
Quoted 2 lines · On 29.02.16 at 17:37, <[email protected]> wrote:
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +1 -0
@@ -258,6 +263,7 @@ int main(void)
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
 
     printf("HVM Loader\n");
+    BUG_ON(hvm_start_info->magic != XEN_HVM_START_MAGIC_VALUE);

Wait - public/xen.h clearly says this is being handed for PVH guests only. How can you even de-reference the pointer unconditionally?

Ah, I see this is a result of patch 2, which so far I didn't look at in any detail, the title of which doesn't suggest such a behavioral change, and which also doesn't update the comment in public/xen.h.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#24 lore raw

PATCH v3 8/16 hvmloader: Locate the BIOS blob

In reply to Anthony PERARD

The BIOS can be found an entry called "bios" of the modlist of the hvm_start_info struct.

The found BIOS blob is not loaded by this patch, but only passed as argument to bios_load() function. It is going to be used by the next few patches.

---
Changes in V3:
- fix some codying style
- use module.cmdline to look for a module name instead of the main cmdline from hvm_start_info.

---
 tools/firmware/hvmloader/config.h    |  2 +-
 tools/firmware/hvmloader/hvmloader.c | 34 ++++++++++++++++++++++++++++++++--
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 tools/firmware/hvmloader/rombios.c   |  3 ++-
 tools/firmware/hvmloader/util.h      |  2 ++
 5 files changed, 39 insertions(+), 5 deletions(-)
tools/firmware/hvmloader/config.h +1 -1
index b838cf9..4c6d8ad 100644
@@ -22,7 +22,7 @@ struct bios_config {
     /* ROMS */
     void (*load_roms)(void);
 
-    void (*bios_load)(const struct bios_config *config);
+    void (*bios_load)(const struct bios_config *config, void *addr, uint32_t size);
 
     void (*bios_info_setup)(void);
     void (*bios_info_finish)(void);
tools/firmware/hvmloader/hvmloader.c +32 -2
index 20ec8dc..d319de0 100644
@@ -254,10 +254,32 @@ static void acpi_enable_sci(void)
     BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
 }
 
+const struct hvm_modlist_entry *get_module_entry(
+    const struct hvm_start_info *info,
+    const char *name)
+{
+    const struct hvm_modlist_entry *modlist =
+        (struct hvm_modlist_entry *)info->modlist_paddr;
+    int i;
+
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;
+        if ( !strcmp(name, (char*)module_name) )
+        {
+            BUG_ON(modlist[i].paddr > UINT_MAX);
+            return &modlist[i];
+        }
+    }
+
+    return NULL;
+}
+
 int main(void)
 {
     const struct bios_config *bios;
     int acpi_enabled;
+    const struct hvm_modlist_entry *bios_module;
 
     /* Initialise hypercall stubs with RET, rendering them no-ops. */
     memset((void *)HYPERCALL_PHYSICAL_ADDRESS, 0xc3 /* RET */, PAGE_SIZE);
@@ -293,8 +315,16 @@ int main(void)
     }
 
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
+    bios_module = get_module_entry(hvm_start_info, "bios");
+    if ( bios_module && bios->bios_load )
+    {
+        uint32_t paddr = bios_module->paddr;
+        bios->bios_load(bios, (void*)paddr, bios_module->size);
+    }
+    else if ( bios->bios_load )
+    {
+        bios->bios_load(bios, 0, 0);
+    }
     else
     {
         BUG_ON(bios->bios_address + bios->image_size >
tools/firmware/hvmloader/ovmf.c +2 -1
index db9fa7a..858a2d4 100644
@@ -93,7 +93,8 @@ static void ovmf_finish_bios_info(void)
     info->checksum = -checksum;
 }
 
-static void ovmf_load(const struct bios_config *config)
+static void ovmf_load(const struct bios_config *config,
+                      void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
     uint64_t addr = OVMF_BEGIN;
tools/firmware/hvmloader/rombios.c +2 -1
index 1f15b94..2ded844 100644
@@ -121,7 +121,8 @@ static void rombios_load_roms(void)
                option_rom_phys_addr + option_rom_sz - 1);
 }
 
-static void rombios_load(const struct bios_config *config)
+static void rombios_load(const struct bios_config *config,
+                         void *unused_addr, uint32_t unused_size)
 {
     uint32_t bioshigh;
     struct rombios_info *info;
tools/firmware/hvmloader/util.h +2 -0
index 132d915..d45c107 100644
@@ -25,6 +25,8 @@
 #undef NULL
 #define NULL ((void*)0)
 
+#define UINT_MAX (~0U)
+
 void __assert_failed(char *assertion, char *file, int line)
     __attribute__((noreturn));
 #define ASSERT(p) \
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#25 lore raw

Re: [PATCH v3 08/16] hvmloader: Locate the BIOS blob

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:

tools/firmware/hvmloader/hvmloader.c static void acpi_enable_sci(void) · line 263

Quoted 10 lines
tools/firmware/hvmloader/hvmloader.c +7 -0
@@ -254,10 +254,32 @@ static void acpi_enable_sci(void)
     BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
 }
 
+const struct hvm_modlist_entry *get_module_entry(
+    const struct hvm_start_info *info,
+    const char *name)
+{
+    const struct hvm_modlist_entry *modlist =
+        (struct hvm_modlist_entry *)info->modlist_paddr;
+    int i;

unsigned int

tools/firmware/hvmloader/hvmloader.c static void acpi_enable_sci(void) · line 267

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;

The right side is uint64_t, so you may be truncating here.

Also blank line between declaration(s) and statement(s) please.

tools/firmware/hvmloader/hvmloader.c int main(void) · line 322

Quoted 11 lines
tools/firmware/hvmloader/hvmloader.c +5 -2
@@ -293,8 +315,16 @@ int main(void)
     }
 
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
+    bios_module = get_module_entry(hvm_start_info, "bios");
+    if ( bios_module && bios->bios_load )
+    {
+        uint32_t paddr = bios_module->paddr;
+        bios->bios_load(bios, (void*)paddr, bios_module->size);

bios_module->size is a 64-bit quantity too, so would also need checking.

tools/firmware/hvmloader/hvmloader.c int main(void) · line 330

Quoted 8 lines
tools/firmware/hvmloader/hvmloader.c +5 -0
+    }
+    else if ( bios->bios_load )
+    {
+        bios->bios_load(bios, 0, 0);
+    }
     else
     {
         BUG_ON(bios->bios_address + bios->image_size >

Is all of the remaining code (from the first "else if" above) intended to go away eventually?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#26 lore raw

Re: [PATCH v3 08/16] hvmloader: Locate the BIOS blob

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -254,10 +254,32 @@ static void acpi_enable_sci(void)
     BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
 }
 
Quoted 9 lines

tools/firmware/hvmloader/hvmloader.c static void acpi_enable_sci(void) · line 263

Quoted 7 lines
tools/firmware/hvmloader/hvmloader.c +7 -0
+const struct hvm_modlist_entry *get_module_entry(
+    const struct hvm_start_info *info,
+    const char *name)
+{
+    const struct hvm_modlist_entry *modlist =
+        (struct hvm_modlist_entry *)info->modlist_paddr;
+    int i;

unsigned int

ok

Quoted 5 lines

tools/firmware/hvmloader/hvmloader.c static void acpi_enable_sci(void) · line 267

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;

The right side is uint64_t, so you may be truncating here.

Yes, I need to check that.

Quoted 1 line

Also blank line between declaration(s) and statement(s) please.

ok.

Quoted 14 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 322

Quoted 11 lines
tools/firmware/hvmloader/hvmloader.c +5 -2
@@ -293,8 +315,16 @@ int main(void)
     }
 
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
+    bios_module = get_module_entry(hvm_start_info, "bios");
+    if ( bios_module && bios->bios_load )
+    {
+        uint32_t paddr = bios_module->paddr;
+        bios->bios_load(bios, (void*)paddr, bios_module->size);

bios_module->size is a 64-bit quantity too, so would also need checking.

Yes.

Quoted 11 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 330

Quoted 8 lines
tools/firmware/hvmloader/hvmloader.c +5 -0
+    }
+    else if ( bios->bios_load )
+    {
+        bios->bios_load(bios, 0, 0);
+    }
     else
     {
         BUG_ON(bios->bios_address + bios->image_size >

Is all of the remaining code (from the first "else if" above) intended to go away eventually?

The "else if" would be kept for the benefit of rombios (if it's compiled in), and the last "else" will be turned into a BUG.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#27 lore raw

PATCH v3 9/16 hvmloader: Check modules whereabouts

In reply to Anthony PERARD

As perform_tests() is going to clear memory past 4MB, we check that the memory can be use.

---
New in V3

---
 tools/firmware/hvmloader/hvmloader.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/firmware/hvmloader/hvmloader.c +9 -0
index d319de0..a40503d 100644
@@ -303,6 +303,15 @@ int main(void)
 
     smp_initialise();
 
+    /* Check that tests does not use memory where modules are stored */
+    BUG_ON( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) >= 4 << 20 );
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].size )
+            BUG_ON( modlist[i].paddr + modlist[i].size >= 4ul << 20 );
+    }
     perform_tests();
 
     if ( bios->bios_info_setup )
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#28 lore raw

Re: [PATCH v3 09/16] hvmloader: Check modules whereabouts

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -303,6 +303,15 @@ int main(void)
 
     smp_initialise();

tools/firmware/hvmloader/hvmloader.c int main(void) · line 314

Quoted 10 lines
tools/firmware/hvmloader/hvmloader.c +9 -0
 
+    /* Check that tests does not use memory where modules are stored */
+    BUG_ON( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) >= 4 << 20 );
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].size )
+            BUG_ON( modlist[i].paddr + modlist[i].size >= 4ul << 20 );
+    }

First of all both checks should use > instead of >=. And then expecting all modules to live below 4Mb doesn't seem very reasonable.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#29 lore raw

Re: [PATCH v3 09/16] hvmloader: Check modules whereabouts

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -303,6 +303,15 @@ int main(void)
 
     smp_initialise();
 
Quoted 13 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 314

Quoted 9 lines
tools/firmware/hvmloader/hvmloader.c +9 -0
+    /* Check that tests does not use memory where modules are stored */
+    BUG_ON( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) >= 4 << 20 );
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].size )
+            BUG_ON( modlist[i].paddr + modlist[i].size >= 4ul << 20 );
+    }

First of all both checks should use > instead of >=. And then expecting all modules to live below 4Mb doesn't seem very reasonable.

Yes, and this can be an issue with OVMF, it's a 2MB binary. I'm not sure what to do about this, should I ignore perform_tests() if it going to clear the memory used by the modules?

I should probably check that the modules are outside the memory region that is going to be used by perform_tests(), instead of just checking that they are bellow 4MB.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#30 lore raw

Re: [PATCH v3 09/16] hvmloader: Check modules whereabouts

Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 03.03.16 at 17:00, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich

tools/firmware/hvmloader/hvmloader.c int main(void) · line 307

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +2 -0
@@ -303,6 +303,15 @@ int main(void)
 
     smp_initialise();
 
+    /* Check that tests does not use memory where modules are stored */
+    BUG_ON( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) >= 4 

<< 20 );

Quoted 8 lines
Quoted 7 lines
tools/firmware/hvmloader/hvmloader.c +7 -0
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].size )
+            BUG_ON( modlist[i].paddr + modlist[i].size >= 4ul << 20 );
+    }
Quoted 7 lines
Quoted 3 lines

First of all both checks should use > instead of >=. And then expecting all modules to live below 4Mb doesn't seem very reasonable.

Yes, and this can be an issue with OVMF, it's a 2MB binary. I'm not sure what to do about this, should I ignore perform_tests() if it going to clear the memory used by the modules?

Temporarily this might be an option, but ultimately the tests shouldn't assume a fixed memory location to be available.

Quoted 3 lines

I should probably check that the modules are outside the memory region that is going to be used by perform_tests(), instead of just checking that they are bellow 4MB.

Yes.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#31 lore raw

Re: [PATCH v3 09/16] hvmloader: Check modules whereabouts

In reply to Anthony PERARD
Quoted 20 lines · Anthony PERARD
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -303,6 +303,15 @@ int main(void)
 
     smp_initialise();
 
Quoted 12 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 314

Quoted 9 lines
tools/firmware/hvmloader/hvmloader.c +9 -0
+    /* Check that tests does not use memory where modules are stored */
+    BUG_ON( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) >= 4 << 20 );
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].size )
+            BUG_ON( modlist[i].paddr + modlist[i].size >= 4ul << 20 );
+    }

First of all both checks should use > instead of >=. And then expecting all modules to live below 4Mb doesn't seem very reasonable.

Quoted 7 lines

Yes, and this can be an issue with OVMF, it's a 2MB binary. I'm not sure what to do about this, should I ignore perform_tests() if it going to clear the memory used by the modules?

I should probably check that the modules are outside the memory region that is going to be used by perform_tests(), instead of just checking that they are bellow 4MB.

Now that I have published my Xen Test Framework, these hvmloader tests should be moved across and removed entirely from hvmloader. This was one of the original intentions.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#32 lore raw

PATCH v3 10/16 hvmloader: Load SeaBIOS from hvm_start_info modules

In reply to Anthony PERARD

... and do not include the SeaBIOS ROM into hvmloader anymore.

This also fix the dependency on roms.inc, hvmloader.o does not include it.

---
Change in V3:
- change makefile to not include seabios roms into roms.inc.
- update the struct bios_config with the location of the bios blob.

---
 tools/firmware/hvmloader/Makefile  | 15 +--------------
 tools/firmware/hvmloader/seabios.c | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 24 deletions(-)
tools/firmware/hvmloader/Makefile +1 -14
index f2f4791..ed0bfad 100644
@@ -45,7 +45,6 @@ CIRRUSVGA_DEBUG ?= n
 
 OVMF_DIR := ../ovmf-dir
 ROMBIOS_DIR := ../rombios
-SEABIOS_DIR := ../seabios-dir
 
 ifeq ($(CONFIG_ROMBIOS),y)
 STDVGA_ROM    := ../vgabios/VGABIOS-lgpl-latest.bin
@@ -80,19 +79,13 @@ endif
 ifeq ($(CONFIG_SEABIOS),y)
 OBJS += seabios.o
 CFLAGS += -DENABLE_SEABIOS
-ifeq ($(SEABIOS_PATH),)
-	SEABIOS_ROM := $(SEABIOS_DIR)/out/bios.bin
-else
-	SEABIOS_ROM := $(SEABIOS_PATH)
-endif
-ROMS += $(SEABIOS_ROM)
 endif
 
 .PHONY: all
 all: subdirs-all
 	$(MAKE) hvmloader
 
-ovmf.o rombios.o seabios.o hvmloader.o: roms.inc
+ovmf.o rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
 hvmloader: $(OBJS) acpi/acpi.a
@@ -109,12 +102,6 @@ ifneq ($(ROMBIOS_ROM),)
 	echo "#endif" >> [email protected]
 endif
 
-ifneq ($(SEABIOS_ROM),)
-	echo "#ifdef ROM_INCLUDE_SEABIOS" >> [email protected]
-	sh ./mkhex seabios $(SEABIOS_ROM) >> [email protected]
-	echo "#endif" >> [email protected]
-endif
-
 ifneq ($(OVMF_ROM),)
 	echo "#ifdef ROM_INCLUDE_OVMF" >> [email protected]
 	sh ./mkhex ovmf $(OVMF_ROM) >> [email protected]
tools/firmware/hvmloader/seabios.c +14 -10
index c6b3d9f..5d896e3 100644
@@ -27,9 +27,6 @@
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
 
-#define ROM_INCLUDE_SEABIOS
-#include "roms.inc"
-
 extern unsigned char dsdt_anycpu_qemu_xen[];
 extern int dsdt_anycpu_qemu_xen_len;
 
@@ -127,22 +124,29 @@ static void seabios_setup_e820(void)
     struct e820entry *e820 = scratch_alloc(sizeof(struct e820entry)*16, 0);
     info->e820 = (uint32_t)e820;
 
+    BUG_ON(seabios_config.bios_address == 0);
     /* SeaBIOS reserves memory in e820 as necessary so no low reservation. */
-    info->e820_nr = build_e820_table(e820, 0, 0x100000-sizeof(seabios));
+    info->e820_nr = build_e820_table(e820, 0, seabios_config.bios_address);
     dump_e820_table(e820, info->e820_nr);
 }
 
-struct bios_config seabios_config = {
-    .name = "SeaBIOS",
+static void seabios_load(const struct bios_config *bios,
+                         void *bios_addr, uint32_t bios_length)
+{
+    unsigned int bios_dest = 0x100000 - bios_length;
 
-    .image = seabios,
-    .image_size = sizeof(seabios),
+    BUG_ON(bios_dest + bios_length > HVMLOADER_PHYSICAL_ADDRESS);
+    memcpy((void *)bios_dest, bios_addr, bios_length);
+    seabios_config.bios_address = bios_dest;
+    seabios_config.image_size = bios_length;
+}
 
-    .bios_address = 0x100000 - sizeof(seabios),
+struct bios_config seabios_config = {
+    .name = "SeaBIOS",
 
     .load_roms = NULL,
 
-    .bios_load = NULL,
+    .bios_load = seabios_load,
 
     .bios_info_setup = seabios_setup_bios_info,
     .bios_info_finish = seabios_finish_bios_info,
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#33 lore raw

Re: [PATCH v3 10/16] hvmloader: Load SeaBIOS from hvm_start_info modules

tools/firmware/hvmloader/seabios.c static void seabios_setup_e820(void) · line 127

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/seabios.c +1 -0
@@ -127,22 +124,29 @@ static void seabios_setup_e820(void)
     struct e820entry *e820 = scratch_alloc(sizeof(struct e820entry)*16, 0);
     info->e820 = (uint32_t)e820;
 
+    BUG_ON(seabios_config.bios_address == 0);

I think this is too lax: Surely this shouldn't live below 0xC0000 nor above 0x100000?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#34 lore raw

Re: [PATCH v3 10/16] hvmloader: Load SeaBIOS from hvm_start_info modules

Quoted 9 lines · Jan Beulich

tools/firmware/hvmloader/seabios.c static void seabios_setup_e820(void) · line 127

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/seabios.c +1 -0
@@ -127,22 +124,29 @@ static void seabios_setup_e820(void)
     struct e820entry *e820 = scratch_alloc(sizeof(struct e820entry)*16, 0);
     info->e820 = (uint32_t)e820;
 
+    BUG_ON(seabios_config.bios_address == 0);

I think this is too lax: Surely this shouldn't live below 0xC0000 nor above 0x100000?

I was just trying to check that seabios_load() was called before this one. But I guest it does not hurt to expand the assertion.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#35 lore raw

PATCH v3 11/16 hvmloader: Load OVMF from modules

In reply to Anthony PERARD

... and do not include the OVMF ROM into hvmloader anymore.

---
Change in V3:
- change makefile to not include ovmf rom into roms.inc.
- update the struct bios_config with bios destination

---
 tools/firmware/hvmloader/Makefile | 15 +--------------
 tools/firmware/hvmloader/ovmf.c   | 27 ++++++++++-----------------
 2 files changed, 11 insertions(+), 31 deletions(-)
tools/firmware/hvmloader/Makefile +1 -14
index ed0bfad..dee1c6b 100644
@@ -43,7 +43,6 @@ endif
 
 CIRRUSVGA_DEBUG ?= n
 
-OVMF_DIR := ../ovmf-dir
 ROMBIOS_DIR := ../rombios
 
 ifeq ($(CONFIG_ROMBIOS),y)
@@ -61,12 +60,6 @@ ROMS :=
 ifeq ($(CONFIG_OVMF),y)
 OBJS += ovmf.o
 CFLAGS += -DENABLE_OVMF
-ifeq ($(OVMF_PATH),)
-	OVMF_ROM := $(OVMF_DIR)/ovmf.bin
-else
-	OVMF_ROM := $(OVMF_PATH)
-endif
-ROMS += $(OVMF_ROM)
 endif
 
 ifeq ($(CONFIG_ROMBIOS),y)
@@ -85,7 +78,7 @@ endif
 all: subdirs-all
 	$(MAKE) hvmloader
 
-ovmf.o rombios.o: roms.inc
+rombios.o: roms.inc
 smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\""
 
 hvmloader: $(OBJS) acpi/acpi.a
@@ -102,12 +95,6 @@ ifneq ($(ROMBIOS_ROM),)
 	echo "#endif" >> [email protected]
 endif
 
-ifneq ($(OVMF_ROM),)
-	echo "#ifdef ROM_INCLUDE_OVMF" >> [email protected]
-	sh ./mkhex ovmf $(OVMF_ROM) >> [email protected]
-	echo "#endif" >> [email protected]	
-endif 
-
 ifneq ($(STDVGA_ROM),)
 	echo "#ifdef ROM_INCLUDE_VGABIOS" >> [email protected]
 	sh ./mkhex vgabios_stdvga $(STDVGA_ROM) >> [email protected]
tools/firmware/hvmloader/ovmf.c +10 -17
index 858a2d4..89a005e 100644
@@ -34,17 +34,10 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
-#define ROM_INCLUDE_OVMF
-#include "roms.inc"
-
-#define OVMF_SIZE               (sizeof(ovmf))
 #define OVMF_MAXOFFSET          0x000FFFFFULL
-#define OVMF_BEGIN              (0x100000000ULL - ((OVMF_SIZE + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET))
-#define OVMF_END                (OVMF_BEGIN + OVMF_SIZE)
 #define LOWCHUNK_BEGIN          0x000F0000
 #define LOWCHUNK_SIZE           0x00010000
 #define LOWCHUNK_MAXOFFSET      0x0000FFFF
-#define LOWCHUNK_END            (OVMF_BEGIN + OVMF_SIZE)
 #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
@@ -97,16 +90,20 @@ static void ovmf_load(const struct bios_config *config,
                       void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
-    uint64_t addr = OVMF_BEGIN;
+    uint64_t addr = 0x100000000ULL
+        - ((bios_length + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET);
+    uint64_t ovmf_end = addr + bios_length;
+
+    ovmf_config.bios_address = addr;
+    ovmf_config.image_size = bios_length;
 
     /* Copy low-reset vector portion. */
-    memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
-           + OVMF_SIZE
-           - LOWCHUNK_SIZE,
+    memcpy((void *) LOWCHUNK_BEGIN,
+           (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,
            LOWCHUNK_SIZE);
 
     /* Ensure we have backing page prior to moving FD. */
-    while ( (addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT) )
+    while ( (addr >> PAGE_SHIFT) != (ovmf_end >> PAGE_SHIFT) )
     {
         mfn = (uint32_t) (addr >> PAGE_SHIFT);
         addr += PAGE_SIZE;
@@ -114,7 +111,7 @@ static void ovmf_load(const struct bios_config *config,
     }
 
     /* Copy FD. */
-    memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
+    memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
 }
 
 static void ovmf_acpi_build_tables(void)
@@ -151,10 +148,6 @@ static void ovmf_setup_e820(void)
 struct bios_config ovmf_config =  {
     .name = "OVMF",
 
-    .image = ovmf,
-    .image_size = sizeof(ovmf),
-
-    .bios_address = OVMF_BEGIN,
     .bios_load = ovmf_load,
 
     .load_roms = 0,
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#36 lore raw

Re: [PATCH v3 11/16] hvmloader: Load OVMF from modules

Quoted 48 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/ovmf.c +9 -12
@@ -34,17 +34,10 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
-#define ROM_INCLUDE_OVMF
-#include "roms.inc"
-
-#define OVMF_SIZE               (sizeof(ovmf))
 #define OVMF_MAXOFFSET          0x000FFFFFULL
-#define OVMF_BEGIN              (0x100000000ULL - ((OVMF_SIZE + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET))
-#define OVMF_END                (OVMF_BEGIN + OVMF_SIZE)
 #define LOWCHUNK_BEGIN          0x000F0000
 #define LOWCHUNK_SIZE           0x00010000
 #define LOWCHUNK_MAXOFFSET      0x0000FFFF
-#define LOWCHUNK_END            (OVMF_BEGIN + OVMF_SIZE)
 #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
@@ -97,16 +90,20 @@ static void ovmf_load(const struct bios_config *config,
                       void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
-    uint64_t addr = OVMF_BEGIN;
+    uint64_t addr = 0x100000000ULL
+        - ((bios_length + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET);
+    uint64_t ovmf_end = addr + bios_length;
+
+    ovmf_config.bios_address = addr;
+    ovmf_config.image_size = bios_length;
 
     /* Copy low-reset vector portion. */
-    memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
-           + OVMF_SIZE
-           - LOWCHUNK_SIZE,
+    memcpy((void *) LOWCHUNK_BEGIN,
+           (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,
            LOWCHUNK_SIZE);
 
     /* Ensure we have backing page prior to moving FD. */
-    while ( (addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT) )
+    while ( (addr >> PAGE_SHIFT) != (ovmf_end >> PAGE_SHIFT) )
     {
         mfn = (uint32_t) (addr >> PAGE_SHIFT);
         addr += PAGE_SIZE;

tools/firmware/hvmloader/ovmf.c static void ovmf_load(const struct bios_config *config, · line 115

Quoted 6 lines
tools/firmware/hvmloader/ovmf.c +1 -1
@@ -114,7 +111,7 @@ static void ovmf_load(const struct bios_config *config,
     }
 
     /* Copy FD. */
-    memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
+    memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
 }

Is this safe, considering that source and destination may now overlap? Thinking about it, the same consideration applies to BIOS placement below 1Mb too. Roger - should we perhaps amend the respective hvm_start_info comment to exclude anything getting placed below 1Mb?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#37 lore raw

Re: [PATCH v3 11/16] hvmloader: Load OVMF from modules

Quoted 50 lines · Jan Beulich
Quoted 50 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/ovmf.c +9 -12
@@ -34,17 +34,10 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
-#define ROM_INCLUDE_OVMF
-#include "roms.inc"
-
-#define OVMF_SIZE               (sizeof(ovmf))
 #define OVMF_MAXOFFSET          0x000FFFFFULL
-#define OVMF_BEGIN              (0x100000000ULL - ((OVMF_SIZE + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET))
-#define OVMF_END                (OVMF_BEGIN + OVMF_SIZE)
 #define LOWCHUNK_BEGIN          0x000F0000
 #define LOWCHUNK_SIZE           0x00010000
 #define LOWCHUNK_MAXOFFSET      0x0000FFFF
-#define LOWCHUNK_END            (OVMF_BEGIN + OVMF_SIZE)
 #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
@@ -97,16 +90,20 @@ static void ovmf_load(const struct bios_config *config,
                       void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
-    uint64_t addr = OVMF_BEGIN;
+    uint64_t addr = 0x100000000ULL
+        - ((bios_length + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET);
+    uint64_t ovmf_end = addr + bios_length;
+
+    ovmf_config.bios_address = addr;
+    ovmf_config.image_size = bios_length;
 
     /* Copy low-reset vector portion. */
-    memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
-           + OVMF_SIZE
-           - LOWCHUNK_SIZE,
+    memcpy((void *) LOWCHUNK_BEGIN,
+           (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,
            LOWCHUNK_SIZE);
 
     /* Ensure we have backing page prior to moving FD. */
-    while ( (addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT) )
+    while ( (addr >> PAGE_SHIFT) != (ovmf_end >> PAGE_SHIFT) )
     {
         mfn = (uint32_t) (addr >> PAGE_SHIFT);
         addr += PAGE_SIZE;
@@ -114,7 +111,7 @@ static void ovmf_load(const struct bios_config *config,
     }
 
Quoted 8 lines

tools/firmware/hvmloader/ovmf.c static void ovmf_load(const struct bios_config *config, · line 115

Quoted 4 lines
tools/firmware/hvmloader/ovmf.c +1 -1
     /* Copy FD. */
-    memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
+    memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
 }

Is this safe, considering that source and destination may now overlap? Thinking about it, the same consideration applies to BIOS placement below 1Mb too.

It's probably not safe, it just happen to work right now. I guest I can add some checking, or leave it up to libxc to manage the memory and write this blob just after hvmloader, like it's done right now.

I think I'll add some bug_on to catch unexpected changes.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#38 lore raw

Re: [PATCH v3 11/16] hvmloader: Load OVMF from modules

Quoted 60 lines · Anthony PERARD
Quoted 50 lines · Jan Beulich
Quoted 50 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/ovmf.c +9 -12
@@ -34,17 +34,10 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/memory.h>
 
-#define ROM_INCLUDE_OVMF
-#include "roms.inc"
-
-#define OVMF_SIZE               (sizeof(ovmf))
 #define OVMF_MAXOFFSET          0x000FFFFFULL
-#define OVMF_BEGIN              (0x100000000ULL - ((OVMF_SIZE + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET))
-#define OVMF_END                (OVMF_BEGIN + OVMF_SIZE)
 #define LOWCHUNK_BEGIN          0x000F0000
 #define LOWCHUNK_SIZE           0x00010000
 #define LOWCHUNK_MAXOFFSET      0x0000FFFF
-#define LOWCHUNK_END            (OVMF_BEGIN + OVMF_SIZE)
 #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
 
 extern unsigned char dsdt_anycpu_qemu_xen[];
@@ -97,16 +90,20 @@ static void ovmf_load(const struct bios_config *config,
                       void *bios_addr, uint32_t bios_length)
 {
     xen_pfn_t mfn;
-    uint64_t addr = OVMF_BEGIN;
+    uint64_t addr = 0x100000000ULL
+        - ((bios_length + OVMF_MAXOFFSET) & ~OVMF_MAXOFFSET);
+    uint64_t ovmf_end = addr + bios_length;
+
+    ovmf_config.bios_address = addr;
+    ovmf_config.image_size = bios_length;
 
     /* Copy low-reset vector portion. */
-    memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
-           + OVMF_SIZE
-           - LOWCHUNK_SIZE,
+    memcpy((void *) LOWCHUNK_BEGIN,
+           (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,
            LOWCHUNK_SIZE);
 
     /* Ensure we have backing page prior to moving FD. */
-    while ( (addr >> PAGE_SHIFT) != (OVMF_END >> PAGE_SHIFT) )
+    while ( (addr >> PAGE_SHIFT) != (ovmf_end >> PAGE_SHIFT) )
     {
         mfn = (uint32_t) (addr >> PAGE_SHIFT);
         addr += PAGE_SIZE;
@@ -114,7 +111,7 @@ static void ovmf_load(const struct bios_config *config,
     }
 
Quoted 8 lines

tools/firmware/hvmloader/ovmf.c static void ovmf_load(const struct bios_config *config, · line 115

Quoted 4 lines
tools/firmware/hvmloader/ovmf.c +1 -1
     /* Copy FD. */
-    memcpy((void *) OVMF_BEGIN, config->image, OVMF_SIZE);
+    memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
 }

Is this safe, considering that source and destination may now overlap? Thinking about it, the same consideration applies to BIOS placement below 1Mb too.

Quoted 6 lines

It's probably not safe, it just happen to work right now. I guest I can add some checking, or leave it up to libxc to manage the memory and write this blob just after hvmloader, like it's done right now.

I think I'll add some bug_on to catch unexpected changes.

If the only concern is overlapping region (not overwriting something that needs to be used later), using memmove should be good enough?

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#39 lore raw

PATCH v3 12/16 hvmloader: Specific bios_load function required

In reply to Anthony PERARD

All BIOS but ROMBIOS needs to be loaded via modules.

ROMBIOS is handled as a special case.

---
Change in V3:
- reprint Main BIOS in bios map with now available information from bios modules.
- handle rombios, and keep its built-in ROMs.

---
 tools/firmware/hvmloader/hvmloader.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tools/firmware/hvmloader/hvmloader.c +10 -6
index a40503d..cc52302 100644
@@ -325,21 +325,25 @@ int main(void)
 
     printf("Loading %s ...\n", bios->name);
     bios_module = get_module_entry(hvm_start_info, "bios");
-    if ( bios_module && bios->bios_load )
+    if ( bios_module )
     {
         uint32_t paddr = bios_module->paddr;
         bios->bios_load(bios, (void*)paddr, bios_module->size);
     }
-    else if ( bios->bios_load )
+#ifdef ENABLE_ROMBIOS
+    else if ( bios == &rombios_config )
     {
         bios->bios_load(bios, 0, 0);
     }
+#endif
     else
     {
-        BUG_ON(bios->bios_address + bios->image_size >
-               HVMLOADER_PHYSICAL_ADDRESS);
-        memcpy((void *)bios->bios_address, bios->image,
-               bios->image_size);
+        /*
+         * If there is no BIOS module supplied and if there is no embeded BIOS
+         * image, then we failed. Only rombios might have an embedded bios blob.
+         */
+        printf("no BIOS ROM image found\n");
+        BUG();
     }
 
     if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v3 12/16
#40 lore raw

Re: [PATCH v3 12/16] hvmloader: Specific bios_load function required

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:

All BIOS but ROMBIOS needs to be loaded via modules.

ROMBIOS is handled as a special case.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#41 lore raw

PATCH v3 13/16 hvmloader: Load ACPI tables from hvm_start_info module

In reply to Anthony PERARD

... and use it with both SeaBIOS and OVMF.

---
Changes in V3:
- handle rombios

---
 tools/firmware/hvmloader/config.h    |  2 +-
 tools/firmware/hvmloader/hvmloader.c | 20 +++++++++++++++++++-
 tools/firmware/hvmloader/ovmf.c      |  9 +++------
 tools/firmware/hvmloader/rombios.c   |  3 ++-
 tools/firmware/hvmloader/seabios.c   |  9 +++------
 5 files changed, 28 insertions(+), 15 deletions(-)
tools/firmware/hvmloader/config.h +1 -1
index 4c6d8ad..2c39637 100644
@@ -29,7 +29,7 @@ struct bios_config {
 
     void (*e820_setup)(void);
 
-    void (*acpi_build_tables)(void);
+    void (*acpi_build_tables)(void* addr, uint32_t size);
     void (*create_mp_tables)(void);
     void (*create_smbios_tables)(void);
     void (*create_pir_tables)(void);
tools/firmware/hvmloader/hvmloader.c +19 -1
index cc52302..e7b0139 100644
@@ -365,8 +365,26 @@ int main(void)
 
         if ( bios->acpi_build_tables )
         {
+            const struct hvm_modlist_entry *acpi_module;
+            acpi_module = get_module_entry(hvm_start_info, "acpi");
             printf("Loading ACPI ...\n");
-            bios->acpi_build_tables();
+            if ( acpi_module )
+            {
+                uint32_t paddr = acpi_module->paddr;
+                bios->acpi_build_tables((void*)paddr,
+                                        acpi_module->size);
+            }
+#ifdef ENABLE_ROMBIOS
+            else if ( bios == &rombios_config )
+            {
+                bios->acpi_build_tables(0, 0);
+            }
+#endif
+            else
+            {
+                printf("no ACPI DSDT image found\n");
+                BUG();
+            }
         }
 
         acpi_enable_sci();
tools/firmware/hvmloader/ovmf.c +3 -6
index 89a005e..c1612ea 100644
@@ -40,9 +40,6 @@
 #define LOWCHUNK_MAXOFFSET      0x0000FFFF
 #define OVMF_INFO_PHYSICAL_ADDRESS 0x00001000
 
-extern unsigned char dsdt_anycpu_qemu_xen[];
-extern int dsdt_anycpu_qemu_xen_len;
-
 #define OVMF_INFO_MAX_TABLES 4
 struct ovmf_info {
     char signature[14]; /* XenHVMOVMF\0\0\0\0 */
@@ -114,11 +111,11 @@ static void ovmf_load(const struct bios_config *config,
     memcpy((void *) ovmf_config.bios_address, bios_addr, bios_length);
 }
 
-static void ovmf_acpi_build_tables(void)
+static void ovmf_acpi_build_tables(void *addr, uint32_t length)
 {
     struct acpi_config config = {
-        .dsdt_anycpu = dsdt_anycpu_qemu_xen,
-        .dsdt_anycpu_len = dsdt_anycpu_qemu_xen_len,
+        .dsdt_anycpu = addr,
+        .dsdt_anycpu_len = length,
         .dsdt_15cpu = NULL, 
         .dsdt_15cpu_len = 0
     };
tools/firmware/hvmloader/rombios.c +2 -1
index 2ded844..732a7ff 100644
@@ -172,7 +172,8 @@ static void reset_bios_checksum(void)
     *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum;
 }
 
-static void rombios_acpi_build_tables(void)
+static void rombios_acpi_build_tables(void *unused_addr,
+                                      uint32_t unused_size)
 {
     struct acpi_config config = {
         .dsdt_anycpu = dsdt_anycpu,
tools/firmware/hvmloader/seabios.c +3 -6
index 5d896e3..b55a7c9 100644
@@ -27,9 +27,6 @@
 #include "smbios_types.h"
 #include "acpi/acpi2_0.h"
 
-extern unsigned char dsdt_anycpu_qemu_xen[];
-extern int dsdt_anycpu_qemu_xen_len;
-
 struct seabios_info {
     char signature[14]; /* XenHVMSeaBIOS\0 */
     uint8_t length;     /* Length of this struct */
@@ -87,12 +84,12 @@ static void add_table(uint32_t t)
     info->tables_nr++;
 }
 
-static void seabios_acpi_build_tables(void)
+static void seabios_acpi_build_tables(void *addr, uint32_t length)
 {
     uint32_t rsdp = (uint32_t)scratch_alloc(sizeof(struct acpi_20_rsdp), 0);
     struct acpi_config config = {
-        .dsdt_anycpu = dsdt_anycpu_qemu_xen,
-        .dsdt_anycpu_len = dsdt_anycpu_qemu_xen_len,
+        .dsdt_anycpu = addr,
+        .dsdt_anycpu_len = length,
         .dsdt_15cpu = NULL,
         .dsdt_15cpu_len = 0,
     };
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#42 lore raw

Re: [PATCH v3 13/16] hvmloader: Load ACPI tables from hvm_start_info module

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -365,8 +365,26 @@ int main(void)
 
         if ( bios->acpi_build_tables )
         {

tools/firmware/hvmloader/hvmloader.c int main(void) · line 376

Quoted 10 lines
tools/firmware/hvmloader/hvmloader.c +8 -1
+            const struct hvm_modlist_entry *acpi_module;
+            acpi_module = get_module_entry(hvm_start_info, "acpi");
             printf("Loading ACPI ...\n");
-            bios->acpi_build_tables();
+            if ( acpi_module )
+            {
+                uint32_t paddr = acpi_module->paddr;
+                bios->acpi_build_tables((void*)paddr,
+                                        acpi_module->size);
+            }

Hmm, so far it was the build process which ensured the right ACPI tables would be used with the corresponding BIOS. The disconnect that gets introduced here worries me a little, since things having got out of sync may be rather hard to diagnose (as they may surface only much later).

tools/firmware/hvmloader/hvmloader.c int main(void) · line 387

Quoted 11 lines
tools/firmware/hvmloader/hvmloader.c +11 -0
+#ifdef ENABLE_ROMBIOS
+            else if ( bios == &rombios_config )
+            {
+                bios->acpi_build_tables(0, 0);
+            }
+#endif
+            else
+            {
+                printf("no ACPI DSDT image found\n");
+                BUG();
+            }

Is this really fatal? It's not like "no ACPI" == "end of the world", is it?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#43 lore raw

Re: [PATCH v3 13/16] hvmloader: Load ACPI tables from hvm_start_info module

Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +6 -1
@@ -365,8 +365,26 @@ int main(void)
 
         if ( bios->acpi_build_tables )
         {
+            const struct hvm_modlist_entry *acpi_module;
+            acpi_module = get_module_entry(hvm_start_info, "acpi");
             printf("Loading ACPI ...\n");
-            bios->acpi_build_tables();
+            if ( acpi_module )
+            {
+                uint32_t paddr = acpi_module->paddr;
+                bios->acpi_build_tables((void*)paddr,
Quoted 8 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 376

Quoted 2 lines
tools/firmware/hvmloader/hvmloader.c +2 -0
+                                        acpi_module->size);
+            }

Hmm, so far it was the build process which ensured the right ACPI tables would be used with the corresponding BIOS. The disconnect that gets introduced here worries me a little, since things having got out of sync may be rather hard to diagnose (as they may surface only much later).

So, my ultimate goal with this series was to be able to create a guest with QEMU's Q35 machine, which would need a different ACPI tables.

Also, I would say that the ACPI tables are already disconnected from the thing they describe, the device model QEMU. I don't think there is much information about the BIOS backed into the DSDT table.

Quoted 6 lines
Quoted 6 lines
tools/firmware/hvmloader/hvmloader.c +6 -0
+#ifdef ENABLE_ROMBIOS
+            else if ( bios == &rombios_config )
+            {
+                bios->acpi_build_tables(0, 0);
+            }
+#endif
Quoted 8 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 387

Quoted 5 lines
tools/firmware/hvmloader/hvmloader.c +5 -0
+            else
+            {
+                printf("no ACPI DSDT image found\n");
+                BUG();
+            }

Is this really fatal? It's not like "no ACPI" == "end of the world", is it?

I guest it's not fatal, I'll give it a try and just print a warning.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#44 lore raw

Re: [PATCH v3 13/16] hvmloader: Load ACPI tables from hvm_start_info module

Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 03.03.16 at 18:59, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +6 -1
@@ -365,8 +365,26 @@ int main(void)
 
         if ( bios->acpi_build_tables )
         {
+            const struct hvm_modlist_entry *acpi_module;
+            acpi_module = get_module_entry(hvm_start_info, "acpi");
             printf("Loading ACPI ...\n");
-            bios->acpi_build_tables();
+            if ( acpi_module )
+            {
+                uint32_t paddr = acpi_module->paddr;
+                bios->acpi_build_tables((void*)paddr,
Quoted 8 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 376

Quoted 2 lines
tools/firmware/hvmloader/hvmloader.c +2 -0
+                                        acpi_module->size);
+            }

Hmm, so far it was the build process which ensured the right ACPI tables would be used with the corresponding BIOS. The disconnect that gets introduced here worries me a little, since things having got out of sync may be rather hard to diagnose (as they may surface only much later).

Quoted 6 lines

So, my ultimate goal with this series was to be able to create a guest with QEMU's Q35 machine, which would need a different ACPI tables.

Also, I would say that the ACPI tables are already disconnected from the thing they describe, the device model QEMU. I don't think there is much information about the BIOS backed into the DSDT table.

But then why would the Q35 model need a different one? Or the other way around, why wouldn't that other one be usable with with the current machine type (or more generally, why couldn't we have one that fits all machine types we mean to support)?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#45 lore raw

Re: [PATCH v3 13/16] hvmloader: Load ACPI tables from hvm_start_info module

Quoted 29 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 03.03.16 at 18:59, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +6 -1
@@ -365,8 +365,26 @@ int main(void)
 
         if ( bios->acpi_build_tables )
         {
+            const struct hvm_modlist_entry *acpi_module;
+            acpi_module = get_module_entry(hvm_start_info, "acpi");
             printf("Loading ACPI ...\n");
-            bios->acpi_build_tables();
+            if ( acpi_module )
+            {
+                uint32_t paddr = acpi_module->paddr;
+                bios->acpi_build_tables((void*)paddr,
Quoted 8 lines

tools/firmware/hvmloader/hvmloader.c int main(void) · line 376

Quoted 2 lines
tools/firmware/hvmloader/hvmloader.c +2 -0
+                                        acpi_module->size);
+            }

Hmm, so far it was the build process which ensured the right ACPI tables would be used with the corresponding BIOS. The disconnect that gets introduced here worries me a little, since things having got out of sync may be rather hard to diagnose (as they may surface only much later).

So, my ultimate goal with this series was to be able to create a guest with QEMU's Q35 machine, which would need a different ACPI tables.

Quoted 8 lines
Quoted 3 lines

Also, I would say that the ACPI tables are already disconnected from the thing they describe, the device model QEMU. I don't think there is much information about the BIOS backed into the DSDT table.

But then why would the Q35 model need a different one? Or the other way around, why wouldn't that other one be usable with with the current machine type (or more generally, why couldn't we have one that fits all machine types we mean to support)?

I have not though about using the same one for both. I could try to change the tables we have to make it work with both. But that for another time.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#46 lore raw

PATCH v3 14/16 hvmloader: Compile out the qemu-xen ACPI tables

In reply to Anthony PERARD

It should now be loaded by libxl.

---
 tools/firmware/hvmloader/acpi/Makefile | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
tools/firmware/hvmloader/acpi/Makefile +2 -6
index a3041d3..3252ddf 100644
@@ -17,7 +17,7 @@
 XEN_ROOT = $(CURDIR)/../../../..
 include $(XEN_ROOT)/tools/firmware/Rules.mk
 
-C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c dsdt_anycpu_qemu_xen.c
+C_SRC = build.c dsdt_anycpu.c dsdt_15cpu.c static_tables.c
 OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
 CFLAGS += $(CFLAGS_xeninclude)
@@ -48,12 +48,8 @@ $(filter dsdt_%cpu.c,$(C_SRC)): %.c: iasl %.asl
 	echo "int $*_len=sizeof($*);" >>$@
 	rm -f $*.aml $*.hex
 
-dsdt_anycpu_qemu_xen.c: dsdt_anycpu_qemu_xen.aml
 dsdt_anycpu_qemu_xen.aml: %.aml: iasl %.asl
-	iasl -vs -p $* -tc $*.asl
-	sed -e 's/AmlCode/$*/g' $*.hex >$*.c
-	echo "int $*_len=sizeof($*);" >>$*.c
-	rm -f $*.hex
+	iasl -vs -p $* $*.asl
 
 iasl:
 	@echo
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Acked-by on v3 14/16
#47 lore raw

Re: [PATCH v3 14/16] hvmloader: Compile out the qemu-xen ACPI tables

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:

It should now be loaded by libxl.

Pending concerns to previous patches, this one on its own clearly looks fine, i.e.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#48 lore raw

PATCH v3 15/16 hvmloader: Always build-in SeaBIOS and OVMF loader

In reply to Anthony PERARD
---
 tools/firmware/hvmloader/Makefile    | 11 +----------
 tools/firmware/hvmloader/hvmloader.c |  4 ----
 2 files changed, 1 insertion(+), 14 deletions(-)
tools/firmware/hvmloader/Makefile +1 -10
index dee1c6b..9f7357f 100644
@@ -37,6 +37,7 @@ OBJS  = hvmloader.o mp_tables.o util.o smbios.o
 OBJS += smp.o cacheattr.o xenbus.o vnuma.o
 OBJS += e820.o pci.o pir.o ctype.o
 OBJS += hvm_param.o
+OBJS += ovmf.o seabios.o
 ifeq ($(debug),y)
 OBJS += tests.o
 endif
@@ -57,11 +58,6 @@ endif
 
 ROMS := 
 
-ifeq ($(CONFIG_OVMF),y)
-OBJS += ovmf.o
-CFLAGS += -DENABLE_OVMF
-endif
-
 ifeq ($(CONFIG_ROMBIOS),y)
 OBJS += optionroms.o 32bitbios_support.o rombios.o
 CFLAGS += -DENABLE_ROMBIOS
@@ -69,11 +65,6 @@ ROMBIOS_ROM := $(ROMBIOS_DIR)/BIOS-bochs-latest
 ROMS += $(ROMBIOS_ROM) $(STDVGA_ROM) $(CIRRUSVGA_ROM) $(ETHERBOOT_ROMS)
 endif
 
-ifeq ($(CONFIG_SEABIOS),y)
-OBJS += seabios.o
-CFLAGS += -DENABLE_SEABIOS
-endif
-
 .PHONY: all
 all: subdirs-all
 	$(MAKE) hvmloader
tools/firmware/hvmloader/hvmloader.c +0 -4
index e7b0139..bd774d5 100644
@@ -210,12 +210,8 @@ struct bios_info {
 #ifdef ENABLE_ROMBIOS
     { "rombios", &rombios_config, },
 #endif
-#ifdef ENABLE_SEABIOS
     { "seabios", &seabios_config, },
-#endif
-#ifdef ENABLE_OVMF
     { "ovmf", &ovmf_config, },
-#endif
     { NULL, NULL }
 };
 
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#50 lore raw

PATCH v3 16/16 hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH ...

In reply to Anthony PERARD

... to compile SeaBIOS and OVMF. Only depends on CONFIG_*.

If --with-system-* configure option is used, then set *_CONFIG=n to not compile SEABIOS and OVMF.

---
Please, run ./autogen.sh on this patch.

---
 tools/configure.ac      | 6 ++++--
 tools/firmware/Makefile | 8 --------
 2 files changed, 4 insertions(+), 10 deletions(-)
tools/configure.ac +4 -2
index 6929006..0cff3fc 100644
@@ -206,12 +206,13 @@ AC_ARG_WITH([system-seabios],
     AS_HELP_STRING([--with-system-seabios@<:@=PATH@:>@],
        [Use system supplied seabios PATH instead of building and installing
         our own version]),[
+    # Disable compilation of SeaBIOS.
+    seabios=n
     case $withval in
         no) seabios_path= ;;
         *)  seabios_path=$withval ;;
     esac
 ],[])
-AC_SUBST(seabios_path)
 AC_DEFINE_UNQUOTED([SEABIOS_PATH],
                    ["${seabios_path:-$XENFIRMWAREDIR/seabios.bin}"],
                    [SeaBIOS path])
@@ -220,12 +221,13 @@ AC_ARG_WITH([system-ovmf],
     AS_HELP_STRING([--with-system-ovmf@<:@=PATH@:>@],
        [Use system supplied OVMF PATH instead of building and installing
         our own version]),[
+    # Disable compilation of OVMF.
+    ovmf=n
     case $withval in
         no) ovmf_path= ;;
         *)  ovmf_path=$withval ;;
     esac
 ],[])
-AC_SUBST(ovmf_path)
 AC_DEFINE_UNQUOTED([OVMF_PATH],
                    ["${ovmf_path:-$XENFIRMWAREDIR/ovmf.bin}"],
                    [OVMF path])
tools/firmware/Makefile +0 -8
index aa1ab54..d7b508e 100644
@@ -6,12 +6,8 @@ TARGET      := hvmloader/hvmloader
 INST_DIR := $(DESTDIR)$(XENFIRMWAREDIR)
 
 SUBDIRS-y :=
-ifeq ($(OVMF_PATH),)
 SUBDIRS-$(CONFIG_OVMF) += ovmf-dir
-endif
-ifeq ($(SEABIOS_PATH),)
 SUBDIRS-$(CONFIG_SEABIOS) += seabios-dir
-endif
 SUBDIRS-$(CONFIG_ROMBIOS) += rombios
 SUBDIRS-$(CONFIG_ROMBIOS) += vgabios
 SUBDIRS-$(CONFIG_ROMBIOS) += etherboot
@@ -50,15 +46,11 @@ install: all
 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET) $(INST_DIR)
 ifeq ($(CONFIG_SEABIOS),y)
-ifeq ($(SEABIOS_PATH),)
 	$(INSTALL_DATA) $(SEABIOS_ROM) $(INST_DIR)/seabios.bin
 endif
-endif
 ifeq ($(CONFIG_OVMF),y)
-ifeq ($(OVMF_PATH),)
 	$(INSTALL_DATA) $(OVMF_ROM) $(INST_DIR)/ovmf.bin
 endif
-endif
 	$(INSTALL_DATA) $(ACPI_TABLE_QEMU_PC_I440FX) $(INST_DIR)
 
 .PHONY: clean
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#51 lore raw

Re: [PATCH v3 16/16] hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH ...

Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 25.02.16 at 15:56, <[email protected]> wrote:

... to compile SeaBIOS and OVMF. Only depends on CONFIG_*.

If --with-system-* configure option is used, then set *_CONFIG=n to not compile SEABIOS and OVMF.

The subject prefix is a little misleading, as this doesn't really touch hvmloader in any way.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#52 lore raw

Re: [PATCH v3 16/16] hvmloader: do not depend on SEABIOS_PATH or OVMF_PATH ...

In reply to Anthony PERARD
Quoted 7 lines · Anthony PERARD

... to compile SeaBIOS and OVMF. Only depends on CONFIG_*.

If --with-system-* configure option is used, then set *_CONFIG=n to not compile SEABIOS and OVMF.

Just notice this patch belongs to toolstack.

But I guess it should be modified or changed given my comment on the --with-system-* in previous patch.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#53 lore raw
In reply to Anthony PERARD
Quoted 15 lines · Anthony PERARD

Hi all,

Many changes in V3:
no more cmdline, but use each modules' cmdline to provide a name for it. in libxc:
- use xc_dom_alloc_segment() to load modules. see patch #1.
- avoid duplication of code between PVHv2 and hvmloader for the initialisation of hvm_start_info.
in xl/libxl:
- only one new option, bios_firmware. acpi_firmware is reused, see patch #6.
in hvmloader:
- handle rombios as separate case.
more detail in each patches.

Quoted 2 lines

I've look at loading the BIOS and the ACPI tables via the toolstack instead of having them embedded in the hvmloader binary.

This is what I've been trying to do for HVMlite/PVHv2 guests. Roger and I have a PoC toolstack code that loads limited ACPI data into the guest but I wonder whether these patches already do this.

I haven't gone over the series in detail yet. Does this allow toolstack to load RSDP and then R/XSDT, FADT etc. directly to guest memory or are they passed to hvmloader to do so via hvm_start_info? (I think it's the latter based on how I read patch 13 but I am not sure).

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#54 lore raw
Quoted 19 lines · Boris Ostrovsky
Quoted 15 lines · Anthony PERARD

Hi all,

Many changes in V3:
no more cmdline, but use each modules' cmdline to provide a name for it. in libxc:
- use xc_dom_alloc_segment() to load modules. see patch #1.
- avoid duplication of code between PVHv2 and hvmloader for the initialisation of hvm_start_info.
in xl/libxl:
- only one new option, bios_firmware. acpi_firmware is reused, see patch #6.
in hvmloader:
- handle rombios as separate case.
more detail in each patches.

Quoted 2 lines

I've look at loading the BIOS and the ACPI tables via the toolstack instead of having them embedded in the hvmloader binary.

Quoted 8 lines

This is what I've been trying to do for HVMlite/PVHv2 guests. Roger and I have a PoC toolstack code that loads limited ACPI data into the guest but I wonder whether these patches already do this.

I haven't gone over the series in detail yet. Does this allow toolstack to load RSDP and then R/XSDT, FADT etc. directly to guest memory or are they passed to hvmloader to do so via hvm_start_info? (I think it's the latter based on how I read patch 13 but I am not sure).

Those patches only allow to load the DSDT table from a file, rather than having it embedded in the hvmloader binary.

hvmloader take care of building the RSDT XSDT FADT etc.

And yes, the DSDT table is passed to hvmloader via the hvm_start_info.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#55 lore raw
In reply to Anthony PERARD

In this series, there are plenty of places where one blob loaded by libxl to be consume by hvmloader is called acpi_module or acpi_table... where in fact it is only the DSDT table. I think I'm going to do some renaming to include "dsdt" into those names.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#56 lore raw
Quoted 4 lines · Anthony PERARD

In this series, there are plenty of places where one blob loaded by libxl to be consume by hvmloader is called acpi_module or acpi_table... where in fact it is only the DSDT table. I think I'm going to do some renaming to include "dsdt" into those names.

The DSDT cannot possibly come from anywhere other than hvmloader (as a logic extension of Xen). It is very hardware specific, including bits of ACPI emulated by Xen itself.

There are plenty of improvements which can be made over the current status quo by splitting out the optional parts into extra SSDTs, but having the DSDT itself come from another source will cause all kinds of problems for the domain.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#57 lore raw
Quoted 6 lines · Andrew Cooper
Quoted 4 lines · Anthony PERARD

In this series, there are plenty of places where one blob loaded by libxl to be consume by hvmloader is called acpi_module or acpi_table... where in fact it is only the DSDT table. I think I'm going to do some renaming to include "dsdt" into those names.

Quoted 8 lines

The DSDT cannot possibly come from anywhere other than hvmloader (as a logic extension of Xen). It is very hardware specific, including bits of ACPI emulated by Xen itself.

There are plenty of improvements which can be made over the current status quo by splitting out the optional parts into extra SSDTs, but having the DSDT itself come from another source will cause all kinds of problems for the domain.

Ok.

I think I leave the acpi tables alone in the next revision of the series and only load the BIOS.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel