From: "Jan Beulich" Subject: [PATCH] hvmloader: fix SeaBIOS interface Date: Fri, 23 Aug 2013 13:42:44 +0100 Message-ID: <521774E402000078000EDFF6@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartA192E9D4.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VCqhU-0006XG-68 for xen-devel@lists.xenproject.org; Fri, 23 Aug 2013 12:42:48 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser , Ian Campbell List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartA192E9D4.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The SeaBIOS ROM image may validly exceed 128k in size, it's only our interface code that so far assumed that it wouldn't. Remove that restriction by setting the base address depending on image size. Add a check to HVM loader so that too big images won't result in silent guest failure anymore. Uncomment the intended build-time size check for rombios, moving it into a function so that it would actually compile. Signed-off-by: Jan Beulich --- a/tools/firmware/hvmloader/config-seabios.h +++ b/tools/firmware/hvmloader/config-seabios.h @@ -3,8 +3,6 @@ =20 #define BIOS_INFO_PHYSICAL_ADDRESS 0x00001000 =20 -#define SEABIOS_PHYSICAL_ADDRESS 0x000E0000 - #endif /* __HVMLOADER_CONFIG_SEABIOS_H__ */ =20 /* --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -292,8 +292,12 @@ int main(void) if ( bios->bios_load ) bios->bios_load(bios); else + { + BUG_ON(bios->bios_address + bios->image_size > + HVMLOADER_PHYSICAL_ADDRESS); memcpy((void *)bios->bios_address, bios->image, bios->image_size); + } =20 if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode ) { --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -127,6 +127,8 @@ static void rombios_load(const struct bi uint32_t bioshigh; struct rombios_info *info; =20 + BUILD_BUG_ON(sizeof(rombios) > 0x100000 - ROMBIOS_PHYSICAL_ADDRESS); + memcpy((void *)config->bios_address, config->image, config->image_size); =20 @@ -206,8 +208,6 @@ static void rombios_create_smbios_tables SMBIOS_PHYSICAL_END); } =20 -//BUILD_BUG_ON(sizeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS))= ; - struct bios_config rombios_config =3D { .name =3D "ROMBIOS", =20 --- a/tools/firmware/hvmloader/seabios.c +++ b/tools/firmware/hvmloader/seabios.c @@ -133,15 +133,13 @@ static void seabios_setup_e820(void) dump_e820_table(e820, info->e820_nr); } =20 -//BUILD_BUG_ON(sizeof(seabios) > (0x00100000U - SEABIOS_PHYSICAL_ADDRESS))= ; - struct bios_config seabios_config =3D { .name =3D "SeaBIOS", =20 .image =3D seabios, .image_size =3D sizeof(seabios), =20 - .bios_address =3D SEABIOS_PHYSICAL_ADDRESS, + .bios_address =3D 0x100000 - sizeof(seabios), =20 .load_roms =3D NULL, =20 --=__PartA192E9D4.1__= Content-Type: text/plain; name="hvmloader-seabios.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="hvmloader-seabios.patch" hvmloader: fix SeaBIOS interface=0A=0AThe SeaBIOS ROM image may validly = exceed 128k in size, it's only our=0Ainterface code that so far assumed = that it wouldn't. Remove that=0Arestriction by setting the base address = depending on image size.=0A=0AAdd a check to HVM loader so that too big = images won't result in silent=0Aguest failure anymore.=0A=0AUncomment the = intended build-time size check for rombios, moving it=0Ainto a function so = that it would actually compile.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/tools/firmware/hvmloader/config-seabios.h=0A+++ = b/tools/firmware/hvmloader/config-seabios.h=0A@@ -3,8 +3,6 @@=0A =0A = #define BIOS_INFO_PHYSICAL_ADDRESS 0x00001000=0A =0A-#define SEABIOS_PHYSI= CAL_ADDRESS 0x000E0000=0A-=0A #endif /* __HVMLOADER_CONFIG_SEABIOS_H__ = */=0A =0A /*=0A--- a/tools/firmware/hvmloader/hvmloader.c=0A+++ b/tools/fir= mware/hvmloader/hvmloader.c=0A@@ -292,8 +292,12 @@ int main(void)=0A = if ( bios->bios_load )=0A bios->bios_load(bios);=0A else=0A+ = {=0A+ BUG_ON(bios->bios_address + bios->image_size >=0A+ = HVMLOADER_PHYSICAL_ADDRESS);=0A memcpy((void *)bios->bios_addre= ss, bios->image,=0A bios->image_size);=0A+ }=0A =0A = if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )=0A {=0A--- = a/tools/firmware/hvmloader/rombios.c=0A+++ b/tools/firmware/hvmloader/rombi= os.c=0A@@ -127,6 +127,8 @@ static void rombios_load(const struct bi=0A = uint32_t bioshigh;=0A struct rombios_info *info;=0A =0A+ BUILD_BUG_O= N(sizeof(rombios) > 0x100000 - ROMBIOS_PHYSICAL_ADDRESS);=0A+=0A = memcpy((void *)config->bios_address, config->image,=0A = config->image_size);=0A =0A@@ -206,8 +208,6 @@ static void rombios_create_s= mbios_tables=0A SMBIOS_PHYSICAL_END);=0A }=0A =0A-//BUILD_BUG_ON(si= zeof(rombios) > (0x00100000U - ROMBIOS_PHYSICAL_ADDRESS));=0A-=0A struct = bios_config rombios_config =3D {=0A .name =3D "ROMBIOS",=0A =0A--- = a/tools/firmware/hvmloader/seabios.c=0A+++ b/tools/firmware/hvmloader/seabi= os.c=0A@@ -133,15 +133,13 @@ static void seabios_setup_e820(void)=0A = dump_e820_table(e820, info->e820_nr);=0A }=0A =0A-//BUILD_BUG_ON(sizeof(sea= bios) > (0x00100000U - SEABIOS_PHYSICAL_ADDRESS));=0A-=0A struct bios_confi= g seabios_config =3D {=0A .name =3D "SeaBIOS",=0A =0A .image =3D = seabios,=0A .image_size =3D sizeof(seabios),=0A =0A- .bios_address = =3D SEABIOS_PHYSICAL_ADDRESS,=0A+ .bios_address =3D 0x100000 - = sizeof(seabios),=0A =0A .load_roms =3D NULL,=0A =0A --=__PartA192E9D4.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartA192E9D4.1__=--