diff mbox

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

Message ID 1457978150-27201-11-git-send-email-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anthony PERARD March 14, 2016, 5:55 p.m. UTC
... and do not include the SeaBIOS ROM into hvmloader anymore.

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

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
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(-)

Comments

Konrad Rzeszutek Wilk March 16, 2016, 1:27 a.m. UTC | #1
> diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
> index c6b3d9f..5d0a491 100644
> --- a/tools/firmware/hvmloader/seabios.c
> +++ b/tools/firmware/hvmloader/seabios.c
> @@ -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);

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

?
>      /* 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,
> -- 
> Anthony PERARD
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
Konrad Rzeszutek Wilk March 16, 2016, 1:27 a.m. UTC | #2
On Tue, Mar 15, 2016 at 09:27:19PM -0400, Konrad Rzeszutek Wilk wrote:
> > diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
> > index c6b3d9f..5d0a491 100644
> > --- a/tools/firmware/hvmloader/seabios.c
> > +++ b/tools/firmware/hvmloader/seabios.c
> > @@ -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);
> 
> s/0x100000/HVMLOADER_PHYSICAL_ADDRESS/
> s/0xc0000/0x000C0000/

That was suppose to be VGABIOS_PHYSICAL_ADDRESS
Jan Beulich April 5, 2016, 1:11 p.m. UTC | #3
>>> On 14.03.16 at 18:55, <anthony.perard@citrix.com> 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.
> 
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 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(-)
> 
> diff --git a/tools/firmware/hvmloader/Makefile 
> b/tools/firmware/hvmloader/Makefile
> index f2f4791..ed0bfad 100644
> --- a/tools/firmware/hvmloader/Makefile
> +++ b/tools/firmware/hvmloader/Makefile
> @@ -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" >> $@.new
>  endif
>  
> -ifneq ($(SEABIOS_ROM),)
> -	echo "#ifdef ROM_INCLUDE_SEABIOS" >> $@.new
> -	sh ./mkhex seabios $(SEABIOS_ROM) >> $@.new
> -	echo "#endif" >> $@.new
> -endif
> -
>  ifneq ($(OVMF_ROM),)
>  	echo "#ifdef ROM_INCLUDE_OVMF" >> $@.new
>  	sh ./mkhex ovmf $(OVMF_ROM) >> $@.new
> diff --git a/tools/firmware/hvmloader/seabios.c 
> b/tools/firmware/hvmloader/seabios.c
> index c6b3d9f..5d0a491 100644
> --- a/tools/firmware/hvmloader/seabios.c
> +++ b/tools/firmware/hvmloader/seabios.c
> @@ -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);

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

>      /* 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);

... this.

Jan
diff mbox

Patch

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index f2f4791..ed0bfad 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -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" >> $@.new
 endif
 
-ifneq ($(SEABIOS_ROM),)
-	echo "#ifdef ROM_INCLUDE_SEABIOS" >> $@.new
-	sh ./mkhex seabios $(SEABIOS_ROM) >> $@.new
-	echo "#endif" >> $@.new
-endif
-
 ifneq ($(OVMF_ROM),)
 	echo "#ifdef ROM_INCLUDE_OVMF" >> $@.new
 	sh ./mkhex ovmf $(OVMF_ROM) >> $@.new
diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c
index c6b3d9f..5d0a491 100644
--- a/tools/firmware/hvmloader/seabios.c
+++ b/tools/firmware/hvmloader/seabios.c
@@ -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,