Skip to contentSkip to conversation

Load BIOS via toolstack instead of been embedded in hvmloader.

PATCH Superseded Anthony PERARD 11 participants 73 messages Mar 14, 2016 – Apr 19, 2016 1 message not in the archive

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

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

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS 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-v4

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 (14):
libxc: Rework extra module initialisation
libxc: Prepare a start info structure for hvmloader
configure: #define SEABIOS_PATH and OVMF_PATH firmware/makefile: install BIOS blob ...
libxl: Load guest BIOS from file
xen: Move the hvm_start_info C representation from libxc to
public/xen.h
hvmloader: Grab the hvm_start_info pointer
hvmloader: Locate the BIOS blob
hvmloader: Check modules whereabouts in perform_tests
hvmloader: Load SeaBIOS from hvm_start_info modules
hvmloader: Load OVMF from modules
hvmloader: Specific bios_load function required
hvmloader: Always build-in SeaBIOS and OVMF loader
configure: do not depend on SEABIOS_PATH or OVMF_PATH ...

 docs/man/xl.cfg.pod.5                |   9 +++
 tools/configure.ac                   |  12 +++-
 tools/firmware/Makefile              |  13 ++--
 tools/firmware/hvmloader/Makefile    |  39 +---------
 tools/firmware/hvmloader/config.h    |   2 +-
 tools/firmware/hvmloader/hvmloader.c |  63 ++++++++++++++---
 tools/firmware/hvmloader/ovmf.c      |  33 ++++-----
 tools/firmware/hvmloader/rombios.c   |   3 +-
 tools/firmware/hvmloader/seabios.c   |  24 ++++---
 tools/firmware/hvmloader/tests.c     |  20 ++++++
 tools/firmware/hvmloader/util.h      |   5 ++
 tools/libxc/include/xc_dom.h         |  34 +--------
 tools/libxc/xc_dom_hvmloader.c       | 133 +++++++++++------------------------
 tools/libxc/xc_dom_x86.c             | 132 +++++++++++++++++++++++-----------
 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 ++-
 xen/include/public/xen.h             |  33 ++++++++-
 21 files changed, 391 insertions(+), 253 deletions(-)
Signature · 7 lines
Anthony PERARD


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

PATCH v4 1/14 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.

---
Changes in V4:
- check that guest_addr_out have a reasonable value.

New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 131 ++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +38 -93
index 330d5e8..7cf5854 100644
@@ -129,98 +129,52 @@ 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;
+        if ( module->guest_addr_out > UINT32_MAX ||
+             module->guest_addr_out + module->length > UINT32_MAX )
+        {
+            DOMPRINTF("%s: Module %s would be loaded abrove 4GB",
+                      __FUNCTION__, name);
+            goto err;
+        }
+    }
 
     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 +183,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 +215,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 v4 01/14] libxc: Rework extra module initialisation

Quoted 3 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.

s/of/at/ ?

Or are you rather staying that the memory for ACPI modules and such is offset by one 1MB after hvmloader image?

In other words:

/-----------\ <- 0

|           |
| hvmloader |
| binary    |
+-----------| <- 800kB
|           |
|  empty    |
+-----------+ <- 1.8MB
| ACPI DATA |
|           |
+-----------+ <- 2.8MB
|           |
| .....     |
+-----------| <- 4MB
|  scratch  |
| space for |
| hvmloader |

\-----------/ <- 8MB

Is what can happen now? But prior to this you had:

/-----------\ <- 0

|           |
| hvmloader |
| binary    |
+-----------| <- 800kB
|           |
|  empty    |
+-----------+ <- 1MB
| ACPI DATA |
|           |
+-----------+ <- 2MB 
|           |
| .....     |
+-----------| <- 4MB
|  scratch  |
| space for |
| hvmloader |

\-----------/ <- 8MB

?

Quoted 2 lines

In later patches, while trying to load a firmware such as OVMF, the later

.. what later patches? These ones? You may want to mention which ones.

Quoted 1 line

could easily be loaded past the address 4MB (OVMF is a 2MB binary), but

Why would it be loaded past 4MB? Why not in the space right after ACPI DSDT and such?

Quoted 2 lines

hvmloader use a range of memory from 4MB to 8MB to perform tests and in the process, clear the memory, before loading the modules.

s/clear/clears/

Quoted 133 lines

---
Changes in V4:
- check that guest_addr_out have a reasonable value.

New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 131 ++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +29 -78
index 330d5e8..7cf5854 100644
@@ -129,98 +129,52 @@ 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;
+        if ( module->guest_addr_out > UINT32_MAX ||
+             module->guest_addr_out + module->length > UINT32_MAX )
+        {
+            DOMPRINTF("%s: Module %s would be loaded abrove 4GB",
+                      __FUNCTION__, name);
+            goto err;
+        }
+    }
 
     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);
-    }
-

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

Quoted 10 lines
tools/libxc/xc_dom_hvmloader.c +5 -4
-    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;

You can't be that code thought. That is some nice deletion of code.

Now is this safe for migration?
I presume so since this is all E820_RESERVED righT? No funny business there?

Quoted 41 lines
tools/libxc/xc_dom_hvmloader.c +4 -11
-    return rc;
+    return 0;
+err:
+    return -1;
 }
 
 static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom)
@@ -229,7 +183,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 +215,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

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

#3 lore raw

Re: [PATCH v4 01/14] libxc: Rework extra module initialisation

Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 3 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.

s/of/at/ ?

Or are you rather staying that the memory for ACPI modules and such is offset by one 1MB after hvmloader image?

I was trying to translate this in to english:
*mstart_out = MKALIGN(elf->pend, MB_ALIGN) + (MB_ALIGN); which came with that comment:
/* Want to place the modules 1Mb+change behind the loader image. */

[...]

Actually, the current situation before this patch would be, with every bios compiled in, and with the use of acpi_firmware:
/-----------\ <- 0MB

|   other   |
|   stuff   |
+-----------+ <- 1MB
| hvmloader |
| binary    |
+-----------| <- 3.8MB
|  empty    |
+-----------+ <- 4MB <- begining of memory used by perform_tests()
|  ...      |
+-----------+ <- 5MB
| ACPI DATA |
+-----------+ <- 5.4MB
|   ...     |

\-----------/ <- 8MB <- end of memory used by perform_tests()

I just tried to to use the options acpi_firmware, and that the result. When hvmloader tried to load the extra acpi data, I have this:
Loading SeaBIOS ...
Creating MP tables ...
Loading ACPI ...
*** HVMLoader bug at util.c:460
*** HVMLoader crashed.

That the BUG_ON in mem_alloc(). I think it's trying to allocate memory of size 0.

Quoted 3 lines
Quoted 1 line

In later patches, while trying to load a firmware such as OVMF, the later

.. what later patches? These ones? You may want to mention which ones.

Ok, I will. That would be "hvmloader: Load OVMF from modules" and previous ones of the patch series.

Quoted 26 lines
Quoted 1 line

could easily be loaded past the address 4MB (OVMF is a 2MB binary), but

Why would it be loaded past 4MB? Why not in the space right after ACPI DSDT and such?

Quoted 2 lines

hvmloader use a range of memory from 4MB to 8MB to perform tests and in the process, clear the memory, before loading the modules.

s/clear/clears/

Quoted 15 lines

---
Changes in V4:
- check that guest_addr_out have a reasonable value.

New patch in V3.

---
 tools/libxc/xc_dom_hvmloader.c | 131 ++++++++++++-----------------------------
 1 file changed, 38 insertions(+), 93 deletions(-)
tools/libxc/xc_dom_hvmloader.c +0 -0
index 330d5e8..7cf5854 100644

[...]

Quoted 8 lines

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

Quoted 7 lines

- error_out:

tools/libxc/xc_dom_hvmloader.c +4 -1
-    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;
Quoted 5 lines

You can't be that code thought. That is some nice deletion of code.

Now is this safe for migration?
I presume so since this is all E820_RESERVED righT? No funny business there?

The acpi module is moved to another location by hvmloader. I guess that the same for the smbios module. So I think it's safe for migration, and it does not change anything once hvmloader has finished.

Signature · 6 lines
Anthony PERARD

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

PATCH v4 2/14 libxc: Prepare a start info structure for hvmloader

In reply to Anthony PERARD

... and load BIOS into guest memory.

This adds a new firmware module, bios_module. It is
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 V4:
- change title to suggest the change of beavior
- remove code to load acpi tables (dsdt)
- Update public/xen.h about hvm_start_info available on other HVM guest in %ebx.

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   |   3 +
 tools/libxc/xc_dom_hvmloader.c |   2 +
 tools/libxc/xc_dom_x86.c       | 132 ++++++++++++++++++++++++++++-------------
 xen/include/public/xen.h       |   2 +-
 4 files changed, 96 insertions(+), 43 deletions(-)
tools/libxc/include/xc_dom.h +3 -0
index 6ebe946..93f894c 100644
@@ -209,6 +209,9 @@ struct xc_dom_image {
     /* If unset disables the setup of the IOREQ pages. */
     bool device_model;
 
+    /* BIOS passed to HVMLOADER */
+    struct xc_hvm_firmware_module bios_module;
+
     /* Extra ACPI tables passed to HVMLOADER */
     struct xc_hvm_firmware_module acpi_module;
 
tools/libxc/xc_dom_hvmloader.c +2 -0
index 7cf5854..606351a 100644
@@ -167,6 +167,8 @@ 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->acpi_module, "acpi module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "smbios module");
tools/libxc/xc_dom_x86.c +90 -42

188 lines not on this page · raw message

xen/include/public/xen.h +1 -1
index 64ba7ab..1cfec5c 100644
@@ -798,7 +798,7 @@ struct start_info {
 typedef struct start_info start_info_t;
 
 /*
- * Start of day structure passed to PVH guests in %ebx.
+ * Start of day structure passed to PVH guests and to HVM guests in %ebx.
  *
  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
  * of the address fields should be treated as not present.
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v4 02/14] libxc: Prepare a start info structure for hvmloader

Quoted 9 lines · Anthony PERARD

... and load BIOS into guest memory.

This adds a new firmware module, bios_module. It is
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.

CC-ing Boris and Roger since this impact the PVH code.

And therefore not snipping the code so they can see it in its full glory.

Quoted 93 lines

---
Change in V4:
- change title to suggest the change of beavior
- remove code to load acpi tables (dsdt)
- Update public/xen.h about hvm_start_info available on other HVM guest in %ebx.

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   |   3 +
 tools/libxc/xc_dom_hvmloader.c |   2 +
 tools/libxc/xc_dom_x86.c       | 132 ++++++++++++++++++++++++++++-------------
 xen/include/public/xen.h       |   2 +-
 4 files changed, 96 insertions(+), 43 deletions(-)
tools/libxc/include/xc_dom.h +3 -0
index 6ebe946..93f894c 100644
@@ -209,6 +209,9 @@ struct xc_dom_image {
     /* If unset disables the setup of the IOREQ pages. */
     bool device_model;
 
+    /* BIOS passed to HVMLOADER */
+    struct xc_hvm_firmware_module bios_module;
+
     /* Extra ACPI tables passed to HVMLOADER */
     struct xc_hvm_firmware_module acpi_module;
 
tools/libxc/xc_dom_hvmloader.c +2 -0
index 7cf5854..606351a 100644
@@ -167,6 +167,8 @@ 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->acpi_module, "acpi module");
     if ( rc ) goto err;
     rc = module_init_one(dom, &dom->smbios_module, "smbios module");
tools/libxc/xc_dom_x86.c +4 -8
index bdec40a..9c56d55 100644
@@ -69,6 +69,9 @@
 #define round_up(addr, mask)     ((addr) | (mask))
 #define round_pg_up(addr)  (((addr) + PAGE_SIZE_X86 - 1) & ~(PAGE_SIZE_X86 - 1))
 
+#define HVMLOADER_MODULE_MAX_COUNT 1
+#define HVMLOADER_MODULE_NAME_SIZE 10
+
 struct xc_dom_params {
     unsigned levels;
     xen_vaddr_t vaddr_mask;
@@ -590,6 +593,7 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
     xen_pfn_t special_array[X86_HVM_NR_SPECIAL_PAGES];
     xen_pfn_t ioreq_server_array[NR_IOREQ_SERVER_PAGES];
     xc_interface *xch = dom->xch;
+    size_t start_info_size = sizeof(struct hvm_start_info);
 
     /* Allocate and clear special pages. */
     for ( i = 0; i < X86_HVM_NR_SPECIAL_PAGES; i++ )
@@ -624,8 +628,6 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
 
     if ( !dom->device_model )
     {
-        size_t start_info_size = sizeof(struct hvm_start_info);
-
         if ( dom->cmdline )
         {
             dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
@@ -635,17 +637,26 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
         /* Limited to one module. */
         if ( dom->ramdisk_blob )
             start_info_size += sizeof(struct hvm_modlist_entry);
-
-        rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
-                                  "HVMlite start info", 0, start_info_size);
-        if ( rc != 0 )
-        {
-            DOMPRINTF("Unable to reserve memory for the start info");

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 647

Quoted 10 lines
tools/libxc/xc_dom_x86.c +5 -2
-            goto out;
-        }
     }
     else
     {
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size +=
+            HVMLOADER_MODULE_NAME_SIZE * HVMLOADER_MODULE_MAX_COUNT;

What about \0 ? Ah, the strncpy we use adds \0 byte. But it would be nice to mention that somewhere. Perhaps mention:

The HVMLOADER_MODULE_NAME_SIZE accounts for NUL byte?

Quoted 33 lines
tools/libxc/xc_dom_x86.c +26 -0
+    }
+
+    rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
+                              "HVMlite start info", 0, start_info_size);
+    if ( rc != 0 )
+    {
+        DOMPRINTF("Unable to reserve memory for the start info");
+        goto out;
+    }
+
+    if ( dom->device_model )
+    {
         /*
          * Allocate and clear additional ioreq server pages. The default
          * server will use the IOREQ and BUFIOREQ special pages above.
@@ -1696,39 +1707,68 @@ static int alloc_pgtables_hvm(struct xc_dom_image *dom)
     return 0;
 }
 
+static void add_module_to_list(struct xc_dom_image *dom,
+                               struct xc_hvm_firmware_module *module,
+                               const char *name,
+                               struct hvm_modlist_entry *modlist,
+                               struct hvm_start_info *start_info)
+{
+    uint32_t index = start_info->nr_modules;
+    if ( module->length == 0 )
+        return;
+
+    assert(start_info->nr_modules < HVMLOADER_MODULE_MAX_COUNT);
+    assert(strnlen(name, HVMLOADER_MODULE_NAME_SIZE)
+           < HVMLOADER_MODULE_NAME_SIZE);
+

tools/libxc/xc_dom_x86.c static int alloc_pgtables_hvm(struct xc_dom_image *dom) · line 1733

Quoted 10 lines
tools/libxc/xc_dom_x86.c +10 -0
+    modlist[index].paddr = module->guest_addr_out;
+    modlist[index].size = module->length;
+    strncpy((char*)(modlist + HVMLOADER_MODULE_MAX_COUNT)
+            + HVMLOADER_MODULE_NAME_SIZE * index,
+            name, HVMLOADER_MODULE_NAME_SIZE);
+    modlist[index].cmdline_paddr =
+        (dom->start_info_seg.pfn << PAGE_SHIFT) +
+        ((uintptr_t)modlist - (uintptr_t)start_info) +
+        sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT +
+        HVMLOADER_MODULE_NAME_SIZE * index;

That looks right, but boy it takes a bit of thinking to make sure it is right. Perhaps put a comment outlining where it ought to be (so folks reading the first time can feel OK they got it right?)

Quoted 125 lines
tools/libxc/xc_dom_x86.c +45 -32
+
+    start_info->nr_modules++;
+}
+
 static int bootlate_hvm(struct xc_dom_image *dom)
 {
     uint32_t domid = dom->guest_domid;
     xc_interface *xch = dom->xch;
+    struct hvm_start_info *start_info;
+    size_t start_info_size;
+    void *start_page;
+    struct hvm_modlist_entry *modlist;
 
-    if ( !dom->device_model )
-    {
-        struct hvm_start_info *start_info;
-        size_t start_info_size;
-        void *start_page;
-
-        start_info_size = sizeof(*start_info) + dom->cmdline_size;
-        if ( dom->ramdisk_blob )
-            start_info_size += sizeof(struct hvm_modlist_entry);
+    start_info_size = sizeof(*start_info) + dom->cmdline_size;
+    if ( dom->ramdisk_blob )
+        start_info_size += sizeof(struct hvm_modlist_entry);
 
-        if ( start_info_size >
-             dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
-        {
-            DOMPRINTF("Trying to map beyond start_info_seg");
-            return -1;
-        }
+    if ( start_info_size >
+         dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
+    {
+        DOMPRINTF("Trying to map beyond start_info_seg");
+        return -1;
+    }
 
-        start_page = xc_map_foreign_range(xch, domid, start_info_size,
-                                          PROT_READ | PROT_WRITE,
-                                          dom->start_info_seg.pfn);
-        if ( start_page == NULL )
-        {
-            DOMPRINTF("Unable to map HVM start info page");
-            return -1;
-        }
+    start_page = xc_map_foreign_range(xch, domid, start_info_size,
+                                      PROT_READ | PROT_WRITE,
+                                      dom->start_info_seg.pfn);
+    if ( start_page == NULL )
+    {
+        DOMPRINTF("Unable to map HVM start info page");
+        return -1;
+    }
 
-        start_info = start_page;
+    start_info = start_page;
+    modlist = start_page + sizeof(*start_info) + dom->cmdline_size;
 
+    if ( !dom->device_model )
+    {
         if ( dom->cmdline )
         {
             char *cmdline = start_page + sizeof(*start_info);
@@ -1740,22 +1780,30 @@ static int bootlate_hvm(struct xc_dom_image *dom)
 
         if ( dom->ramdisk_blob )
         {
-            struct hvm_modlist_entry *modlist =
-                start_page + sizeof(*start_info) + dom->cmdline_size;
 
             modlist[0].paddr = dom->ramdisk_seg.vstart - dom->parms.virt_base;
             modlist[0].size = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart;
-            start_info->modlist_paddr = (dom->start_info_seg.pfn << PAGE_SHIFT) +
-                                ((uintptr_t)modlist - (uintptr_t)start_info);
             start_info->nr_modules = 1;
         }
-
-        start_info->magic = XEN_HVM_START_MAGIC_VALUE;
-
-        munmap(start_page, start_info_size);
     }
     else
     {
+        add_module_to_list(dom, &dom->bios_module, "bios",
+                           modlist, start_info);
+    }
+
+    if ( start_info->nr_modules )
+    {
+        start_info->modlist_paddr = (dom->start_info_seg.pfn << PAGE_SHIFT) +
+                            ((uintptr_t)modlist - (uintptr_t)start_info);
+    }
+
+    start_info->magic = XEN_HVM_START_MAGIC_VALUE;
+
+    munmap(start_page, start_info_size);
+
+    if ( dom->device_model )
+    {
         void *hvm_info_page;
 
         if ( (hvm_info_page = xc_map_foreign_range(
xen/include/public/xen.h +1 -1
index 64ba7ab..1cfec5c 100644
@@ -798,7 +798,7 @@ struct start_info {
 typedef struct start_info start_info_t;
 
 /*
- * Start of day structure passed to PVH guests in %ebx.
+ * Start of day structure passed to PVH guests and to HVM guests in %ebx.
  *
  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
  * of the address fields should be treated as not present.
Signature · 7 lines
Anthony PERARD


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

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

#6 lore raw

Re: [PATCH v4 02/14] libxc: Prepare a start info structure for hvmloader

Quoted 38 lines · Konrad Rzeszutek Wilk
Quoted 19 lines · Anthony PERARD
tools/libxc/xc_dom_x86.c +0 -8
@@ -624,8 +628,6 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
 
      if ( !dom->device_model )
      {
-        size_t start_info_size = sizeof(struct hvm_start_info);
-
          if ( dom->cmdline )
          {
              dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
@@ -635,17 +637,26 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
          /* Limited to one module. */
          if ( dom->ramdisk_blob )
              start_info_size += sizeof(struct hvm_modlist_entry);
-
-        rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
-                                  "HVMlite start info", 0, start_info_size);
-        if ( rc != 0 )
-        {
-            DOMPRINTF("Unable to reserve memory for the start info");

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 647

Quoted 10 lines
tools/libxc/xc_dom_x86.c +5 -2
-            goto out;
-        }
      }
      else
      {
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size +=
+            HVMLOADER_MODULE_NAME_SIZE * HVMLOADER_MODULE_MAX_COUNT;

What about \0 ? Ah, the strncpy we use adds \0 byte. But it would be nice to mention that somewhere. Perhaps mention:

The HVMLOADER_MODULE_NAME_SIZE accounts for NUL byte?

Quoted 12 lines

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 659

Quoted 12 lines
tools/libxc/xc_dom_x86.c +12 -0
+    }
+
+    rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
+                              "HVMlite start info", 0, start_info_size);
+    if ( rc != 0 )
+    {
+        DOMPRINTF("Unable to reserve memory for the start info");
+        goto out;
+    }
+
+    if ( dom->device_model )
+    {

Can you fold this into the 'else' clause above and move xc_dom_alloc_segment() down?

Quoted 53 lines
Quoted 53 lines
tools/libxc/xc_dom_x86.c +22 -23
+
  static int bootlate_hvm(struct xc_dom_image *dom)
  {
      uint32_t domid = dom->guest_domid;
      xc_interface *xch = dom->xch;
+    struct hvm_start_info *start_info;
+    size_t start_info_size;
+    void *start_page;
+    struct hvm_modlist_entry *modlist;
 
-    if ( !dom->device_model )
-    {
-        struct hvm_start_info *start_info;
-        size_t start_info_size;
-        void *start_page;
-
-        start_info_size = sizeof(*start_info) + dom->cmdline_size;
-        if ( dom->ramdisk_blob )
-            start_info_size += sizeof(struct hvm_modlist_entry);
+    start_info_size = sizeof(*start_info) + dom->cmdline_size;
+    if ( dom->ramdisk_blob )
+        start_info_size += sizeof(struct hvm_modlist_entry);
 
-        if ( start_info_size >
-             dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
-        {
-            DOMPRINTF("Trying to map beyond start_info_seg");
-            return -1;
-        }
+    if ( start_info_size >
+         dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
+    {
+        DOMPRINTF("Trying to map beyond start_info_seg");
+        return -1;
+    }
 
-        start_page = xc_map_foreign_range(xch, domid, start_info_size,
-                                          PROT_READ | PROT_WRITE,
-                                          dom->start_info_seg.pfn);
-        if ( start_page == NULL )
-        {
-            DOMPRINTF("Unable to map HVM start info page");
-            return -1;
-        }
+    start_page = xc_map_foreign_range(xch, domid, start_info_size,
+                                      PROT_READ | PROT_WRITE,
+                                      dom->start_info_seg.pfn);
+    if ( start_page == NULL )
+    {
+        DOMPRINTF("Unable to map HVM start info page");
+        return -1;
+    }
Quoted 3 lines

tools/libxc/xc_dom_x86.c static int alloc_pgtables_hvm(struct xc_dom_image *dom) · line 1768

Quoted 3 lines
tools/libxc/xc_dom_x86.c +2 -1
-        start_info = start_page;
+    start_info = start_page;
+    modlist = start_page + sizeof(*start_info) + dom->cmdline_size;

I think we can drop start_page and use start_info only. They are the same, aren't they?

-boris

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

#7 lore raw

Re: [PATCH v4 02/14] libxc: Prepare a start info structure for hvmloader

Quoted 38 lines · Boris Ostrovsky
Quoted 37 lines · Konrad Rzeszutek Wilk
Quoted 18 lines · Anthony PERARD
tools/libxc/xc_dom_x86.c +0 -8
@@ -624,8 +628,6 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
     if ( !dom->device_model )
     {
-        size_t start_info_size = sizeof(struct hvm_start_info);
-
         if ( dom->cmdline )
         {
             dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
@@ -635,17 +637,26 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
         /* Limited to one module. */
         if ( dom->ramdisk_blob )
             start_info_size += sizeof(struct hvm_modlist_entry);
-
-        rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
-                                  "HVMlite start info", 0, start_info_size);
-        if ( rc != 0 )
-        {
-            DOMPRINTF("Unable to reserve memory for the start info");

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 647

Quoted 10 lines
tools/libxc/xc_dom_x86.c +5 -2
-            goto out;
-        }
     }
     else
     {
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size +=
+            HVMLOADER_MODULE_NAME_SIZE * HVMLOADER_MODULE_MAX_COUNT;

What about \0 ? Ah, the strncpy we use adds \0 byte. But it would be nice to mention that somewhere. Perhaps mention:

The HVMLOADER_MODULE_NAME_SIZE accounts for NUL byte?

Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
tools/libxc/xc_dom_x86.c +4 -0
+    }
+
+    rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
+                              "HVMlite start info", 0, start_info_size);
Quoted 8 lines

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 659

Quoted 8 lines
tools/libxc/xc_dom_x86.c +8 -0
+    if ( rc != 0 )
+    {
+        DOMPRINTF("Unable to reserve memory for the start info");
+        goto out;
+    }
+
+    if ( dom->device_model )
+    {

Can you fold this into the 'else' clause above and move xc_dom_alloc_segment() down?

Yes, I will.

Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
tools/libxc/xc_dom_x86.c +20 -23
+
 static int bootlate_hvm(struct xc_dom_image *dom)
 {
     uint32_t domid = dom->guest_domid;
     xc_interface *xch = dom->xch;
+    struct hvm_start_info *start_info;
+    size_t start_info_size;
+    void *start_page;
+    struct hvm_modlist_entry *modlist;
-    if ( !dom->device_model )
-    {
-        struct hvm_start_info *start_info;
-        size_t start_info_size;
-        void *start_page;
-
-        start_info_size = sizeof(*start_info) + dom->cmdline_size;
-        if ( dom->ramdisk_blob )
-            start_info_size += sizeof(struct hvm_modlist_entry);
+    start_info_size = sizeof(*start_info) + dom->cmdline_size;
+    if ( dom->ramdisk_blob )
+        start_info_size += sizeof(struct hvm_modlist_entry);
-        if ( start_info_size >
-             dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
-        {
-            DOMPRINTF("Trying to map beyond start_info_seg");
-            return -1;
-        }
+    if ( start_info_size >
+         dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
+    {
+        DOMPRINTF("Trying to map beyond start_info_seg");
+        return -1;
+    }
-        start_page = xc_map_foreign_range(xch, domid, start_info_size,
-                                          PROT_READ | PROT_WRITE,
-                                          dom->start_info_seg.pfn);
-        if ( start_page == NULL )
-        {
-            DOMPRINTF("Unable to map HVM start info page");
-            return -1;
-        }
+    start_page = xc_map_foreign_range(xch, domid, start_info_size,
+                                      PROT_READ | PROT_WRITE,
+                                      dom->start_info_seg.pfn);
+    if ( start_page == NULL )
+    {
+        DOMPRINTF("Unable to map HVM start info page");
Quoted 8 lines
Quoted 5 lines

tools/libxc/xc_dom_x86.c static int alloc_pgtables_hvm(struct xc_dom_image *dom) · line 1768

Quoted 5 lines
tools/libxc/xc_dom_x86.c +4 -1
+        return -1;
+    }
-        start_info = start_page;
+    start_info = start_page;
+    modlist = start_page + sizeof(*start_info) + dom->cmdline_size;

I think we can drop start_page and use start_info only. They are the same, aren't they?

Yes, there are pointer to the same part of memory, with different types. By droping start_page, I could replace few "start_page+sizeof(*start_info)" by "start_info + 1" :), and have to use a cast for the line abrove.

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 02/14] libxc: Prepare a start info structure for hvmloader

In reply to Konrad Rzeszutek Wilk
Quoted 55 lines
Quoted 41 lines
tools/libxc/xc_dom_x86.c +4 -8
index bdec40a..9c56d55 100644
@@ -69,6 +69,9 @@
 #define round_up(addr, mask)     ((addr) | (mask))
 #define round_pg_up(addr)  (((addr) + PAGE_SIZE_X86 - 1) & ~(PAGE_SIZE_X86 - 1))
 
+#define HVMLOADER_MODULE_MAX_COUNT 1
+#define HVMLOADER_MODULE_NAME_SIZE 10
+
 struct xc_dom_params {
     unsigned levels;
     xen_vaddr_t vaddr_mask;
@@ -590,6 +593,7 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
     xen_pfn_t special_array[X86_HVM_NR_SPECIAL_PAGES];
     xen_pfn_t ioreq_server_array[NR_IOREQ_SERVER_PAGES];
     xc_interface *xch = dom->xch;
+    size_t start_info_size = sizeof(struct hvm_start_info);
 
     /* Allocate and clear special pages. */
     for ( i = 0; i < X86_HVM_NR_SPECIAL_PAGES; i++ )
@@ -624,8 +628,6 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
 
     if ( !dom->device_model )
     {
-        size_t start_info_size = sizeof(struct hvm_start_info);
-
         if ( dom->cmdline )
         {
             dom->cmdline_size = ROUNDUP(strlen(dom->cmdline) + 1, 8);
@@ -635,17 +637,26 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
         /* Limited to one module. */
         if ( dom->ramdisk_blob )
             start_info_size += sizeof(struct hvm_modlist_entry);
-
-        rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
-                                  "HVMlite start info", 0, start_info_size);
-        if ( rc != 0 )
-        {
-            DOMPRINTF("Unable to reserve memory for the start info");

tools/libxc/xc_dom_x86.c static int alloc_magic_pages_hvm(struct xc_dom_image *dom) · line 647

Quoted 10 lines
tools/libxc/xc_dom_x86.c +5 -2
-            goto out;
-        }
     }
     else
     {
+        start_info_size +=
+            sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT;
+        /* Add extra space to write modules name */
+        start_info_size +=
+            HVMLOADER_MODULE_NAME_SIZE * HVMLOADER_MODULE_MAX_COUNT;

What about \0 ? Ah, the strncpy we use adds \0 byte. But it would be nice to mention that somewhere. Perhaps mention:

Quoted 1 line

The HVMLOADER_MODULE_NAME_SIZE accounts for NUL byte?

Yes, I can add a comment about it.

Quoted 40 lines
Quoted 40 lines
tools/libxc/xc_dom_x86.c +33 -0
+    }
+
+    rc = xc_dom_alloc_segment(dom, &dom->start_info_seg,
+                              "HVMlite start info", 0, start_info_size);
+    if ( rc != 0 )
+    {
+        DOMPRINTF("Unable to reserve memory for the start info");
+        goto out;
+    }
+
+    if ( dom->device_model )
+    {
         /*
          * Allocate and clear additional ioreq server pages. The default
          * server will use the IOREQ and BUFIOREQ special pages above.
@@ -1696,39 +1707,68 @@ static int alloc_pgtables_hvm(struct xc_dom_image *dom)
     return 0;
 }
 
+static void add_module_to_list(struct xc_dom_image *dom,
+                               struct xc_hvm_firmware_module *module,
+                               const char *name,
+                               struct hvm_modlist_entry *modlist,
+                               struct hvm_start_info *start_info)
+{
+    uint32_t index = start_info->nr_modules;
+    if ( module->length == 0 )
+        return;
+
+    assert(start_info->nr_modules < HVMLOADER_MODULE_MAX_COUNT);
+    assert(strnlen(name, HVMLOADER_MODULE_NAME_SIZE)
+           < HVMLOADER_MODULE_NAME_SIZE);
+
+    modlist[index].paddr = module->guest_addr_out;
+    modlist[index].size = module->length;
+    strncpy((char*)(modlist + HVMLOADER_MODULE_MAX_COUNT)
+            + HVMLOADER_MODULE_NAME_SIZE * index,
+            name, HVMLOADER_MODULE_NAME_SIZE);
+    modlist[index].cmdline_paddr =
+        (dom->start_info_seg.pfn << PAGE_SHIFT) +
Quoted 8 lines

tools/libxc/xc_dom_x86.c static int alloc_pgtables_hvm(struct xc_dom_image *dom) · line 1733

Quoted 3 lines
tools/libxc/xc_dom_x86.c +3 -0
+        ((uintptr_t)modlist - (uintptr_t)start_info) +
+        sizeof(struct hvm_modlist_entry) * HVMLOADER_MODULE_MAX_COUNT +
+        HVMLOADER_MODULE_NAME_SIZE * index;

That looks right, but boy it takes a bit of thinking to make sure it is right. Perhaps put a comment outlining where it ought to be (so folks reading the first time can feel OK they got it right?)

Yes, I can add comments, and maybe try to simplify it a bit.

Signature · 6 lines
Anthony PERARD

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

PATCH v4 3/14 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 via --with-system-seabios or --with-system-ovmf, 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 5b5dda4..7e5452e 100644
@@ -218,6 +218,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@:>@],
@@ -229,6 +232,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
Reviewed-by on v4 3/14
#10 lore raw

Re: [PATCH v4 03/14] configure: #define SEABIOS_PATH and OVMF_PATH

Quoted 2 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 via --with-system-seabios or

s/define/defined/

Quoted 1 line

--with-system-ovmf, then this default to the Xen firmware directory.

s/this//

Quoted 2 lines
Quoted 39 lines

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

---
 tools/configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)
tools/configure.ac +6 -0
index 5b5dda4..7e5452e 100644
@@ -218,6 +218,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@:>@],
@@ -229,6 +232,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

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

Acked-by on v4 3/14
#11 lore raw

Re: [PATCH v4 03/14] configure: #define SEABIOS_PATH and OVMF_PATH

In reply to Anthony PERARD
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 via --with-system-seabios or --with-system-ovmf, then this default to the Xen firmware directory.

Quoted 33 lines

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

---
 tools/configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)
tools/configure.ac +6 -0
index 5b5dda4..7e5452e 100644
@@ -218,6 +218,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@:>@],
@@ -229,6 +232,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 · 1 line
Anthony PERARD

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

#12 lore raw

PATCH v4 4/14 firmware/makefile: install BIOS blob ...

In reply to Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +13 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 20 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644

tools/firmware/Makefile SUBDIRS-y += hvmloader · line 23

Quoted 5 lines
tools/firmware/Makefile +2 -0
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin

These will set the variables..

tools/firmware/Makefile endif · line 52

Quoted 10 lines
tools/firmware/Makefile +3 -0
+
 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 +48,16 @@ endif
 install: all
 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET) $(INST_DIR)
+ifeq ($(CONFIG_SEABIOS),y)
+ifeq ($(SEABIOS_PATH),)

But here you check them?

Or should the setting of OVMF_ROM and SEABIOS_ROM be ?=

Quoted 19 lines
tools/firmware/Makefile +8 -0
+	$(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
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 7 lines
Anthony PERARD


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

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

#14 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 28 lines · Konrad Rzeszutek Wilk

tools/firmware/Makefile SUBDIRS-y += hvmloader · line 23

Quoted 11 lines · Anthony PERARD

tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader


 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd

tools/firmware/Makefile +2 -0
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin

These will set the variables..

tools/firmware/Makefile endif · line 52

Quoted 13 lines

+
 ovmf-dir:
  GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir cp ovmf-makefile ovmf-dir/Makefile;

tools/firmware/Makefile +0 -0
@@ -45,6 +48,16 @@ endif

 install: all

 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET)

$(INST_DIR)

tools/firmware/Makefile +2 -0
+ifeq ($(CONFIG_SEABIOS),y)
+ifeq ($(SEABIOS_PATH),)

But here you check them?

Quoted 2 lines

Or should the setting of OVMF_ROM and SEABIOS_ROM be ?=

I don't speak too much Makefile, TBH (so apologies if I'm talking nonsense), but it looks to me that what is set above and what is checked here are indeed _not_the_same_ variables.. isn't that the case?

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

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

#15 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 29 lines · Dario Faggioli
Quoted 28 lines · Konrad Rzeszutek Wilk

tools/firmware/Makefile SUBDIRS-y += hvmloader · line 23

Quoted 11 lines · Anthony PERARD

tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader


 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd

tools/firmware/Makefile +2 -0
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin

These will set the variables..

tools/firmware/Makefile endif · line 52

Quoted 13 lines

+
 ovmf-dir:
  GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir cp ovmf-makefile ovmf-dir/Makefile;

tools/firmware/Makefile +0 -0
@@ -45,6 +48,16 @@ endif

 install: all

 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET)

$(INST_DIR)

tools/firmware/Makefile +2 -0
+ifeq ($(CONFIG_SEABIOS),y)
+ifeq ($(SEABIOS_PATH),)

But here you check them?

Quoted 5 lines
Quoted 2 lines

Or should the setting of OVMF_ROM and SEABIOS_ROM be ?=

I don't speak too much Makefile, TBH (so apologies if I'm talking nonsense), but it looks to me that what is set above and what is checked here are indeed _not_the_same_ variables.. isn't that the case?

<facepalm>
You are right.

Ignore my comment.

Thanks!

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

#16 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

In reply to Konrad Rzeszutek Wilk
Quoted 28 lines · Konrad Rzeszutek Wilk
Quoted 20 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644

tools/firmware/Makefile SUBDIRS-y += hvmloader · line 23

Quoted 5 lines
tools/firmware/Makefile +2 -0
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin

These will set the variables..

Quoted 12 lines

tools/firmware/Makefile endif · line 52

Quoted 10 lines
tools/firmware/Makefile +3 -0
+
 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 +48,16 @@ endif
 install: all
 	[ -d $(INST_DIR) ] || $(INSTALL_DIR) $(INST_DIR)
 	[ ! -e $(TARGET) ] || $(INSTALL_DATA) $(TARGET) $(INST_DIR)
+ifeq ($(CONFIG_SEABIOS),y)
+ifeq ($(SEABIOS_PATH),)

But here you check them?

What do you mean by check them?

Quoted 1 line

Or should the setting of OVMF_ROM and SEABIOS_ROM be ?=

I don't see any reason to change the location of SEABIOS_ROM, it describe the location to the one we built. I've mostly copy those from hvmloader/Makefile.

But thinking about it, there is no more reason to have variables, I'll remove SEABIOS_ROM and OVMF_ROM and hardcode it below.

So that would give for seabios:

	$(INSTALL_DATA) seabios-dir/out/bios.bin $(INST_DIR)/seabios.bin

Would that be better?

Quoted 19 lines
Quoted 19 lines
tools/firmware/Makefile +8 -0
+	$(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
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

In reply to Anthony PERARD
Quoted 30 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +3 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 ovmf-dir:
 	GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh $(OVMF_UPSTREAM_URL) $(OVMF_UPSTREAM_REVISION) ovmf-dir
 	cp ovmf-makefile ovmf-dir/Makefile;

tools/firmware/Makefile endif · line 53

Quoted 6 lines
tools/firmware/Makefile +3 -0
@@ -45,6 +48,16 @@ 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

Why install this as "seabios.bin" when the default is "bios.bin". Most distro's packages for SeaBIOS install it as "bios.bin"

Quoted 11 lines
tools/firmware/Makefile +7 -0
+endif
+endif
+ifeq ($(CONFIG_OVMF),y)
+ifeq ($(OVMF_PATH),)
+	$(INSTALL_DATA) $(OVMF_ROM) $(INST_DIR)/ovmf.bin
+endif
+endif
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 1 line
Doug Goldstein

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

#18 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 24 lines · Doug Goldstein
Quoted 23 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
Quoted 16 lines

tools/firmware/Makefile endif · line 53

Quoted 13 lines
tools/firmware/Makefile +6 -0
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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

Why install this as "seabios.bin" when the default is "bios.bin". Most distro's packages for SeaBIOS install it as "bios.bin"

No reason. I guess it's fine to keep the same name ("bios.bin"). My distro install it as "bios-256k.bin", with "bios.bin" been the small version I guess.

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 40 lines · Anthony PERARD
Quoted 24 lines · Doug Goldstein
Quoted 23 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
Quoted 15 lines

tools/firmware/Makefile endif · line 53

Quoted 13 lines
tools/firmware/Makefile +6 -0
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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

Why install this as "seabios.bin" when the default is "bios.bin". Most distro's packages for SeaBIOS install it as "bios.bin"

Quoted 3 lines

No reason. I guess it's fine to keep the same name ("bios.bin"). My distro install it as "bios-256k.bin", with "bios.bin" been the small version I guess.

Same with SUSE's SeaBIOS package, which contains bios.bin (sz 131072) and bios-256k.bin (sz 262144).

Regards,
Jim

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

#20 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

In reply to Anthony PERARD
Quoted 42 lines · Anthony PERARD
Quoted 24 lines · Doug Goldstein
Quoted 23 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +0 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
Quoted 16 lines

tools/firmware/Makefile endif · line 53

Quoted 13 lines
tools/firmware/Makefile +6 -0
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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

Why install this as "seabios.bin" when the default is "bios.bin". Most distro's packages for SeaBIOS install it as "bios.bin"

Quoted 5 lines

No reason. I guess it's fine to keep the same name ("bios.bin"). My distro install it as "bios-256k.bin", with "bios.bin" been the small version I guess.

Right. All the distros should be doing that now for modern versions of SeaBIOS. When this work gets packaged up in a distro they'll likely use one of those two versions instead of using the one that Xen builds, like they mostly do with QEMU. I'd have to check how Xen builds SeaBIOS to know which it should point to.

Signature · 1 line
Doug Goldstein

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

#21 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

In reply to Anthony PERARD
Quoted 37 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +6 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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

tools/firmware/Makefile endif · line 63

Quoted 10 lines
tools/firmware/Makefile +7 -0
+endif
+endif
+ifeq ($(CONFIG_OVMF),y)
+ifeq ($(OVMF_PATH),)
+	$(INSTALL_DATA) $(OVMF_ROM) $(INST_DIR)/ovmf.bin
+endif
+endif
 
 .PHONY: clean
 clean: subdirs-clean

So I'm going to toss this out there but what if we don't install these at all? We talked about reducing the scope that the Xen Security team had to maintain. What if we just state that SeaBIOS and/or OVMF are dependencies? All the downstream distros don't use the pre-built binaries from Xen and build it themselves. For plain Xen users we just add that to the list of dependencies.

I think SeaBIOS and OVMF are a lot more low risk than something like QEMU since they have a very clear target so they're a lot more likely to remain stable. SeaBIOS also has a fairly low level of churn, especially on stable branches.

Just a thought.

Signature · 1 line
Doug Goldstein

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

#22 lore raw

Re: [PATCH v4 04/14] firmware/makefile: install BIOS blob ...

Quoted 56 lines · Doug Goldstein
Quoted 37 lines · Anthony PERARD

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

---
Change in V4:
- remove install of acpi dsdt table

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.

---
 tools/firmware/Makefile | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/firmware/Makefile +6 -0
index 6cc86ce..6a37758 100644
@@ -19,6 +19,9 @@ SUBDIRS-y += hvmloader
 
 LD32BIT-$(CONFIG_FreeBSD) := LD32BIT_FLAG=-melf_i386_fbsd
 
+SEABIOS_ROM := seabios-dir/out/bios.bin
+OVMF_ROM := ovmf-dir/ovmf.bin
+
 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 +48,16 @@ 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

tools/firmware/Makefile endif · line 63

Quoted 10 lines
tools/firmware/Makefile +7 -0
+endif
+endif
+ifeq ($(CONFIG_OVMF),y)
+ifeq ($(OVMF_PATH),)
+	$(INSTALL_DATA) $(OVMF_ROM) $(INST_DIR)/ovmf.bin
+endif
+endif
 
 .PHONY: clean
 clean: subdirs-clean

So I'm going to toss this out there but what if we don't install these at all? We talked about reducing the scope that the Xen Security team had to maintain. What if we just state that SeaBIOS and/or OVMF are dependencies? All the downstream distros don't use the pre-built binaries from Xen and build it themselves. For plain Xen users we just add that to the list of dependencies.

Quoted 4 lines

I think SeaBIOS and OVMF are a lot more low risk than something like QEMU since they have a very clear target so they're a lot more likely to remain stable. SeaBIOS also has a fairly low level of churn, especially on stable branches.

Just to add to your argument, Raisin already supports both SeaBIOS and OVMF. That's another way for users to build them if they want to.

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

#23 lore raw

PATCH v4 5/14 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 V4:
- updating man page to have bios_override described.
- return ERROR_INVAL in libxl__load_hvm_firmware_module when the file is empty.

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

---
 docs/man/xl.cfg.pod.5        |  9 +++++++
 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 ++++++---
 7 files changed, 95 insertions(+), 3 deletions(-)
docs/man/xl.cfg.pod.5 +9 -0
index 56b1117..165915b 100644
@@ -1121,6 +1121,15 @@ Requires device_model_version=qemu-xen.
 
 =back
 
+=item B<bios_override="PATH">
+
+Override the path to the blob to be used as BIOS. The blob provided here MUST
+be consistent with the `bios` which you have specified. You should not normally
+need to specify this option.
+
+This options does not have any effect if using bios="rombios" or
+device_model_version="qemu-xen-traditional".
+
 =item B<pae=BOOLEAN>
 
 Hide or expose the IA32 Physical Address Extensions. These extensions
tools/libxl/libxl.h +8 -0
index f9e3ef5..d06c6c5 100644
@@ -884,6 +884,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
 #define LIBXL_HAVE_CHECKPOINTED_STREAM 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
+
+/*
  * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it
  * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7
  */
tools/libxl/libxl_dom.c +57 -0

75 lines not on this page · raw message

tools/libxl/libxl_internal.h +2 -0
index 005fe53..af3ba9a 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 632c009..3978fd9 100644
@@ -493,6 +493,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 990d3c9..08ceede 100644
@@ -1505,12 +1505,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
#24 lore raw

Re: [PATCH v4 05/14] libxl: Load guest BIOS from file

Quoted 1 line · Anthony PERARD

The path to the BIOS blob can be override by the xl's bios_override option,

s/override/overriden/

Quoted 36 lines

or provided by u.hvm.bios_firmware in the domain_build_info struct by other libxl user.

---
Change in V4:
- updating man page to have bios_override described.
- return ERROR_INVAL in libxl__load_hvm_firmware_module when the file is empty.

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

---
 docs/man/xl.cfg.pod.5        |  9 +++++++
 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 ++++++---
 7 files changed, 95 insertions(+), 3 deletions(-)
docs/man/xl.cfg.pod.5 +0 -0
index 56b1117..165915b 100644

docs/man/xl.cfg.pod.5 Requires device_model_version=qemu-xen. · line 1124

Quoted 4 lines
docs/man/xl.cfg.pod.5 +1 -0
@@ -1121,6 +1121,15 @@ Requires device_model_version=qemu-xen.
 
 =back
 
+=item B<bios_override="PATH">

Perhaps 'bios_override_path' ?

docs/man/xl.cfg.pod.5 Requires device_model_version=qemu-xen. · line 1126

Quoted 2 lines
docs/man/xl.cfg.pod.5 +2 -0
+
+Override the path to the blob to be used as BIOS. The blob provided here MUST

Perhaps:

Override the path to search for the B<bios=>?

Or is this the full path including the name?? In which case should it mention that B<bios=> is overriden?

docs/man/xl.cfg.pod.5 Requires device_model_version=qemu-xen. · line 1130

Quoted 4 lines
docs/man/xl.cfg.pod.5 +4 -0
+be consistent with the `bios` which you have specified. You should not normally
+need to specify this option.
+
+This options does not have any effect if using bios="rombios" or

B<bios="rombios"> ?

docs/man/xl.cfg.pod.5 Requires device_model_version=qemu-xen. · line 1131

Quoted 1 line
docs/man/xl.cfg.pod.5 +1 -0
+device_model_version="qemu-xen-traditional".

And here too?

Quoted 29 lines
docs/man/xl.cfg.pod.5 +1 -0
+
 =item B<pae=BOOLEAN>
 
 Hide or expose the IA32 Physical Address Extensions. These extensions
tools/libxl/libxl.h +8 -0
index f9e3ef5..d06c6c5 100644
@@ -884,6 +884,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);
 #define LIBXL_HAVE_CHECKPOINTED_STREAM 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
+
+/*
  * ERROR_REMUS_XXX error code only exists from Xen 4.5, Xen 4.6 and it
  * is changed to ERROR_CHECKPOINT_XXX in Xen 4.7
  */
tools/libxl/libxl_dom.c +0 -0
index b825b98..c112cc5 100644
@@ -862,6 +862,38 @@ err:
     return ret;

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

Quoted 10 lines
tools/libxl/libxl_dom.c +8 -0
 }
 
+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;

That is interesting.

The CODING_STYLE in tools/libxl says:

 36   int rc;    /* a libxl error code - and not anything else */                   
 37   int r;     /* the return value from a system call (or libxc call) */          
 38   bool ok;   /* the success return value from a boolean function */             

And libxl_read_file_contents is quite weird. It does return an normal errno value, so .. one could say it should be 'r'? But the existing users of this are either 'e','ret' or 'rc'. 'rc' is not good, and 'ret' is 'rc' is clearly wrong.

How confusing.

Ian, Wei, maybe you could clarify please?

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

Quoted 6 lines
tools/libxl/libxl_dom.c +6 -0
+
+    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

s/error/errors/

Quoted 139 lines
tools/libxl/libxl_dom.c +43 -0
+         * 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) {
+        /* Only accept non-empty files */
+        m->data = data;
+        m->length = datalen;
+    } else {
+        LOG(ERROR, "file %s for %s is empty", filename, what);
+        return ERROR_INVAL;
+    }
+    return 0;
+}
+
 static int libxl__domain_firmware(libxl__gc *gc,
                                   libxl_domain_build_info *info,
                                   struct xc_dom_image *dom)
@@ -871,6 +903,7 @@ static int libxl__domain_firmware(libxl__gc *gc,
     int e, rc;
     int datalen = 0;
     void *data;
+    const char *bios_filename = NULL;
 
     if (info->u.hvm.firmware)
         firmware = info->u.hvm.firmware;
@@ -914,6 +947,30 @@ static int libxl__domain_firmware(libxl__gc *gc,
         goto out;
     }
 
+    if (info->device_model_version == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
+        if (info->u.hvm.bios_firmware) {
+            bios_filename = info->u.hvm.bios_firmware;
+        } else {
+            switch (info->u.hvm.bios) {
+            case LIBXL_BIOS_TYPE_SEABIOS:
+                bios_filename = libxl__seabios_path();
+                break;
+            case LIBXL_BIOS_TYPE_OVMF:
+                bios_filename = libxl__ovmf_path();
+                break;
+            case LIBXL_BIOS_TYPE_ROMBIOS:
+            default:
+                abort();
+            }
+        }
+    }
+
+    if (bios_filename) {
+        rc = libxl__load_hvm_firmware_module(gc, bios_filename, "BIOS",
+                                             &dom->bios_module);
+        if (rc) goto out;
+    }
+
     if (info->u.hvm.smbios_firmware) {
         data = NULL;
         e = libxl_read_file_contents(ctx, info->u.hvm.smbios_firmware,
tools/libxl/libxl_internal.h +2 -0
index 005fe53..af3ba9a 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 632c009..3978fd9 100644
@@ -493,6 +493,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 990d3c9..08ceede 100644
@@ -1505,12 +1505,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

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

#25 lore raw

Re: [PATCH v4 05/14] libxl: Load guest BIOS from file

Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Anthony PERARD
docs/man/xl.cfg.pod.5 +0 -0
@@ -1121,6 +1121,15 @@ Requires device_model_version=qemu-xen.


 =back

+=item B<bios_override="PATH">

Perhaps 'bios_override_path' ?

Or 'bios_path_override' ?

Wow, a French, an Italian and a Polish arguing about best looking English-ish words... This must be a (bad) joke! :-P :-P

Quoted 7 lines
Quoted 3 lines
docs/man/xl.cfg.pod.5 +2 -0
+
+Override the path to the blob to be used as BIOS. The blob

provided here MUST

Perhaps:

Override the path to search for the B<bios=>?

AFAIUI, B<bios=> does not contain an exact file name, but the indication of what kind of BIOS we want. Therefore, referencing it directly like this may be confusing (IMHO).

So, maybe something like: "Override the path at which to look for the BIOS binary. Such binary MUST be consistent with what has been specified in B<bios=>."

Quoted 3 lines

Or is this the full path including the name?? In which case should it mention that B<bios=> is overriden?

If that is the case, indeed.

Quoted 32 lines
Quoted 7 lines
tools/libxl/libxl_dom.c +0 -0
@@ -862,6 +862,38 @@ err:
      return ret;
  }


+static int libxl__load_hvm_firmware_module(libxl__gc *gc,

Quoted 8 lines

+                                           const char *filename, +                                           const char *what, +                                           struct xc_hvm_firmware_module *m)
+{
+    int datalen = 0;
+    void *data = NULL;
+    int e;

That is interesting.

The CODING_STYLE in tools/libxl says:

 36   int rc;    /* a libxl error code - and not anything else */
 37   int r;     /* the return value from a system call (or libxc call) */
 38   bool ok;   /* the success return value from a boolean function */

And libxl_read_file_contents is quite weird. It does return an normal errno value, so .. one could say it should be 'r'? But the existing users
of this are either 'e','ret' or 'rc'. 'rc' is not good, and 'ret' is 'rc' is clearly wrong.

Quoted 4 lines

How confusing.

Ian, Wei, maybe you could clarify please?

Hehe... I'd also go for 'r', and call the (or at least some of the) existing users not codying style compliant, but it's indeed a funny case, and we should hear from maintainers what they prefer. :-)

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

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

#26 lore raw

Re: [PATCH v4 05/14] libxl: Load guest BIOS from file

Quoted 12 lines · Dario Faggioli
Quoted 11 lines · Konrad Rzeszutek Wilk
Quoted 8 lines · Anthony PERARD
docs/man/xl.cfg.pod.5 +0 -0
@@ -1121,6 +1121,15 @@ Requires device_model_version=qemu-xen.


 =back

+=item B<bios_override="PATH">

Perhaps 'bios_override_path' ?

Quoted 4 lines

Or 'bios_path_override' ?

Wow, a French, an Italian and a Polish arguing about best looking English-ish words... This must be a (bad) joke! :-P :-P

:)

To be honest, I just try to do the same as what is done for "device_model_override". I even copied over the description, replacing "binary" by "blob".

Maybe bios_path_override would be a good name, would this name can be describe as "override bios_path"? At least that would not make someone beleave that the bios= config option itself is overridden.

Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
docs/man/xl.cfg.pod.5 +2 -0
+
+Override the path to the blob to be used as BIOS. The blob

provided here MUST

Perhaps:

Override the path to search for the B<bios=>?

AFAIUI, B<bios=> does not contain an exact file name, but the indication of what kind of BIOS we want. Therefore, referencing it directly like this may be confusing (IMHO).

That's right, value can only be "rombios" or "seabios" or "ovmf".

Quoted 8 lines

So, maybe something like: "Override the path at which to look for the BIOS binary. Such binary MUST be consistent with what has been specified in B<bios=>."

Quoted 3 lines

Or is this the full path including the name?? In which case should it mention that B<bios=> is overriden?

If that is the case, indeed.

Yes this new config option is the full path. But it does not override bios=.

If someone start a guest with this:

bios="seabios"
bios_override="/usr/share/ovmf/ovmf_x64.bin"

it's going to fail.

Signature · 6 lines
Anthony PERARD

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

PATCH v4 6/14 xen: Move the hvm_start_info C representation from libxc to public/xen.h

In reply to Anthony PERARD

Instead of having several representation of hvm_start_info in C, define it in public/xen.h so both libxc and hvmloader can use it.

---
New in V4.

---
 tools/libxc/include/xc_dom.h | 31 -------------------------------
 xen/include/public/xen.h     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 31 deletions(-)
tools/libxc/include/xc_dom.h +0 -31
index 93f894c..567016c 100644
@@ -219,37 +219,6 @@ struct xc_dom_image {
     struct xc_hvm_firmware_module smbios_module;
 };
 
-#if defined(__i386__) || defined(__x86_64__)
-/* 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 /* x86 */
-
 /* --- pluggable kernel loader ------------------------------------- */
 
 struct xc_dom_loader {
xen/include/public/xen.h +31 -0
index 1cfec5c..c270cf1 100644
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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 /* x86 */
+
 /* New console union for dom0 introduced in 0x00030203. */
 #if __XEN_INTERFACE_VERSION__ < 0x00030203
 #define console_mfn    console.domU.mfn
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +20 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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    */

xen/include/public/xen.h typedef struct start_info start_info_t; · line 873

Quoted 10 lines
xen/include/public/xen.h +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 /* x86 */

This needs extra care: Either the packed attributes need to be dropped (Roger - why did they get put there in the first place?), or their use needs to be shielded from compilers not understanding them.

Jan

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

#29 lore raw

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

Quoted 32 lines · Jan Beulich
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +25 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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.           */
Quoted 8 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 873

Quoted 5 lines
xen/include/public/xen.h +5 -0
+    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 /* x86 */

This needs extra care: Either the packed attributes need to be dropped (Roger - why did they get put there in the first place?),

Presumarily b/c on 32-bit and 64-bit the size of the structure would be different otherwise...

Quoted 2 lines

or their use needs to be shielded from compilers not understanding them.

.. which begs the question - How come we didn't make the structure 64-bit nice? As in add another uint32_t to it? And then we can ditch the packed?

Quoted 8 lines

Jan

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

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

#30 lore raw

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

Quoted 1 line · Konrad Rzeszutek Wilk

On Tue, Mar 15, 2016 at 02:09:46AM -0600, Jan Beulich wrote:

Adding Boris to the To:

Quoted 41 lines
Quoted 32 lines
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +25 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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.           */
Quoted 8 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 873

Quoted 5 lines
xen/include/public/xen.h +5 -0
+    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 /* x86 */

This needs extra care: Either the packed attributes need to be dropped (Roger - why did they get put there in the first place?),

Quoted 19 lines

Presumarily b/c on 32-bit and 64-bit the size of the structure would be different otherwise...

Quoted 2 lines

or their use needs to be shielded from compilers not understanding them.

.. which begs the question - How come we didn't make the structure 64-bit nice? As in add another uint32_t to it? And then we can ditch the packed?

Quoted 8 lines

Jan

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

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

#31 lore raw

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

In reply to Konrad Rzeszutek Wilk
Quoted 43 lines
Quoted 1 line
Quoted 1 line · On 16.03.16 at 01:59, <[email protected]> wrote:
Quoted 32 lines · Jan Beulich
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +25 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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.           */
Quoted 8 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 873

Quoted 5 lines
xen/include/public/xen.h +5 -0
+    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 /* x86 */

This needs extra care: Either the packed attributes need to be dropped (Roger - why did they get put there in the first place?),

Quoted 2 lines

Presumarily b/c on 32-bit and 64-bit the size of the structure would be different otherwise...

And that difference in size would result from what?

Quoted 6 lines
Quoted 2 lines

or their use needs to be shielded from compilers not understanding them.

.. which begs the question - How come we didn't make the structure 64-bit nice?
As in add another uint32_t to it? And then we can ditch the packed?

Certainly not the odd number of uint32_t-s in there. If there was a mix of uint32_t and uint64_t, I could certainly see any issue...

Jan

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

#32 lore raw

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

In reply to Jan Beulich

Hello,

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +0 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
Quoted 10 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 853

Quoted 10 lines
xen/include/public/xen.h +10 -0
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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.
+ */

^ Rationale on why the packed attribute was added.

Quoted 17 lines
Quoted 17 lines
xen/include/public/xen.h +17 -0
+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.     */
Quoted 8 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 873

Quoted 3 lines
xen/include/public/xen.h +3 -0
+    uint64_t reserved;
+} __attribute__((packed));
+#endif /* x86 */

This needs extra care: Either the packed attributes need to be dropped (Roger - why did they get put there in the first place?), or their use needs to be shielded from compilers not understanding them.

Hello,

The rationale behind the packed attribute is in the highlighted comment above.

I would really like to avoid placing this in public headers, or else people will think this is the definition of the payload and will forget that this is just a C representation of it, but the definition is in a comment just above. I want to avoid the issues we have already seen by the usage of C structures as definitions of the placement of payloads in memory.

If this really has to be there, please guard it with:

#if defined(__XEN__) || defined(__XEN_TOOLS__)

So only the Xen kernel/tools can use it.

Roger.

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

#33 lore raw

Re: [PATCH v4 06/14] xen: Move the hvm_start_info C representation from libxc to public/xen.h

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.03.16 at 18:04, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
xen/include/public/xen.h +0 -0
@@ -841,6 +841,37 @@ typedef struct start_info start_info_t;
  */
 #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
 
Quoted 12 lines
Quoted 10 lines

xen/include/public/xen.h typedef struct start_info start_info_t; · line 853

Quoted 10 lines
xen/include/public/xen.h +10 -0
+#if defined(__i386__) || defined(__x86_64__)
+/* C representation of the x86/HVM start info layout.
+ *
+ * The canonical definition of this layout is abrove, 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.
+ */

^ Rationale on why the packed attribute was added.

Well, I admit to have overlooked this comment, but I don't see how the packed attribute helps enforce anything. Hence, Anthony, I think together with the attribute that part of the comment should be removed.

Quoted 7 lines

I would really like to avoid placing this in public headers, or else people will think this is the definition of the payload and will forget that this is just a C representation of it, but the definition is in a comment just above. I want to avoid the issues we have already seen by the usage of C structures as definitions of the placement of payloads in memory.

Quoted 5 lines

If this really has to be there, please guard it with:

#if defined(__XEN__) || defined(__XEN_TOOLS__)

So only the Xen kernel/tools can use it.

And hvmloader can't. Not a good idea imo.

Jan

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

#34 lore raw

PATCH v4 7/14 hvmloader: Grab the hvm_start_info pointer

In reply to Anthony PERARD

---
Change in V4:
- remove struct hvm_info_start redefinition, as it's moved to public/xen.h in a previous patch.

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/hvmloader.c | 5 +++++
 tools/firmware/hvmloader/util.h      | 3 +++
 2 files changed, 8 insertions(+)
tools/firmware/hvmloader/hvmloader.c +5 -0
index 716d03c..c45f367 100644
@@ -29,6 +29,8 @@
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 
+const struct hvm_start_info *hvm_start_info;
+
 asm (
     "    .text                       \n"
     "    .globl _start               \n"
@@ -46,6 +48,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 +262,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();
 
tools/firmware/hvmloader/util.h +3 -0
index 3126817..9808016 100644
@@ -158,6 +158,9 @@ static inline void cpu_relax(void)
 struct hvm_info_table *get_hvm_info_table(void) __attribute__ ((const));
 #define hvm_info (get_hvm_info_table())
 
+/* HVM start info */
+extern const struct hvm_start_info *hvm_start_info;
+
 /* String and memory functions */
 int strcmp(const char *cs, const char *ct);
 int strncmp(const char *s1, const char *s2, uint32_t n);
Signature · 7 lines
Anthony PERARD


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Reviewed-by on v4 7/14
#35 lore raw

Re: [PATCH v4 07/14] hvmloader: Grab the hvm_start_info pointer

Quoted 2 lines · Anthony PERARD
Quoted 66 lines

---
Change in V4:
- remove struct hvm_info_start redefinition, as it's moved to public/xen.h in a previous patch.

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/hvmloader.c | 5 +++++
 tools/firmware/hvmloader/util.h      | 3 +++
 2 files changed, 8 insertions(+)
tools/firmware/hvmloader/hvmloader.c +5 -0
index 716d03c..c45f367 100644
@@ -29,6 +29,8 @@
 #include <xen/version.h>
 #include <xen/hvm/params.h>
 
+const struct hvm_start_info *hvm_start_info;
+
 asm (
     "    .text                       \n"
     "    .globl _start               \n"
@@ -46,6 +48,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 +262,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();
 
tools/firmware/hvmloader/util.h +3 -0
index 3126817..9808016 100644
@@ -158,6 +158,9 @@ static inline void cpu_relax(void)
 struct hvm_info_table *get_hvm_info_table(void) __attribute__ ((const));
 #define hvm_info (get_hvm_info_table())
 
+/* HVM start info */
+extern const struct hvm_start_info *hvm_start_info;
+
 /* String and memory functions */
 int strcmp(const char *cs, const char *ct);
 int strncmp(const char *s1, const char *s2, uint32_t n);
Signature · 7 lines
Anthony PERARD


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

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

#37 lore raw

PATCH v4 8/14 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 V4:
- add more BUG_ON into get_module_entry(). Check that modules paddr and size are 32bits.

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 | 42 ++++++++++++++++++++++++++++++++++--
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 tools/firmware/hvmloader/rombios.c   |  3 ++-
 tools/firmware/hvmloader/util.h      |  2 ++
 5 files changed, 47 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 +40 -2

58 lines not on this page · raw message

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 9808016..003dc71 100644
@@ -34,6 +34,8 @@ enum {
 #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
#38 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 1 line · Anthony PERARD

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

s/BIOS/BIOS blob/

Quoted 5 lines

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.

Please list the 'few patches' by name as this patch and others may not always be committed in order.

And it also helps in future to figure out what those other ones are when debugging or backporting.

See below.

Quoted 47 lines

---
Changes in V4:
- add more BUG_ON into get_module_entry(). Check that modules paddr and size are 32bits.

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 | 42 ++++++++++++++++++++++++++++++++++--
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 tools/firmware/hvmloader/rombios.c   |  3 ++-
 tools/firmware/hvmloader/util.h      |  2 ++
 5 files changed, 47 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 +6 -0
index c45f367..460efb9 100644
@@ -253,10 +253,40 @@ 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;

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

Quoted 10 lines
tools/firmware/hvmloader/hvmloader.c +10 -0
+    unsigned int i;
+
+    if ( !modlist )
+        return NULL;
+
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;
+
+        BUG_ON(!modlist[i].cmdline_paddr ||

Having an zero value in cmdline_paddr is OK.

The spec says:

803  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
804  * of the address fields should be treated as not present.
805  *

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

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+               modlist[i].cmdline_paddr > UINT_MAX);
+
+        if ( !strcmp(name, (char*)module_name) )

Which could result in looking up a value at 0 address.

Perhaps change your code to:

	if ( !modlist[i].cmdline_paddr )
		continue;

?

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

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+        {
+            BUG_ON(!modlist[i].paddr || modlist[i].paddr > UINT_MAX ||
+                   modlist[i].size > UINT_MAX);

To be fair all of those values are in spec..Perhaps you should mention that the libxc code would never put those there and neermind the spec?

Quoted 83 lines
tools/firmware/hvmloader/hvmloader.c +18 -2
+            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);
@@ -292,8 +322,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 9808016..003dc71 100644
@@ -34,6 +34,8 @@ enum {
 #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

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

#39 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Anthony PERARD

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

s/BIOS/BIOS blob/

Quoted 8 lines
Quoted 5 lines

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.

Please list the 'few patches' by name as this patch and others may not always be committed in order.

Yes, will do.

Quoted 74 lines

And it also helps in future to figure out what those other ones are when debugging or backporting.

See below.

Quoted 47 lines

---
Changes in V4:
- add more BUG_ON into get_module_entry(). Check that modules paddr and size are 32bits.

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 | 42 ++++++++++++++++++++++++++++++++++--
 tools/firmware/hvmloader/ovmf.c      |  3 ++-
 tools/firmware/hvmloader/rombios.c   |  3 ++-
 tools/firmware/hvmloader/util.h      |  2 ++
 5 files changed, 47 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 +6 -0
index c45f367..460efb9 100644
@@ -253,10 +253,40 @@ 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;

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

Quoted 10 lines
tools/firmware/hvmloader/hvmloader.c +10 -0
+    unsigned int i;
+
+    if ( !modlist )
+        return NULL;
+
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;
+
+        BUG_ON(!modlist[i].cmdline_paddr ||

Having an zero value in cmdline_paddr is OK.

The spec says:

803  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
804  * of the address fields should be treated as not present.
805  *

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

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+               modlist[i].cmdline_paddr > UINT_MAX);
+
+        if ( !strcmp(name, (char*)module_name) )
Quoted 6 lines

Which could result in looking up a value at 0 address.

Perhaps change your code to:

	if ( !modlist[i].cmdline_paddr )
		continue;

?

I'll do that. I'm using to many BUG_ON in this code.

Quoted 6 lines

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

Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+        {
+            BUG_ON(!modlist[i].paddr || modlist[i].paddr > UINT_MAX ||
+                   modlist[i].size > UINT_MAX);

To be fair all of those values are in spec..Perhaps you should mention that the libxc code would never put those there and neermind the spec?

Yes, there is just this mention in the spec: "However Xen will always try to place all modules below the 4GiB boundary."

But it actualy would be a bug if the blob would be abrove 4GiB, since hvmloader can not read that far, right? I can add a comment.

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 6 lines

I'll do that. I'm using to many BUG_ON in this code.

Quoted 4 lines
Quoted 3 lines
tools/firmware/hvmloader/hvmloader.c +3 -0
+        {
+            BUG_ON(!modlist[i].paddr || modlist[i].paddr > UINT_MAX ||
+                   modlist[i].size > UINT_MAX);
Quoted 8 lines
Quoted 2 lines

To be fair all of those values are in spec..Perhaps you should mention that the libxc code would never put those there and neermind the spec?

Yes, there is just this mention in the spec: "However Xen will always try to place all modules below the 4GiB boundary."

But it actualy would be a bug if the blob would be abrove 4GiB, since hvmloader can not read that far, right? I can add a comment.

Well no. It says that the hypervisor will 'try', not that it 'MUST'.

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

#41 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

In reply to Anthony PERARD
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 17.03.16 at 18:46, <[email protected]> wrote:
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 1 line · Anthony PERARD

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

s/BIOS/BIOS blob/

Quoted 2 lines

hvm_start_info struct.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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.

Please list the 'few patches' by name as this patch and others may not always be committed in order.

Yes, will do.

Or maybe just s/next few/subsequent/ or some such? Listing future dependencies in a too explicit manner may also not be a good idea - who knows if their titles change by the time they go in?

Jan

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

#42 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

In reply to Anthony PERARD

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

Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +6 -0
@@ -253,10 +253,40 @@ 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;

This cast puzzles me (as at the first glance I would expect it to cause a compiler warning): Roger, how come cmdline_paddr, modlist_paddr, and rsdp_paddr are 32-bit quantities? While on x86 that _may_ be fine, what about other architectures we may want to run Xen on?

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

Quoted 11 lines
tools/firmware/hvmloader/hvmloader.c +11 -0
+    unsigned int i;
+
+    if ( !modlist )
+        return NULL;
+
+    for ( i = 0; i < info->nr_modules; i++ )
+    {
+        uint32_t module_name = modlist[i].cmdline_paddr;
+
+        BUG_ON(!modlist[i].cmdline_paddr ||
+               modlist[i].cmdline_paddr > UINT_MAX);

While you can't use the local variable for the latter check, you can for the former.

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

Quoted 7 lines
tools/firmware/hvmloader/hvmloader.c +1 -2
@@ -292,8 +322,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");

Isn't "bios" a bit vague, as there could be multiple (system, video, add-on card)?

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

Quoted 4 lines
tools/firmware/hvmloader/hvmloader.c +4 -0
+    if ( bios_module && bios->bios_load )
+    {
+        uint32_t paddr = bios_module->paddr;
+        bios->bios_load(bios, (void*)paddr, bios_module->size);

Blank line between declaration(s) and statement(s) please.

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

Quoted 4 lines
tools/firmware/hvmloader/hvmloader.c +4 -0
+    }
+    else if ( bios->bios_load )
+    {
+        bios->bios_load(bios, 0, 0);
        bios->bios_load(bios, NULL, 0);

Jan

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

#43 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -253,10 +253,40 @@ static void acpi_enable_sci(void)
     BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
 }
 
Quoted 12 lines

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

Quoted 6 lines
tools/firmware/hvmloader/hvmloader.c +6 -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;

This cast puzzles me (as at the first glance I would expect it to cause a compiler warning): Roger, how come cmdline_paddr, modlist_paddr, and rsdp_paddr are 32-bit quantities? While on x86 that _may_ be fine, what about other architectures we may want to run Xen on?

I've always considered this protocol x86 specific TBH, and since guests are started in 32bit mode I have always considered mandatory to have all this information available below the 4GiB boundary.

I don't mind changing the sizes to be 64bits, it's a fairly easy change that could be done before the release.

Roger.

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

#44 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 22 lines
Quoted 1 line
Quoted 1 line · On 05.04.16 at 16:05, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -253,10 +253,40 @@ static void acpi_enable_sci(void)
     BUG_ON(!(pm1a_cnt_val & ACPI_PM1C_SCI_EN));
 }
 
Quoted 12 lines

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

Quoted 6 lines
tools/firmware/hvmloader/hvmloader.c +6 -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;

This cast puzzles me (as at the first glance I would expect it to cause a compiler warning): Roger, how come cmdline_paddr, modlist_paddr, and rsdp_paddr are 32-bit quantities? While on x86 that _may_ be fine, what about other architectures we may want to run Xen on?

Quoted 3 lines

I've always considered this protocol x86 specific TBH, and since guests are started in 32bit mode I have always considered mandatory to have all this information available below the 4GiB boundary.

I could live with that, but then this should be made explicit, rather than depending on only x86 defining XEN_HAVE_PV_GUEST_ENTRY.

And if that was to be done, then the other 64-bit address changes likely could be undone again, too. We really (just) need to settle on the intended scope of the interface, and then it should be made internally consistent.

Jan

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

#45 lore raw

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

In reply to Jan Beulich
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -292,8 +322,16 @@ int main(void)
     }
 
Quoted 7 lines

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

Quoted 4 lines
tools/firmware/hvmloader/hvmloader.c +1 -2
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
+    bios_module = get_module_entry(hvm_start_info, "bios");

Isn't "bios" a bit vague, as there could be multiple (system, video, add-on card)?

Maybe a bit, also this can be use to load OVMF which is not technically a BIOS. I guess a better name would be "firmware" or "system firmware".

On the other hand, the name "bios" is used in few places, in hvmloader, in libxl (to choose between seabios/ovmf).

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 08/14] hvmloader: Locate the BIOS blob

Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 07.04.16 at 17:10, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:
tools/firmware/hvmloader/hvmloader.c +0 -0
@@ -292,8 +322,16 @@ int main(void)
     }
 
Quoted 7 lines

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

Quoted 4 lines
tools/firmware/hvmloader/hvmloader.c +1 -2
     printf("Loading %s ...\n", bios->name);
-    if ( bios->bios_load )
-        bios->bios_load(bios);
+    bios_module = get_module_entry(hvm_start_info, "bios");

Isn't "bios" a bit vague, as there could be multiple (system, video, add-on card)?

Quoted 5 lines

Maybe a bit, also this can be use to load OVMF which is not technically a BIOS. I guess a better name would be "firmware" or "system firmware".

On the other hand, the name "bios" is used in few places, in hvmloader, in libxl (to choose between seabios/ovmf).

Perhaps that's a result of how that code evolved? I'm not heavily objecting to using "bios" here, but I think this being a newly introduced name it could as well be made more correct.

Jan

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

#47 lore raw

PATCH v4 9/14 hvmloader: Check modules whereabouts in perform_tests

In reply to Anthony PERARD

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

---
Changes in v4:
- move the check into the perform_test() function.
- skip tests instead of using BUG.

New in V3

---
 tools/firmware/hvmloader/tests.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
tools/firmware/hvmloader/tests.c +20 -0
index fea3ad3..7996206 100644
@@ -210,6 +210,26 @@ void perform_tests(void)
         return;
     }
 
+    /* Check that tests does not use memory where modules are stored */
+    if ( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) > 4 << 20
+         && (uint32_t)hvm_start_info < 8 << 20 )
+    {
+        printf("Skipping tests due to memory used by hvm_start_info\n");
+        return;
+    }
+    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].paddr
+             && modlist[i].paddr + modlist[i].size > 4ul << 20
+             && modlist[i].paddr < 8ul << 20 )
+        {
+            printf("Skipping tests due to memory used by a module\n");
+            return;
+        }
+    }
+
     passed = skipped = 0;
     for ( i = 0; tests[i].test; i++ )
     {
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v4 09/14] hvmloader: Check modules whereabouts in perform_tests

Quoted 2 lines · Anthony PERARD

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

I get the reason you want this - but if we have giant binary blobs and something else screws up what the tests are testing for- we don't have a regression test anymore.

.. Oh my looking at rep_io_test and trying to make it more dynamic is tricky but should be managable?

I presume that is the test that blows everything out of the sky? And also the placement of the page tables?

Quoted 51 lines

---
Changes in v4:
- move the check into the perform_test() function.
- skip tests instead of using BUG.

New in V3

---
 tools/firmware/hvmloader/tests.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
tools/firmware/hvmloader/tests.c +20 -0
index fea3ad3..7996206 100644
@@ -210,6 +210,26 @@ void perform_tests(void)
         return;
     }
 
+    /* Check that tests does not use memory where modules are stored */
+    if ( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) > 4 << 20
+         && (uint32_t)hvm_start_info < 8 << 20 )
+    {
+        printf("Skipping tests due to memory used by hvm_start_info\n");
+        return;
+    }
+    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].paddr
+             && modlist[i].paddr + modlist[i].size > 4ul << 20
+             && modlist[i].paddr < 8ul << 20 )
+        {
+            printf("Skipping tests due to memory used by a module\n");
+            return;
+        }
+    }
+
     passed = skipped = 0;
     for ( i = 0; tests[i].test; i++ )
     {
Signature · 7 lines
Anthony PERARD


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

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

#49 lore raw

Re: [PATCH v4 09/14] hvmloader: Check modules whereabouts in perform_tests

Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Anthony PERARD

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

I get the reason you want this - but if we have giant binary blobs and something else screws up what the tests are testing for- we don't have a regression test anymore.

.. Oh my looking at rep_io_test and trying to make it more dynamic is tricky but should be managable?

Maybe, it have been mention that the tests could be more dynamic. But they could also be moved to Andrew's Xen Test Framework.

For now, the test are unlikely to be skipped. On my system, in the worse case, with rombios compiled in, and trying to boot with ovmf, the test are not skiped. So with seabios it should be fine for some time.

Still, I'm not sure what to do about it.

Quoted 1 line

I presume that is the test that blows everything out of the sky?

Yes, the test.

Quoted 1 line

And also the placement of the page tables?

:(, I did not take the page tables into account will writing the check.

Signature · 6 lines
Anthony PERARD

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

Re: [PATCH v4 09/14] hvmloader: Check modules whereabouts in perform_tests

In reply to Anthony PERARD
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:

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

---
Changes in v4:
- move the check into the perform_test() function.
- skip tests instead of using BUG.

New in V3

---
 tools/firmware/hvmloader/tests.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
tools/firmware/hvmloader/tests.c +0 -0
index fea3ad3..7996206 100644

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 214

Quoted 5 lines
tools/firmware/hvmloader/tests.c +2 -0
@@ -210,6 +210,26 @@ void perform_tests(void)
         return;
     }
 
+    /* Check that tests does not use memory where modules are stored */
+    if ( ((uint32_t)hvm_start_info + sizeof(struct hvm_start_info)) > 4 << 20
    if ( (uint32_t)(hvm_start_info + 1) > (4 << 20)

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 215

Quoted 1 line
tools/firmware/hvmloader/tests.c +1 -0
+         && (uint32_t)hvm_start_info < 8 << 20 )

Missing parentheses around operands of <<. Also commonly the && would belong on the previous line.

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 220

Quoted 5 lines
tools/firmware/hvmloader/tests.c +5 -0
+    {
+        printf("Skipping tests due to memory used by hvm_start_info\n");
+        return;
+    }
+    for ( unsigned i = 0; i < hvm_start_info->nr_modules; i++ )

Bogus shadowing of an outer scope variable. And we prefer not to use this C99 declaration style anyway.

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 224

Quoted 4 lines
tools/firmware/hvmloader/tests.c +4 -0
+    {
+        const struct hvm_modlist_entry *modlist =
+            (struct hvm_modlist_entry *)hvm_start_info->modlist_paddr;
+        if ( modlist[i].paddr

Blank line ...

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 226

Quoted 2 lines
tools/firmware/hvmloader/tests.c +2 -0
+             && modlist[i].paddr + modlist[i].size > 4ul << 20
+             && modlist[i].paddr < 8ul << 20 )

Parentheses ... Also, why the ul suffixed here but not above? Please be consistent.

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 228

Quoted 2 lines
tools/firmware/hvmloader/tests.c +2 -0
+        {
+            printf("Skipping tests due to memory used by a module\n");

How about at least printing the module index as well?

tools/firmware/hvmloader/tests.c void perform_tests(void) · line 230

Quoted 3 lines
tools/firmware/hvmloader/tests.c +3 -0
+            return;
+        }
+    }

How about cmdline_paddr (both variant) and rsdp_paddr?

Jan

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

#51 lore raw

PATCH v4 10/14 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 V4:
- check that seabios_config.bios_address have a probably good value instead of checking only if it's set.

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..5d0a491 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 < 0xc0000 || seabios_config.bios_address >= 0x100000);
     /* 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
#52 lore raw

Re: [PATCH v4 10/14] hvmloader: Load SeaBIOS from hvm_start_info modules

Quoted 15 lines
tools/firmware/hvmloader/seabios.c +0 -3
index c6b3d9f..5d0a491 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;
 

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

Quoted 4 lines
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 < 0xc0000 || seabios_config.bios_address >= 0x100000);

s/0x100000/HVMLOADER_PHYSICAL_ADDRESS/
s/0xc0000/0x000C0000/

?

Quoted 40 lines
tools/firmware/hvmloader/seabios.c +13 -7
     /* 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

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

#53 lore raw

Re: [PATCH v4 10/14] hvmloader: Load SeaBIOS from hvm_start_info modules

Quoted 14 lines · Konrad Rzeszutek Wilk
Quoted 14 lines
tools/firmware/hvmloader/seabios.c +0 -3
index c6b3d9f..5d0a491 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;
 
Quoted 8 lines

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

Quoted 5 lines
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 < 0xc0000 || seabios_config.bios_address >= 0x100000);

s/0x100000/HVMLOADER_PHYSICAL_ADDRESS/
s/0xc0000/0x000C0000/

That was suppose to be VGABIOS_PHYSICAL_ADDRESS

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

#54 lore raw

Re: [PATCH v4 10/14] hvmloader: Load SeaBIOS from hvm_start_info modules

In reply to Anthony PERARD
Quoted 82 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:

... 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 V4:
- check that seabios_config.bios_address have a probably good value instead of checking only if it's set.

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 +0 -3
index c6b3d9f..5d0a491 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;
 

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

Quoted 4 lines
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 < 0xc0000 || seabios_config.bios_address >= 0x100000);

The right side could benefit from also taking seabios_config.image_size into account. Or wait - the right side could go away, as being redundant with ...

Quoted 6 lines
tools/firmware/hvmloader/seabios.c +1 -1
     /* 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);
 }
 

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

Quoted 10 lines
tools/firmware/hvmloader/seabios.c +5 -4
-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);

... this.

Jan

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

#55 lore raw

PATCH v4 11/14 hvmloader: Load OVMF from modules

In reply to Anthony PERARD

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

---
Change in V4:
- check if source and dest of ovmf binary does not overlaps

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   | 30 +++++++++++++-----------------
 2 files changed, 14 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 +13 -17
index 858a2d4..6607e57 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,24 +90,31 @@ 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;
         mem_hole_populate_ram(mfn, 1);
     }
 
+    /* Check that source and destination does not overlaps. */
+    BUG_ON(addr + bios_length > (unsigned)bios_addr
+           && addr < (unsigned)bios_addr + bios_length);
     /* 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 +151,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
#56 lore raw

Re: [PATCH v4 11/14] hvmloader: Load OVMF from modules

Quoted 2 lines · Anthony PERARD

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

Yeey..

Quoted 23 lines
tools/firmware/hvmloader/ovmf.c +0 -7
index 858a2d4..6607e57 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[];

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

Quoted 5 lines
tools/firmware/hvmloader/ovmf.c +1 -1
@@ -97,24 +90,31 @@ 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

Perhaps still leave an macro for 0x100000000ULL?

Quoted 14 lines
tools/firmware/hvmloader/ovmf.c +7 -3
+        - ((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);
 

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

Quoted 10 lines
tools/firmware/hvmloader/ovmf.c +2 -1
     /* 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;
         mem_hole_populate_ram(mfn, 1);
     }
 
+    /* Check that source and destination does not overlaps. */

s/overlaps/overlap/

Quoted 27 lines
tools/firmware/hvmloader/ovmf.c +3 -5
+    BUG_ON(addr + bios_length > (unsigned)bios_addr
+           && addr < (unsigned)bios_addr + bios_length);
     /* 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 +151,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

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

Acked-by on v4 11/14
#57 lore raw

Re: [PATCH v4 11/14] hvmloader: Load OVMF from modules

In reply to Anthony PERARD
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 14.03.16 at 18:55, <[email protected]> wrote:

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

with some cosmetics left to be done:

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

Quoted 6 lines
     /* Copy low-reset vector portion. */
tools/firmware/hvmloader/ovmf.c +2 -3
-    memcpy((void *) LOWCHUNK_BEGIN, (uint8_t *) config->image
-           + OVMF_SIZE
-           - LOWCHUNK_SIZE,
+    memcpy((void *) LOWCHUNK_BEGIN,
+           (uint8_t *) bios_addr + bios_length - LOWCHUNK_SIZE,

Please take the opportunity and remove the stray blanks here ...

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

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

... and here (between cast's closing paren and casted expression).

Jan

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

#58 lore raw

PATCH v4 12/14 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.

---
No change in V4.

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 460efb9..bb2a309 100644
@@ -323,21 +323,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
#59 lore raw

Re: [PATCH v4 12/14] hvmloader: Specific bios_load function required

On Mon, Mar 14, 2016 at 05:55:47PM +0000, Anthony PERARD wrote:

The title says:

" Specific bios_load function required "

But I am not sure what you mean?

Quoted 1 line

All BIOS but ROMBIOS needs to be loaded via modules.

All BIOSes but ROMBIOS needs to be loaded via modules?

Quoted 60 lines

ROMBIOS is handled as a special case.

---
No change in V4.

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 460efb9..bb2a309 100644
@@ -323,21 +323,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

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

#60 lore raw

Re: [PATCH v4 12/14] hvmloader: Specific bios_load function required

Quoted 7 lines · Konrad Rzeszutek Wilk

On Mon, Mar 14, 2016 at 05:55:47PM +0000, Anthony PERARD wrote:

The title says:

" Specific bios_load function required "

But I am not sure what you mean?

I meant that bios_config->bios_load() need to be defined and can not be NULL anymore.

What about: "bios->bios_load() now needs to be defined"?

Quoted 3 lines
Quoted 1 line

All BIOS but ROMBIOS needs to be loaded via modules.

All BIOSes but ROMBIOS needs to be loaded via modules?

OK.

Quoted 52 lines
Quoted 52 lines

ROMBIOS is handled as a special case.

---
No change in V4.

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 460efb9..bb2a309 100644
@@ -323,21 +323,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 · 6 lines
Anthony PERARD

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

PATCH v4 13/14 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 bb2a309..7631de2 100644
@@ -209,12 +209,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
#62 lore raw

PATCH v4 14/14 configure: 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.

---
Change in V4:
- change subject prefix

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 7e5452e..ef306ae 100644
@@ -212,12 +212,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])
@@ -226,12 +227,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 6a37758..4975cb4 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
@@ -49,15 +45,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
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 7 lines
Anthony PERARD


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

Re: [PATCH v4 14/14] configure: do not depend on SEABIOS_PATH or OVMF_PATH ...

Quoted 1 line · Anthony PERARD

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

s/depends/depend/

Quoted 5 lines

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

Quoted 86 lines

---
Change in V4:
- change subject prefix

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 7e5452e..ef306ae 100644
@@ -212,12 +212,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])
@@ -226,12 +227,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 6a37758..4975cb4 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
@@ -49,15 +45,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
 
 .PHONY: clean
 clean: subdirs-clean
Signature · 7 lines
Anthony PERARD


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

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

Acked-by on v4 14/14
#64 lore raw

Re: [PATCH v4 14/14] configure: 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.

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

Tested-by on the v4 series
#65 lore raw
In reply to Anthony PERARD
Quoted 23 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS 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-v4

Quoted 5 lines
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]>

I've been testing this series in conjunction with my downstream work to use distro-provided qemu, SeaBIOS, and OVMF instead of the Xen built ones. I've tested many combinations of these components, e.g. distro qemu and SeaBIOS, qemu-xen with distro SeaBIOS, distro qemu with Xen SeaBIOS, etc., and haven't noticed any problems. Therefore...

Regards,
Jim

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

#66 lore raw
In reply to Anthony PERARD
Quoted 10 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS 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.

Hi Anthony, Wei,

Any chance this series will make 4.7? AFAICT, there were no major issues in the reviews. I didn't review all the patches in detail, but have done quite a bit of testing with this series and haven't noticed any problems (beyond the current upstream ovmf breakage with Xen).

Regards,
Jim

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

#67 lore raw
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 30.03.16 at 19:22, <[email protected]> wrote:
Quoted 8 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS via the toolstack instead of having them

embedded

Quoted 1 line

in the hvmloader binary. After this patch series, hvmloader compilation

would

Quoted 1 line

be indenpendant from SeaBIOS and OVMF compilation.

Hi Anthony, Wei,

Quoted 7 lines

Any chance this series will make 4.7? AFAICT, there were no major issues in the
reviews. I didn't review all the patches in detail, but have done quite a bit of
testing with this series and haven't noticed any problems (beyond the current
upstream ovmf breakage with Xen).

I'm afraid the primary issue here is reviewing bandwidth: While the hvmloader parts are on my list of things to look at, this clearly comes only after bug fixes, Andrew's CPUID and Konrad's xSplice work in priority, and I already lack the time to provide timely feedback on those two.

Jan

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#69 lore raw
Quoted 24 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 30.03.16 at 19:22, <[email protected]> wrote:
Quoted 8 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS via the toolstack instead of having them

embedded

Quoted 1 line

in the hvmloader binary. After this patch series, hvmloader compilation

would

Quoted 1 line

be indenpendant from SeaBIOS and OVMF compilation.

Hi Anthony, Wei,

Quoted 7 lines

Any chance this series will make 4.7? AFAICT, there were no major issues in the
reviews. I didn't review all the patches in detail, but have done quite a bit of
testing with this series and haven't noticed any problems (beyond the current
upstream ovmf breakage with Xen).

Quoted 2 lines

I'm afraid the primary issue here is reviewing bandwidth: While the hvmloader parts are on my list of things to look at

And these are precisely the patches I just skimmed over, since I'm not familiar with hvmloader.

Jim

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

#70 lore raw
Quoted 25 lines · Jim Fehlig
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 30.03.16 at 19:22, <[email protected]> wrote:
Quoted 8 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS via the toolstack instead of having them

embedded

Quoted 1 line

in the hvmloader binary. After this patch series, hvmloader compilation

would

Quoted 1 line

be indenpendant from SeaBIOS and OVMF compilation.

Hi Anthony, Wei,

Any chance this series will make 4.7? AFAICT, there were no major issues in the
reviews. I didn't review all the patches in detail, but have done quite a bit of
testing with this series and haven't noticed any problems (beyond the current
upstream ovmf breakage with Xen).

Quoted 5 lines
Quoted 2 lines

I'm afraid the primary issue here is reviewing bandwidth: While the hvmloader parts are on my list of things to look at

And these are precisely the patches I just skimmed over, since I'm not familiar with hvmloader.

Hmm, I probably could have reviewed it if I'd known a bit earlier. Unfortunately I don't work for Citrix tomorrow.

-George

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

#71 lore raw
Quoted 26 lines · George Dunlap
Quoted 25 lines · Jim Fehlig
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 30.03.16 at 19:22, <[email protected]> wrote:
Quoted 8 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS via the toolstack instead of having them

embedded

Quoted 1 line

in the hvmloader binary. After this patch series, hvmloader compilation

would

Quoted 1 line

be indenpendant from SeaBIOS and OVMF compilation.

Hi Anthony, Wei,

Any chance this series will make 4.7? AFAICT, there were no major issues in the
reviews. I didn't review all the patches in detail, but have done quite a bit of
testing with this series and haven't noticed any problems (beyond the current
upstream ovmf breakage with Xen).

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'm afraid the primary issue here is reviewing bandwidth: While the hvmloader parts are on my list of things to look at

And these are precisely the patches I just skimmed over, since I'm not familiar with hvmloader.

Hmm, I probably could have reviewed it if I'd known a bit earlier. Unfortunately I don't work for Citrix tomorrow.

Since there's obviously been a failure to communicate here, allow me to expand on this. Last March (or was it March 2014? I forget now) I asked for permission to cut back to 80% time at Citrix; so since then I've been working M-Th, and Friday was "work for myself" day where I mainly pursued personal projects.

And now that it's been publicly announced, this is actually my *last* "work for myself" Friday -- as of next week I'm back to 100%.

So no, you haven't gotten rid of me just yet; on the contrary, you'll soon get 25% more. :-)

-George

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

#72 lore raw
Quoted 42 lines · George Dunlap
Quoted 26 lines · George Dunlap
Quoted 25 lines · Jim Fehlig
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 30.03.16 at 19:22, <[email protected]> wrote:
Quoted 8 lines · Anthony PERARD

Hi all,

Few changes in V4:
I leave the ACPI alone and only load the BIOS via libxl now.

Detail of changes in each patches.

I've look at loading the BIOS via the toolstack instead of having them

embedded

Quoted 1 line

in the hvmloader binary. After this patch series, hvmloader compilation

would

Quoted 1 line

be indenpendant from SeaBIOS and OVMF compilation.

Hi Anthony, Wei,

Any chance this series will make 4.7? AFAICT, there were no major issues in the
reviews. I didn't review all the patches in detail, but have done quite a bit of
testing with this series and haven't noticed any problems (beyond the current
upstream ovmf breakage with Xen).

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'm afraid the primary issue here is reviewing bandwidth: While the hvmloader parts are on my list of things to look at

And these are precisely the patches I just skimmed over, since I'm not familiar with hvmloader.

Hmm, I probably could have reviewed it if I'd known a bit earlier. Unfortunately I don't work for Citrix tomorrow.

Since there's obviously been a failure to communicate here, allow me to expand on this. Last March (or was it March 2014? I forget now) I asked for permission to cut back to 80% time at Citrix; so since then I've been working M-Th, and Friday was "work for myself" day where I mainly pursued personal projects.

Quoted 5 lines

And now that it's been publicly announced, this is actually my *last* "work for myself" Friday -- as of next week I'm back to 100%.

So no, you haven't gotten rid of me just yet; on the contrary, you'll soon get 25% more. :-)

<Wheew>

You scared me George!

Wait, today is April 1st!?

Um?

Hmmmm...

Well, I am going to be an optimist and assume this is not a joke! Welcome back to 100%!

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