diff --git a/SOURCES/config.base b/SOURCES/config.base
index 7d8b9dd..0471a5e 100644
--- a/SOURCES/config.base
+++ b/SOURCES/config.base
@@ -4,3 +4,4 @@ CONFIG_LSI_SCSI=n
 CONFIG_USB_OHCI=n
 CONFIG_BOOTSPLASH=n
 CONFIG_MEGASAS=n
+CONFIG_ROM_SIZE=128
diff --git a/SOURCES/config.base-256k b/SOURCES/config.base-256k
new file mode 100644
index 0000000..59b3036
--- /dev/null
+++ b/SOURCES/config.base-256k
@@ -0,0 +1,7 @@
+CONFIG_XEN=n
+CONFIG_ESP_SCSI=n
+CONFIG_LSI_SCSI=n
+CONFIG_USB_OHCI=n
+CONFIG_BOOTSPLASH=n
+CONFIG_MEGASAS=n
+CONFIG_ROM_SIZE=256
diff --git a/SOURCES/seabios-Workaround-for-a-win8.1-32-S4-resume-bug.patch b/SOURCES/seabios-Workaround-for-a-win8.1-32-S4-resume-bug.patch
new file mode 100644
index 0000000..918e0c8
--- /dev/null
+++ b/SOURCES/seabios-Workaround-for-a-win8.1-32-S4-resume-bug.patch
@@ -0,0 +1,73 @@
+From 5ce33ae3fd67eb576918f0b1a0e3a5df5715c7a4 Mon Sep 17 00:00:00 2001
+From: Radim Krcmar <rkrcmar@redhat.com>
+Date: Mon, 10 Mar 2014 15:14:27 +0100
+Subject: [PATCH] Workaround for a win8.1-32 S4 resume bug
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+RH-Author: Radim Krcmar <rkrcmar@redhat.com>
+Message-id: <1394464467-23560-1-git-send-email-rkrcmar@redhat.com>
+Patchwork-id: 58069
+O-Subject: [RHEL7.0 seabios PATCH] Workaround for a win8.1-32 S4 resume bug
+Bugzilla: 1050775
+RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
+RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+
+bug:  https://bugzilla.redhat.com/show_bug.cgi?id=1050775
+brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7176174
+This patch has no upstream equivalent.
+
+When a 32 bit version of windows 8.1 resumes from suspend, it writes 1
+into 0x72 in the early boot because it didn't expect a NULL pointer.
+0x72 is lower offset byte of 0x1c interrupt entry, so we jump into a
+middle of other function if this interrupt is triggered.
+
+Because 0x1c is only triggered from our handle_08, we detect if our
+default value (function that does only iret) has its lower offset byte
+overwritten and skip it in that case.
+(Windows never sets own callback there, so we always detect this bug
+ correctly, as seabios doesn't use it either
+ Other sources shouldn't incorrectly overwrite it or use seabios code,
+ but it is quite ok even if the guest did this on purpose.)
+
+The reason Windows uses NULL pointer is still unknown, but this bug is
+blocking WHQL certification, so we have to work around it in 7.0.
+
+Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
+---
+(It is either a Windows bug that is going to be solved on their side,
+ or we will find a better solution after consulting what went wrong.
+ Happens on RHEL6 too.)
+
+ src/clock.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/clock.c |    8 +++++++-
+ 1 files changed, 7 insertions(+), 1 deletions(-)
+
+diff --git a/src/clock.c b/src/clock.c
+index 71b913e..e066ecf 100644
+--- a/src/clock.c
++++ b/src/clock.c
+@@ -570,7 +570,13 @@ handle_08(void)
+     struct bregs br;
+     memset(&br, 0, sizeof(br));
+     br.flags = F_IF;
+-    call16_int(0x1c, &br);
++    struct segoff_s isr1c = GET_IVT(0x1c);
++    // hardcoded address of entry_iret_official with lower segment byte
++    // overwritten by 1
++    if (isr1c.seg == ((SEG_BIOS & ~0xff) | 0x1) && isr1c.offset == 0xff53)
++        dprintf(1, "Worked around win8.1-32 S4 resume bug\n");
++    else
++        call16_int(0x1c, &br);
+ 
+     eoi_pic1();
+ }
+-- 
+1.7.1
+
diff --git a/SOURCES/seabios-acpi-load-and-link-tables-through-romfile-loader.patch b/SOURCES/seabios-acpi-load-and-link-tables-through-romfile-loader.patch
new file mode 100644
index 0000000..4839a73
--- /dev/null
+++ b/SOURCES/seabios-acpi-load-and-link-tables-through-romfile-loader.patch
@@ -0,0 +1,94 @@
+From 3abbb783be92edcc07a999d50eac4e7ff5b6c7ba Mon Sep 17 00:00:00 2001
+Message-Id: <3abbb783be92edcc07a999d50eac4e7ff5b6c7ba.1387280747.git.minovotn@redhat.com>
+In-Reply-To: <c2d55efd8a9a156fe14fd477924fadb765ac9438.1387280747.git.minovotn@redhat.com>
+References: <c2d55efd8a9a156fe14fd477924fadb765ac9438.1387280747.git.minovotn@redhat.com>
+From: Michal Novotny <minovotn@redhat.com>
+Date: Tue, 17 Dec 2013 12:45:03 +0100
+Subject: [PATCH 3/3] acpi: load and link tables through romfile loader
+
+Load files through romfile loader and use for acpi tables.
+We need the RSDP pointer to hang the rest of the tables off it,
+to detect that we simply scan all memory in FSEG.
+
+Add an option to disable this feature (useful for old QEMU versions).
+This saves about 1Kbytes.
+
+enabled:
+Total size: 134932  Fixed: 61571  Free: 127212 (used 51.5% of 256KiB rom)
+
+disabled:
+Total size: 133836  Fixed: 61563  Free: 128308 (used 51.1% of 256KiB rom)
+
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry-picked from commit 11948748495841bd54721b250d68c7b3cb0475ef)
+Signed-off-by: Michal Novotny <minovotn@redhat.com>
+---
+ src/Kconfig | 11 +++++++++++
+ src/acpi.c  | 21 +++++++++++++++++++++
+ 2 files changed, 32 insertions(+)
+
+diff --git a/src/Kconfig b/src/Kconfig
+index 0b112ed..9fa848c 100644
+--- a/src/Kconfig
++++ b/src/Kconfig
+@@ -365,6 +365,17 @@ menu "BIOS Tables"
+         default y
+         help
+             Support generation of ACPI tables.
++    config FW_ROMFILE_LOAD
++        bool "Load BIOS tables from ROM files"
++        depends on QEMU
++        default y
++        help
++            Support loading BIOS firmware tables from ROM files.
++            At the moment, only ACPI tables can be loaded in this way.
++            Required for QEMU 1.7 and newer.
++            This option can be disabled for QEMU 1.6 and older
++            to save some space in the ROM file.
++            If unsure, say Y.
+ endmenu
+
+ source vgasrc/Kconfig
+diff --git a/src/acpi.c b/src/acpi.c
+index 6267d7b..c62fa3a 100644
+--- a/src/acpi.c
++++ b/src/acpi.c
+@@ -14,6 +14,7 @@
+ #include "ioport.h" // inl
+ #include "paravirt.h" // qemu_cfg_irq0_override
+ #include "dev-q35.h" // qemu_cfg_irq0_override
++#include "romfile_loader.h" // romfile_loader_execute
+ 
+ /****************************************************/
+ /* ACPI tables init */
+@@ -798,6 +799,26 @@ struct rsdp_descriptor *RsdpAddr;
+ void
+ acpi_bios_init(void)
+ {
++    if (CONFIG_FW_ROMFILE_LOAD) {
++        int loader_err;
++
++        dprintf(3, "load ACPI tables\n");
++
++        loader_err = romfile_loader_execute("etc/table-loader");
++
++        RsdpAddr = find_acpi_rsdp();
++
++        if (RsdpAddr)
++            return;
++
++        /* If present, loader should have installed an RSDP.
++         * Not installed? We might still be able to continue
++         * using the builtin RSDP.
++         */
++        if (!loader_err)
++            warn_internalerror();
++    }
++
+     if (! CONFIG_ACPI)
+         return;
+ 
+-- 
+1.7.11.7
+
diff --git a/SOURCES/seabios-biostables-support-looking-up-RSDP.patch b/SOURCES/seabios-biostables-support-looking-up-RSDP.patch
new file mode 100644
index 0000000..bc65503
--- /dev/null
+++ b/SOURCES/seabios-biostables-support-looking-up-RSDP.patch
@@ -0,0 +1,117 @@
+From c2d55efd8a9a156fe14fd477924fadb765ac9438 Mon Sep 17 00:00:00 2001
+Message-Id: <c2d55efd8a9a156fe14fd477924fadb765ac9438.1387280747.git.minovotn@redhat.com>
+From: "Michael S. Tsirkin" <mst@redhat.com>
+Date: Wed, 11 Dec 2013 15:16:27 +0100
+Subject: [PATCH 1/3] biostables: support looking up RSDP
+
+RH-Author: Michael S. Tsirkin <mst@redhat.com>
+Message-id: <1386774929-25693-2-git-send-email-mst@redhat.com>
+Patchwork-id: 56224
+O-Subject: [RHEL7.0 seabios PATCH 1/3] biostables: support looking up RSDP
+Bugzilla: 1034877
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
+RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
+RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
+
+Will be used when it's loaded from QEMU.
+
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry-picked from commit ff5f7921d904dd2ddbaded3941643da8ba5fa9aa)
+
+In rhel7 codebase we don't know the exact fseg
+range. Just scan all of the ROM range.
+
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+---
+ src/util.h       |  1 +
+ src/biostables.c | 41 ++++++++++++++++++++++++++++++++++-------
+ 2 files changed, 35 insertions(+), 7 deletions(-)
+
+Signed-off-by: Michal Novotny <minovotn@redhat.com>
+---
+ src/biostables.c | 41 ++++++++++++++++++++++++++++++++++-------
+ src/util.h       |  1 +
+ 2 files changed, 35 insertions(+), 7 deletions(-)
+
+diff --git a/src/biostables.c b/src/biostables.c
+index 81cc79b..2352ba4 100644
+--- a/src/biostables.c
++++ b/src/biostables.c
+@@ -57,22 +57,35 @@ copy_mptable(void *pos)
+     memcpy((void*)newpos + length, (void*)p->physaddr, mpclength);
+ }
+ 
+-static void
+-copy_acpi_rsdp(void *pos)
++static int
++get_acpi_rsdp_length(void *pos, unsigned size)
+ {
+-    if (RsdpAddr)
+-        return;
+     struct rsdp_descriptor *p = pos;
+     if (p->signature != RSDP_SIGNATURE)
+-        return;
++        return -1;
+     u32 length = 20;
++    if (length > size)
++        return -1;
+     if (checksum(pos, length) != 0)
+-        return;
++        return -1;
+     if (p->revision > 1) {
+         length = p->length;
++        if (length > size)
++            return -1;
+         if (checksum(pos, length) != 0)
+-            return;
++            return -1;
+     }
++    return length;
++}
++
++static void
++copy_acpi_rsdp(void *pos)
++{
++    if (RsdpAddr)
++        return;
++    int length = get_acpi_rsdp_length(pos, -1);
++    if (length < 0)
++        return;
+     void *newpos = malloc_fseg(length);
+     if (!newpos) {
+         warn_noalloc();
+@@ -115,3 +128,17 @@ copy_table(void *pos)
+     copy_acpi_rsdp(pos);
+     copy_smbios(pos);
+ }
++
++void *find_acpi_rsdp(void)
++{
++    /* The BIOS read-only memory space is between 0E0000h and 0FFFFFh. */
++    unsigned long start = 0xE0000;
++    unsigned long end = 0xFFFFF;
++    unsigned long pos;
++
++    for (pos = ALIGN(start, 0x10); pos <= ALIGN_DOWN(end, 0x10); pos += 0x10)
++        if (get_acpi_rsdp_length((void *)pos, end - pos) >= 0)
++            return (void *)pos;
++
++    return NULL;
++}
+diff --git a/src/util.h b/src/util.h
+index 7723bb1..e46d298 100644
+--- a/src/util.h
++++ b/src/util.h
+@@ -339,6 +339,7 @@ void coreboot_cbfs_setup(void);
+ 
+ // biostable.c
+ void copy_table(void *pos);
++void *find_acpi_rsdp(void);
+ 
+ // vgahooks.c
+ void handle_155f(struct bregs *regs);
+-- 
+1.7.11.7
+
diff --git a/SOURCES/seabios-build-explicitly-set-ROM-size.patch b/SOURCES/seabios-build-explicitly-set-ROM-size.patch
new file mode 100644
index 0000000..d34c828
--- /dev/null
+++ b/SOURCES/seabios-build-explicitly-set-ROM-size.patch
@@ -0,0 +1,113 @@
+From f1afa918b6f5d3069cc8c772b4cca254d21cba6b Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Mon, 9 Dec 2013 09:14:24 +0100
+Subject: [PATCH 1/2] build: explicitly set ROM size
+
+RH-Author: Gerd Hoffmann <kraxel@redhat.com>
+Message-id: <1386580465-6692-2-git-send-email-kraxel@redhat.com>
+Patchwork-id: 56028
+O-Subject: [RHEL-7 seabios PATCH 1/2] build: explicitly set ROM size
+Bugzilla: 1038604
+RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
+RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
+RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
+
+Add a config option to specify the rom size wanted.  Default is zero,
+which will automatically figure the needed size.
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry picked from commit 85f8fac87526341d775b02a0bfbc29d97f3ba22a)
+
+Conflicts:
+	Makefile
+---
+ Makefile          |  3 ++-
+ src/Kconfig       | 11 +++++++++++
+ tools/checkrom.py | 21 +++++++++++++++------
+ 3 files changed, 28 insertions(+), 7 deletions(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ Makefile          |    3 ++-
+ src/Kconfig       |   11 +++++++++++
+ tools/checkrom.py |   21 +++++++++++++++------
+ 3 files changed, 28 insertions(+), 7 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 409aefa..b82bd58 100644
+--- a/Makefile
++++ b/Makefile
+@@ -167,7 +167,8 @@ $(OUT)bios.bin.elf $(OUT)bios.bin: $(OUT)rom.o tools/checkrom.py
+ 	@echo "  Prepping $@"
+ 	$(Q)$(OBJDUMP) -thr $< > $<.objdump
+ 	$(Q)$(OBJCOPY) -O binary $< $(OUT)bios.bin.raw
+-	$(Q)$(PYTHON) ./tools/checkrom.py $<.objdump $(OUT)bios.bin.raw $(OUT)bios.bin
++	$(Q)$(PYTHON) ./tools/checkrom.py $<.objdump $(CONFIG_ROM_SIZE) \
++		$(OUT)bios.bin.raw $(OUT)bios.bin
+ 	$(Q)$(STRIP) -R .comment $< -o $(OUT)bios.bin.elf
+ 
+ 
+diff --git a/src/Kconfig b/src/Kconfig
+index d00c66c..f5dce60 100644
+--- a/src/Kconfig
++++ b/src/Kconfig
+@@ -90,6 +90,17 @@ endchoice
+         help
+             Support floppy images in coreboot flash.
+ 
++    config ROM_SIZE
++        int "ROM size (in KB)"
++        default 0
++        help
++            Set the ROM size.  Say '0' here to make seabios figure the
++            needed size automatically.
++
++            Currently SeaBIOS will easily fit into 256 KB. To make it fit
++            it into 128 KB (which was big enough for a long time) you'll
++            probably have to disable some featues such as xhci support.
++
+ endmenu
+ 
+ menu "Hardware support"
+diff --git a/tools/checkrom.py b/tools/checkrom.py
+index 69d65e8..b997e8c 100755
+--- a/tools/checkrom.py
++++ b/tools/checkrom.py
+@@ -10,7 +10,7 @@ import layoutrom
+ 
+ def main():
+     # Get args
+-    objinfo, rawfile, outfile = sys.argv[1:]
++    objinfo, finalsize, rawfile, outfile = sys.argv[1:]
+ 
+     # Read in symbols
+     objinfofile = open(objinfo, 'rb')
+@@ -21,11 +21,20 @@ def main():
+     rawdata = f.read()
+     f.close()
+     datasize = len(rawdata)
+-    finalsize = 64*1024
+-    if datasize > 64*1024:
+-        finalsize = 128*1024
+-        if datasize > 128*1024:
+-            finalsize = 256*1024
++    finalsize = int(finalsize) * 1024
++    if finalsize == 0:
++        finalsize = 64*1024
++        if datasize > 64*1024:
++            finalsize = 128*1024
++            if datasize > 128*1024:
++                finalsize = 256*1024
++    if datasize > finalsize:
++        print "Error!  ROM doesn't fit (%d > %d)" % (datasize, finalsize)
++        print "   You have to either increase the size (CONFIG_ROM_SIZE)"
++        print "   or turn off some features (such as hardware support not"
++        print "   needed) to make it fit.  Trying a more recent gcc version"
++        print "   might work too."
++        sys.exit(1)
+ 
+     # Sanity checks
+     start = symbols['code32flat_start'].offset
+-- 
+1.7.1
+
diff --git a/SOURCES/seabios-init_virtio_scsi-reset-the-HBA-before-freeing-its-vi.patch b/SOURCES/seabios-init_virtio_scsi-reset-the-HBA-before-freeing-its-vi.patch
new file mode 100644
index 0000000..1704905
--- /dev/null
+++ b/SOURCES/seabios-init_virtio_scsi-reset-the-HBA-before-freeing-its-vi.patch
@@ -0,0 +1,70 @@
+From 395b6a18728feca247bad3adea3b7c6884eb30fd Mon Sep 17 00:00:00 2001
+From: Laszlo Ersek <lersek@redhat.com>
+Date: Fri, 17 Jan 2014 19:15:23 -0500
+Subject: [PATCH 1/6] init_virtio_scsi(): reset the HBA before freeing its
+ virtio ring
+
+Message-id: <1389986123-16290-1-git-send-email-lersek@redhat.com>
+Patchwork-id: 56797
+O-Subject: [RHEL-7.0 seabios PATCH] init_virtio_scsi(): reset the HBA before freeing its virtio ring
+Bugzilla: 1013418
+RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
+RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
+RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
+
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1013418
+Brew:     https://brewweb.devel.redhat.com/taskinfo?taskID=6893168
+
+When init_virtio_scsi() finds no SCSI targets connected to the HBA, it
+frees the virtio ring. Other code in SeaBIOS proceeds to overwrite the
+area. However, the ring is in use by qemu at that point -- not only did we
+report the (ACK|DRIVER|DRIVER_OK) status earlier, we even communicated
+over the ring.
+
+Of course SeaBIOS doesn't "kick" the HBA ever again, hence qemu has no
+reason to look at the ring. However, when qemu uses KVM acceleration, and
+ioeventfd is enabled for the HBA, then a vmstate change to "running"
+(including stop->cont monitor commands and incoming migration) "forces" a
+kick (see qemu commit 25db9ebe). Qemu then tries to interpret whatever
+unrelated guest data is in the HBA's original ring area, as virtio
+protocol. Qemu exits upon seeing the garbage.
+
+init_virtio_scsi() should reset the HBA before allowing the virtio ring
+memory to be reused. Device reset causes the hypervisor to drop its
+references.
+
+This change is justified / underpinned by pure virtio-spec compliance as
+well.
+
+Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1013418
+
+Signed-off-by: Laszlo Ersek <lersek@redhat.com>
+(cherry picked from commit 5f2d17d35b2339526f3b3d580b279ea78e406a25)
+---
+ src/virtio-scsi.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/virtio-scsi.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/virtio-scsi.c b/src/virtio-scsi.c
+index bf6c68b..7caf405 100644
+--- a/src/virtio-scsi.c
++++ b/src/virtio-scsi.c
+@@ -154,8 +154,10 @@ init_virtio_scsi(struct pci_device *pci)
+     for (tot = 0, i = 0; i < 256; i++)
+         tot += virtio_scsi_scan_target(pci, ioaddr, vq, i);
+ 
+-    if (!tot)
++    if (!tot) {
++        vp_reset(ioaddr);
+         goto fail;
++    }
+ 
+     return;
+ 
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-pci-align-64bit-pci-regions-to-1G.patch b/SOURCES/seabios-pci-align-64bit-pci-regions-to-1G.patch
new file mode 100644
index 0000000..10b5339
--- /dev/null
+++ b/SOURCES/seabios-pci-align-64bit-pci-regions-to-1G.patch
@@ -0,0 +1,51 @@
+From 3c0e8f345d3653dd0a93212961b2417cb5623403 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Mon, 27 Jan 2014 15:31:26 -0500
+Subject: [PATCH 4/6] pci: align 64bit pci regions to 1G
+
+Message-id: <1390836688-16749-2-git-send-email-kraxel@redhat.com>
+Patchwork-id: 56957
+O-Subject: [RHEL-7 seabios PATCH 1/3] pci: align 64bit pci regions to 1G
+Bugzilla: 1055832
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
+RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
+
+So they are hugepage aligned.
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry picked from commit f21c0066df641c2d0e383254bb69a42a60c0616c)
+---
+ src/pciinit.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/pciinit.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/src/pciinit.c b/src/pciinit.c
+index e501964..15744e7 100644
+--- a/src/pciinit.c
++++ b/src/pciinit.c
+@@ -761,10 +761,15 @@ static void pci_bios_map_devices(struct pci_bus *busses)
+         u64 align_mem = pci_region_align(&r64_mem);
+         u64 align_pref = pci_region_align(&r64_pref);
+ 
+-        r64_mem.base = ALIGN(0x100000000LL + RamSizeOver4G, align_mem);
+-        r64_pref.base = ALIGN(r64_mem.base + sum_mem, align_pref);
++        r64_mem.base = 0x100000000LL + RamSizeOver4G;
++        r64_mem.base = ALIGN(r64_mem.base, align_mem);
++        r64_mem.base = ALIGN(r64_mem.base, (1LL<<30));    // 1G hugepage
++        r64_pref.base = r64_mem.base + sum_mem;
++        r64_pref.base = ALIGN(r64_pref.base, align_pref);
++        r64_pref.base = ALIGN(r64_pref.base, (1LL<<30));  // 1G hugepage
+         pcimem64_start = r64_mem.base;
+         pcimem64_end = r64_pref.base + sum_pref;
++        pcimem64_end = ALIGN(pcimem64_end, (1LL<<30));    // 1G hugepage
+ 
+         pci_region_map_entries(busses, &r64_mem);
+         pci_region_map_entries(busses, &r64_pref);
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-pci-improve-io-address-space-allocation.patch b/SOURCES/seabios-pci-improve-io-address-space-allocation.patch
new file mode 100644
index 0000000..856e715
--- /dev/null
+++ b/SOURCES/seabios-pci-improve-io-address-space-allocation.patch
@@ -0,0 +1,111 @@
+From b2d132c9e3a65858fb745bdeafd1700a58db9bdc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Mon, 27 Jan 2014 15:31:28 -0500
+Subject: [PATCH 6/6] pci: improve io address space allocation
+
+Message-id: <1390836688-16749-4-git-send-email-kraxel@redhat.com>
+Patchwork-id: 56958
+O-Subject: [RHEL-7 seabios PATCH 3/3] pci: improve io address space allocation
+Bugzilla: 1055832
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
+RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
+
+This patch improves the io address space allocation.  It adds a check
+that the region above 0xc000 which is traditionally used for pci io
+is actually big enougth.  If it isn't it tries the larger window at
+0x1000.  If that is to small too it errors out.
+
+When creating guests with multiple pci-pci bridges (and devices with
+io regions behind them) the 0xc000 -> 0xffff region quickly becomes
+too small.
+
+While being at it document the io address space layout used by
+qemu/seabios.
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry picked from commit fc3cd00045cbe96ca1e6b6601d26901f040bfcdb)
+---
+ src/pciinit.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 40 insertions(+), 5 deletions(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/pciinit.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 40 insertions(+), 5 deletions(-)
+
+diff --git a/src/pciinit.c b/src/pciinit.c
+index 4e5d7d0..fe58f59 100644
+--- a/src/pciinit.c
++++ b/src/pciinit.c
+@@ -663,10 +663,42 @@ static int pci_bios_check_devices(struct pci_bus *busses)
+  ****************************************************************/
+ 
+ // Setup region bases (given the regions' size and alignment)
+-static int pci_bios_init_root_regions(struct pci_bus *bus)
+-{
+-    bus->r[PCI_REGION_TYPE_IO].base = 0xc000;
++static int pci_bios_init_root_regions_io(struct pci_bus *bus)
++{
++    /*
++     * QEMU I/O address space usage:
++     *   0000 - 0fff    legacy isa, pci config, pci root bus, ...
++     *   1000 - 9fff    free
++     *   a000 - afff    hotplug (cpu, pci via acpi, i440fx/piix only)
++     *   b000 - bfff    power management (PORT_ACPI_PM_BASE)
++     *                  [ qemu 1.4+ implements pci config registers
++     *                    properly so guests can place the registers
++     *                    where they want, on older versions its fixed ]
++     *   c000 - ffff    free, traditionally used for pci io
++     */
++    struct pci_region *r_io = &bus->r[PCI_REGION_TYPE_IO];
++    u64 sum = pci_region_sum(r_io);
++    if (sum < 0x4000) {
++        /* traditional region is big enougth, use it */
++        r_io->base = 0xc000;
++    } else if (sum < 0x9000) {
++        /* use the larger region at 0x1000 */
++        r_io->base = 0x1000;
++    } else {
++        /*
++         * Not enougth io address space -> error out.
++         *
++         * TODO: on q35 we can move PORT_ACPI_PM_BASE out of
++         * the way, then use the whole 1000 -> ffff region.
++         */
++        return -1;
++    }
++    dprintf(1, "PCI: IO: %4llx - %4llx\n", r_io->base, r_io->base + sum - 1);
++    return 0;
++}
+ 
++static int pci_bios_init_root_regions_mem(struct pci_bus *bus)
++{
+     struct pci_region *r_end = &bus->r[PCI_REGION_TYPE_PREFMEM];
+     struct pci_region *r_start = &bus->r[PCI_REGION_TYPE_MEM];
+ 
+@@ -744,8 +776,11 @@ static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)
+ 
+ static void pci_bios_map_devices(struct pci_bus *busses)
+ {
++    if (pci_bios_init_root_regions_io(busses))
++        panic("PCI: out of I/O address space\n");
++
+     dprintf(1, "PCI: 32: %016llx - %016llx\n", pcimem_start, pcimem_end);
+-    if (pci_bios_init_root_regions(busses)) {
++    if (pci_bios_init_root_regions_mem(busses)) {
+         struct pci_region r64_mem, r64_pref;
+         r64_mem.list = NULL;
+         r64_pref.list = NULL;
+@@ -754,7 +789,7 @@ static void pci_bios_map_devices(struct pci_bus *busses)
+         pci_region_migrate_64bit_entries(&busses[0].r[PCI_REGION_TYPE_PREFMEM],
+                                          &r64_pref);
+ 
+-        if (pci_bios_init_root_regions(busses))
++        if (pci_bios_init_root_regions_mem(busses))
+             panic("PCI: out of 32bit address space\n");
+ 
+         u64 sum_mem = pci_region_sum(&r64_mem);
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-pci-log-pci-windows.patch b/SOURCES/seabios-pci-log-pci-windows.patch
new file mode 100644
index 0000000..3fa2b47
--- /dev/null
+++ b/SOURCES/seabios-pci-log-pci-windows.patch
@@ -0,0 +1,47 @@
+From 231900b6da3959e36c364bb5733446891dfd171e Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Mon, 27 Jan 2014 15:31:27 -0500
+Subject: [PATCH 5/6] pci: log pci windows
+
+Message-id: <1390836688-16749-3-git-send-email-kraxel@redhat.com>
+Patchwork-id: 56959
+O-Subject: [RHEL-7 seabios PATCH 2/3] pci: log pci windows
+Bugzilla: 1055832
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
+RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
+
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry picked from commit c72370ea3764bd009beb49ab3857a3953ed568de)
+---
+ src/pciinit.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/pciinit.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/pciinit.c b/src/pciinit.c
+index 15744e7..4e5d7d0 100644
+--- a/src/pciinit.c
++++ b/src/pciinit.c
+@@ -744,6 +744,7 @@ static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)
+ 
+ static void pci_bios_map_devices(struct pci_bus *busses)
+ {
++    dprintf(1, "PCI: 32: %016llx - %016llx\n", pcimem_start, pcimem_end);
+     if (pci_bios_init_root_regions(busses)) {
+         struct pci_region r64_mem, r64_pref;
+         r64_mem.list = NULL;
+@@ -770,6 +771,7 @@ static void pci_bios_map_devices(struct pci_bus *busses)
+         pcimem64_start = r64_mem.base;
+         pcimem64_end = r64_pref.base + sum_pref;
+         pcimem64_end = ALIGN(pcimem64_end, (1LL<<30));    // 1G hugepage
++        dprintf(1, "PCI: 64: %016llx - %016llx\n", pcimem64_start, pcimem64_end);
+ 
+         pci_region_map_entries(busses, &r64_mem);
+         pci_region_map_entries(busses, &r64_pref);
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-resume-restore-piix-pm-config-registers-after-resume.patch b/SOURCES/seabios-resume-restore-piix-pm-config-registers-after-resume.patch
new file mode 100644
index 0000000..f09452b
--- /dev/null
+++ b/SOURCES/seabios-resume-restore-piix-pm-config-registers-after-resume.patch
@@ -0,0 +1,138 @@
+From 141d320f8763898865780ef07fe6e242279df6d1 Mon Sep 17 00:00:00 2001
+From: Laszlo Ersek <lersek@redhat.com>
+Date: Fri, 24 Jan 2014 18:50:34 -0500
+Subject: [PATCH 3/6] resume: restore piix pm config registers after resume
+
+Message-id: <1390589434-13326-2-git-send-email-lersek@redhat.com>
+Patchwork-id: 56947
+O-Subject: [RHEL-7.0 seabios PATCH 1/1] resume: restore piix pm config registers after resume
+Bugzilla: 1049860
+RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
+RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
+RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
+
+From: Marcel Apfelbaum <marcel.a@redhat.com>
+
+On resume, the OS queries the power management event that
+caused it. In order to complete this task, it executes some
+reads to the piix pm io space. This all happens before the
+OS has a chance to restore the PCI config space for devices,
+so it is bios's responsibility to make sure the pm IO space
+is configured correctly. (During suspend, the piix pm
+configuration space is lost).
+
+Note: For 'ordinary' pci devices the config space is
+saved by the OS on sleep and restored on resume.
+
+Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
+Acked-by: Michael S. Tsirkin <mst@redhat.com>
+(cherry picked from commit 40d020f56226aee7c75a6c29f471c4b866765732)
+
+Conflicts (mainly due to not having upstream d83c87b, "Normalize POST
+initialization function name suffixes."):
+
+	src/pciinit.c
+	src/resume.c
+	src/util.h
+
+Signed-off-by: Laszlo Ersek <lersek@redhat.com>
+---
+ src/util.h    |  1 +
+ src/pciinit.c | 26 ++++++++++++++++++++++----
+ src/resume.c  |  2 ++
+ 3 files changed, 25 insertions(+), 4 deletions(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ src/pciinit.c | 26 ++++++++++++++++++++++----
+ src/resume.c  |  2 ++
+ src/util.h    |  1 +
+ 3 files changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/src/pciinit.c b/src/pciinit.c
+index b3f359f..e501964 100644
+--- a/src/pciinit.c
++++ b/src/pciinit.c
+@@ -225,10 +225,8 @@ static void apple_macio_init(struct pci_device *pci, void *arg)
+     pci_set_io_region_addr(pci, 0, 0x80800000, 0);
+ }
+ 
+-/* PIIX4 Power Management device (for ACPI) */
+-static void piix4_pm_init(struct pci_device *pci, void *arg)
++static void piix4_pm_config_setup(u16 bdf)
+ {
+-    u16 bdf = pci->bdf;
+     // acpi sci is hardwired to 9
+     pci_config_writeb(bdf, PCI_INTERRUPT_LINE, 9);
+ 
+@@ -236,6 +234,15 @@ static void piix4_pm_init(struct pci_device *pci, void *arg)
+     pci_config_writeb(bdf, 0x80, 0x01); /* enable PM io space */
+     pci_config_writel(bdf, 0x90, PORT_SMB_BASE | 1);
+     pci_config_writeb(bdf, 0xd2, 0x09); /* enable SMBus io space */
++}
++
++static int PiixPmBDF = -1;
++
++/* PIIX4 Power Management device (for ACPI) */
++static void piix4_pm_setup(struct pci_device *pci, void *arg)
++{
++    PiixPmBDF = pci->bdf;
++    piix4_pm_config_setup(pci->bdf);
+ 
+     pmtimer_init(PORT_ACPI_PM_BASE + 0x08, PM_TIMER_FREQUENCY / 1000);
+ }
+@@ -278,7 +285,7 @@ static const struct pci_device_id pci_device_tbl[] = {
+ 
+     /* PIIX4 Power Management device (for ACPI) */
+     PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3,
+-               piix4_pm_init),
++               piix4_pm_setup),
+     PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_SMBUS,
+                ich9_smbus_init),
+ 
+@@ -289,6 +296,17 @@ static const struct pci_device_id pci_device_tbl[] = {
+     PCI_DEVICE_END,
+ };
+ 
++void pci_resume(void)
++{
++    if (!CONFIG_QEMU) {
++        return;
++    }
++
++    if (PiixPmBDF >= 0) {
++        piix4_pm_config_setup(PiixPmBDF);
++    }
++}
++
+ static void pci_bios_init_device(struct pci_device *pci)
+ {
+     u16 bdf = pci->bdf;
+diff --git a/src/resume.c b/src/resume.c
+index f1a96ac..eed94aa 100644
+--- a/src/resume.c
++++ b/src/resume.c
+@@ -111,6 +111,8 @@ s3_resume(void)
+     pic_setup();
+     smm_init();
+ 
++    pci_resume();
++
+     s3_resume_vga_init();
+ 
+     make_bios_readonly();
+diff --git a/src/util.h b/src/util.h
+index e46d298..59c0fcf 100644
+--- a/src/util.h
++++ b/src/util.h
+@@ -317,6 +317,7 @@ void qemu_prep_reset(void);
+ // pciinit.c
+ extern const u8 pci_irqs[4];
+ void pci_setup(void);
++void pci_resume(void);
+ 
+ // smm.c
+ void smm_init(void);
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-romfile_loader-utility-to-patch-in-memory-ROM-files.patch b/SOURCES/seabios-romfile_loader-utility-to-patch-in-memory-ROM-files.patch
new file mode 100644
index 0000000..6364be2
--- /dev/null
+++ b/SOURCES/seabios-romfile_loader-utility-to-patch-in-memory-ROM-files.patch
@@ -0,0 +1,319 @@
+From b841f263ee4264333fcb571fcc4f7769040df90b Mon Sep 17 00:00:00 2001
+Message-Id: <b841f263ee4264333fcb571fcc4f7769040df90b.1387280747.git.minovotn@redhat.com>
+In-Reply-To: <c2d55efd8a9a156fe14fd477924fadb765ac9438.1387280747.git.minovotn@redhat.com>
+References: <c2d55efd8a9a156fe14fd477924fadb765ac9438.1387280747.git.minovotn@redhat.com>
+From: "Michael S. Tsirkin" <mst@redhat.com>
+Date: Wed, 11 Dec 2013 15:16:35 +0100
+Subject: [PATCH 2/3] romfile_loader: utility to patch in-memory ROM files
+
+RH-Author: Michael S. Tsirkin <mst@redhat.com>
+Message-id: <1386774929-25693-3-git-send-email-mst@redhat.com>
+Patchwork-id: 56225
+O-Subject: [RHEL7.0 seabios PATCH 2/3] romfile_loader: utility to patch in-memory ROM files
+Bugzilla: 1034877
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
+RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
+RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
+
+Add ability for a ROM file to point to
+it's image in memory. When file is in memory,
+add utility that can patch it, storing
+pointers to one file within another file.
+
+This is not a lot of code: together with the follow-up patch to load
+ACPI tables from ROM, it's about 1K extra.
+
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry-picked from commit 4a02768fbbd33e263122bf5deb54382de56c1cfe)
+---
+ Makefile             |   2 +-
+ src/romfile_loader.h |  72 +++++++++++++++++++++
+ src/romfile_loader.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 246 insertions(+), 1 deletion(-)
+ create mode 100644 src/romfile_loader.h
+ create mode 100644 src/romfile_loader.c
+
+Signed-off-by: Michal Novotny <minovotn@redhat.com>
+---
+ Makefile             |   2 +-
+ src/romfile_loader.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++
+ src/romfile_loader.h |  72 +++++++++++++++++++++
+ 3 files changed, 246 insertions(+), 1 deletion(-)
+ create mode 100644 src/romfile_loader.c
+ create mode 100644 src/romfile_loader.h
+
+diff --git a/Makefile b/Makefile
+index f28d86c..9125ea0 100644
+--- a/Makefile
++++ b/Makefile
+@@ -18,7 +18,7 @@ SRC16=$(SRCBOTH) system.c disk.c font.c
+ SRC32FLAT=$(SRCBOTH) post.c shadow.c memmap.c coreboot.c boot.c \
+     acpi.c smm.c mptable.c smbios.c pciinit.c optionroms.c mtrr.c \
+     lzmadecode.c bootsplash.c jpeg.c usb-hub.c paravirt.c \
+-    biostables.c xen.c bmp.c romfile.c
++    biostables.c xen.c bmp.c romfile.c romfile_loader.c
+ SRC32SEG=util.c output.c pci.c pcibios.c apm.c stacks.c
+ 
+ # Default compiler flags
+diff --git a/src/romfile_loader.c b/src/romfile_loader.c
+new file mode 100644
+index 0000000..cae3cc3
+--- /dev/null
++++ b/src/romfile_loader.c
+@@ -0,0 +1,173 @@
++#include "romfile_loader.h"
++#include "byteorder.h" // leXX_to_cpu/cpu_to_leXX
++#include "util.h"
++
++struct romfile_loader_file {
++    struct romfile_s *file;
++    void *data;
++};
++struct romfile_loader_files {
++    int nfiles;
++    struct romfile_loader_file files[];
++};
++
++static struct romfile_loader_file *
++romfile_loader_find(const char *name,
++                    struct romfile_loader_files *files)
++{
++    int i;
++    if (name[ROMFILE_LOADER_FILESZ - 1])
++        return NULL;
++    for (i = 0; i < files->nfiles; ++i)
++        if (!strcmp(files->files[i].file->name, name))
++            return &files->files[i];
++    return NULL;
++}
++
++static void romfile_loader_allocate(struct romfile_loader_entry_s *entry,
++                                    struct romfile_loader_files *files)
++{
++    struct zone_s *zone;
++    struct romfile_loader_file *file = &files->files[files->nfiles];
++    void *data;
++    int ret;
++    unsigned alloc_align = le32_to_cpu(entry->alloc_align);
++
++    if (alloc_align & (alloc_align - 1))
++        goto err;
++
++    switch (entry->alloc_zone) {
++        case ROMFILE_LOADER_ALLOC_ZONE_HIGH:
++            zone = &ZoneHigh;
++            break;
++        case ROMFILE_LOADER_ALLOC_ZONE_FSEG:
++            zone = &ZoneFSeg;
++            break;
++        default:
++            goto err;
++    }
++    if (alloc_align < MALLOC_MIN_ALIGN)
++        alloc_align = MALLOC_MIN_ALIGN;
++    if (entry->alloc_file[ROMFILE_LOADER_FILESZ - 1])
++        goto err;
++    file->file = romfile_find(entry->alloc_file);
++    if (!file->file || !file->file->size)
++        return;
++    data = pmm_malloc(zone, PMM_DEFAULT_HANDLE, file->file->size, alloc_align);
++    if (!data) {
++        warn_noalloc();
++        return;
++    }
++    ret = file->file->copy(file->file, data, file->file->size);
++    if (ret != file->file->size)
++        goto file_err;
++    file->data = data;
++    files->nfiles++;
++    return;
++
++file_err:
++    free(data);
++err:
++    warn_internalerror();
++}
++
++static void romfile_loader_add_pointer(struct romfile_loader_entry_s *entry,
++                                       struct romfile_loader_files *files)
++{
++    struct romfile_loader_file *dest_file;
++    struct romfile_loader_file *src_file;
++    unsigned offset = le32_to_cpu(entry->pointer_offset);
++    u64 pointer = 0;
++
++    dest_file = romfile_loader_find(entry->pointer_dest_file, files);
++    src_file = romfile_loader_find(entry->pointer_src_file, files);
++
++    if (!dest_file || !src_file || !dest_file->data || !src_file->data ||
++        offset + entry->pointer_size < offset ||
++        offset + entry->pointer_size > dest_file->file->size ||
++        entry->pointer_size < 1 || entry->pointer_size > 8 ||
++        entry->pointer_size & (entry->pointer_size - 1))
++        goto err;
++
++    memcpy(&pointer, dest_file->data + offset, entry->pointer_size);
++    pointer = le64_to_cpu(pointer);
++    pointer += (unsigned long)src_file->data;
++    pointer = cpu_to_le64(pointer);
++    memcpy(dest_file->data + offset, &pointer, entry->pointer_size);
++
++    return;
++err:
++    warn_internalerror();
++}
++
++static void romfile_loader_add_checksum(struct romfile_loader_entry_s *entry,
++                                        struct romfile_loader_files *files)
++{
++    struct romfile_loader_file *file;
++    unsigned offset = le32_to_cpu(entry->cksum_offset);
++    unsigned start = le32_to_cpu(entry->cksum_start);
++    unsigned len = le32_to_cpu(entry->cksum_length);
++    u8 *data;
++
++    file = romfile_loader_find(entry->cksum_file, files);
++
++    if (!file || !file->data || offset >= file->file->size ||
++        start + len < start || start + len > file->file->size)
++        goto err;
++
++    data = file->data + offset;
++    *data -= checksum(file->data + start, len);
++
++    return;
++err:
++    warn_internalerror();
++}
++
++int romfile_loader_execute(const char *name)
++{
++    struct romfile_loader_entry_s *entry;
++    int size, offset = 0, nfiles;
++    struct romfile_loader_files *files;
++    void *data = romfile_loadfile(name, &size);
++    if (!data)
++        return -1;
++
++    if (size % sizeof(*entry)) {
++        warn_internalerror();
++        goto err;
++    }
++
++    /* (over)estimate the number of files to load. */
++    nfiles = size / sizeof(*entry);
++    files = malloc_tmp(sizeof(*files) + nfiles * sizeof(files->files[0]));
++    if (!files) {
++        warn_noalloc();
++        goto err;
++    }
++    files->nfiles = 0;
++
++    for (offset = 0; offset < size; offset += sizeof(*entry)) {
++        entry = data + offset;
++        switch (le32_to_cpu(entry->command)) {
++                case ROMFILE_LOADER_COMMAND_ALLOCATE:
++                        romfile_loader_allocate(entry, files);
++                        break;
++                case ROMFILE_LOADER_COMMAND_ADD_POINTER:
++                        romfile_loader_add_pointer(entry, files);
++                        break;
++                case ROMFILE_LOADER_COMMAND_ADD_CHECKSUM:
++                        romfile_loader_add_checksum(entry, files);
++                default:
++                        /* Skip commands that we don't recognize. */
++                        break;
++        }
++    }
++
++    free(files);
++    free(data);
++    return 0;
++
++err:
++    free(data);
++    return -1;
++}
+diff --git a/src/romfile_loader.h b/src/romfile_loader.h
+new file mode 100644
+index 0000000..15eab2a
+--- /dev/null
++++ b/src/romfile_loader.h
+@@ -0,0 +1,72 @@
++#ifndef __ROMFILE_LOADER_H
++#define __ROMFILE_LOADER_H
++
++#include "types.h" // u8
++#include "util.h" // romfile_s
++
++#define ROMFILE_LOADER_FILESZ 56
++
++/* ROM file linker/loader interface. Linker uses little endian format */
++struct romfile_loader_entry_s {
++    u32 command;
++    union {
++        /*
++         * COMMAND_ALLOCATE - allocate a table from @alloc_file
++         * subject to @alloc_align alignment (must be power of 2)
++         * and @alloc_zone (can be HIGH or FSEG) requirements.
++         *
++         * Must appear exactly once for each file, and before
++         * this file is referenced by any other command.
++         */
++        struct {
++            char alloc_file[ROMFILE_LOADER_FILESZ];
++            u32 alloc_align;
++            u8 alloc_zone;
++        };
++
++        /*
++         * COMMAND_ADD_POINTER - patch the table (originating from
++         * @dest_file) at @pointer_offset, by adding a pointer to the table
++         * originating from @src_file. 1,2,4 or 8 byte unsigned
++         * addition is used depending on @pointer_size.
++         */
++        struct {
++            char pointer_dest_file[ROMFILE_LOADER_FILESZ];
++            char pointer_src_file[ROMFILE_LOADER_FILESZ];
++            u32 pointer_offset;
++            u8 pointer_size;
++        };
++
++        /*
++         * COMMAND_ADD_CHECKSUM - calculate checksum of the range specified by
++         * @cksum_start and @cksum_length fields,
++         * and then add the value at @cksum_offset.
++         * Checksum simply sums -X for each byte X in the range
++         * using 8-bit math.
++         */
++        struct {
++            char cksum_file[ROMFILE_LOADER_FILESZ];
++            u32 cksum_offset;
++            u32 cksum_start;
++            u32 cksum_length;
++        };
++
++        /* padding */
++        char pad[124];
++    };
++};
++
++enum {
++    ROMFILE_LOADER_COMMAND_ALLOCATE     = 0x1,
++    ROMFILE_LOADER_COMMAND_ADD_POINTER  = 0x2,
++    ROMFILE_LOADER_COMMAND_ADD_CHECKSUM = 0x3,
++};
++
++enum {
++    ROMFILE_LOADER_ALLOC_ZONE_HIGH = 0x1,
++    ROMFILE_LOADER_ALLOC_ZONE_FSEG = 0x2,
++};
++
++int romfile_loader_execute(const char *name);
++
++#endif
+-- 
+1.7.11.7
+
diff --git a/SOURCES/seabios-smbios-catch-zero-length-strings.patch b/SOURCES/seabios-smbios-catch-zero-length-strings.patch
new file mode 100644
index 0000000..1913d36
--- /dev/null
+++ b/SOURCES/seabios-smbios-catch-zero-length-strings.patch
@@ -0,0 +1,77 @@
+From ba6951c82c8af1c9fd4669d8561517bd7850eeee Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <kraxel@redhat.com>
+Date: Wed, 22 Jan 2014 09:32:53 -0500
+Subject: [PATCH 2/6] smbios: catch zero-length strings
+
+Message-id: <1390383173-24339-2-git-send-email-kraxel@redhat.com>
+Patchwork-id: 56881
+O-Subject: [RHEL-7 seabios PATCH 1/1] smbios: catch zero-length strings
+Bugzilla: 1052837
+RH-Acked-by: Markus Armbruster <armbru@redhat.com>
+RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
+RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
+
+qemu may pass us zero-length strings for smbios fields, when starting
+qemu this way  ...
+
+	qemu -smbios type=1,version=,serial=test
+
+... for example.
+
+Today we don't specifically handle them and simply append them to the
+string list.  Therefore we get two string-terminating zeros in a row.
+Result is that we by accident create a end-of-entry marker in the middle
+of the entry.
+
+Fix this by handling zero-length strings like non-present strings.
+
+Cc: armbru@redhat.com
+Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
+(cherry picked from commit 344496fae4bee9243be7f9719a60b01189c12f00)
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+
+Conflicts:
+	src/smbios.c
+---
+ src/smbios.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+---
+ src/smbios.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/smbios.c b/src/smbios.c
+index 23713a2..4e6df14 100644
+--- a/src/smbios.c
++++ b/src/smbios.c
+@@ -61,13 +61,17 @@ smbios_entry_point_init(u16 max_structure_size,
+         size = qemu_cfg_smbios_load_field(type,                         \
+                                  offsetof(struct smbios_type_##type,    \
+                                           field), end);                 \
+-        if (size > 0) {                                                 \
++        if (size == 1) {                                                \
++            /* zero-length string, skip to avoid bogus end marker */    \
++            p->field = 0;                                               \
++        } else if (size > 1) {                                          \
+             end += size;                                                \
++            p->field = ++str_index;                                     \
+         } else {                                                        \
+             memcpy(end, def, sizeof(def));                              \
+             end += sizeof(def);                                         \
++            p->field = ++str_index;                                     \
+         }                                                               \
+-        p->field = ++str_index;                                         \
+     } while (0)
+ 
+ #define load_str_field_or_skip(type, field)                             \
+@@ -75,7 +79,7 @@ smbios_entry_point_init(u16 max_structure_size,
+         size = qemu_cfg_smbios_load_field(type,                         \
+                                  offsetof(struct smbios_type_##type,    \
+                                           field), end);                 \
+-        if (size > 0) {                                                 \
++        if (size > 1) {                                                 \
+             end += size;                                                \
+             p->field = ++str_index;                                     \
+         } else {                                                        \
+-- 
+1.8.3.1
+
diff --git a/SOURCES/seabios-vgabios-Fix-cirrus-memory-clear-on-mode-switch.patch b/SOURCES/seabios-vgabios-Fix-cirrus-memory-clear-on-mode-switch.patch
new file mode 100644
index 0000000..f7addfa
--- /dev/null
+++ b/SOURCES/seabios-vgabios-Fix-cirrus-memory-clear-on-mode-switch.patch
@@ -0,0 +1,106 @@
+From 52f633e72965e711be4d92928615f63b4cf9f429 Mon Sep 17 00:00:00 2001
+From: Miki Mishael <mmishael@redhat.com>
+Date: Tue, 7 Jan 2014 16:10:44 +0100
+Subject: [PATCH] vgabios: Fix cirrus memory clear on mode switch.
+
+RH-Author: Miki Mishael <mmishael@redhat.com>
+Message-id: <1389111044-9237-1-git-send-email-mmishael@redhat.com>
+Patchwork-id: 56530
+O-Subject: [RHEL7.0 seabios PATCH] vgabios: Fix cirrus memory clear on mode switch.
+Bugzilla: 979898
+RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
+RH-Acked-by: Yan Vugenfirer <yvugenfi@redhat.com>
+RH-Acked-by: Gal Hammer <ghammer@redhat.com>
+
+From: Kevin O'Connor <kevin@koconnor.net>
+
+The cirrus_clear_vram() code wasn't actually doing anything because of
+a u8 overflow.  Fix that.
+
+Fill with 0xff when performing a legacy cirrus mode switch (WinXP has
+been observed to incorrectly render dialog boxes if the memory is
+filled to 0).  This was the behavior of the original LGPL vgabios
+code.  To support this, add mechanism (MF_LEGACY) to allow vga drivers
+to detect if the mode switch is from vesa or int10.
+
+Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
+
+BZ: https://bugzilla.redhat.com/show_bug.cgi?id=979898
+Upstream-status: b7b92935df0e309149c042d587e4764548f10608
+Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=6818682
+Signed-off-by: Miki Mishael <mmishael@redhat.com>
+Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
+---
+ vgasrc/clext.c   | 11 ++++++-----
+ vgasrc/vgabios.c |  2 +-
+ vgasrc/vgabios.h |  1 +
+ 3 files changed, 8 insertions(+), 6 deletions(-)
+
+Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
+---
+ vgasrc/clext.c   |   11 ++++++-----
+ vgasrc/vgabios.c |    2 +-
+ vgasrc/vgabios.h |    1 +
+ 3 files changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/vgasrc/clext.c b/vgasrc/clext.c
+index fc5459a..30da499 100644
+--- a/vgasrc/clext.c
++++ b/vgasrc/clext.c
+@@ -442,14 +442,14 @@ cirrus_enable_16k_granularity(void)
+ }
+ 
+ static void
+-cirrus_clear_vram(void)
++cirrus_clear_vram(u16 fill)
+ {
+     cirrus_enable_16k_granularity();
+-    u8 count = GET_GLOBAL(VBE_total_memory) / (16 * 1024);
+-    u8 i;
++    int count = GET_GLOBAL(VBE_total_memory) / (16 * 1024);
++    int i;
+     for (i=0; i<count; i++) {
+         stdvga_grdc_write(0x09, i);
+-        memset16_far(SEG_GRAPH, 0, 0, 16 * 1024);
++        memset16_far(SEG_GRAPH, 0, fill, 16 * 1024);
+     }
+     stdvga_grdc_write(0x09, 0x00);
+ }
+@@ -468,7 +468,8 @@ clext_set_mode(struct vgamode_s *vmode_g, int flags)
+     if (!(flags & MF_LINEARFB))
+         cirrus_enable_16k_granularity();
+     if (!(flags & MF_NOCLEARMEM))
+-        cirrus_clear_vram();
++        // fill with 0xff to keep win 2K happy
++        cirrus_clear_vram(flags & MF_LEGACY ? 0xffff : 0x0000);
+     return 0;
+ }
+ 
+diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
+index afaf018..0ed8874 100644
+--- a/vgasrc/vgabios.c
++++ b/vgasrc/vgabios.c
+@@ -420,7 +420,7 @@ handle_1000(struct bregs *regs)
+     else
+         regs->al = 0x30;
+ 
+-    int flags = GET_BDA(modeset_ctl) & (MF_NOPALETTE|MF_GRAYSUM);
++    int flags = MF_LEGACY | (GET_BDA(modeset_ctl) & (MF_NOPALETTE|MF_GRAYSUM));
+     if (regs->al & 0x80)
+         flags |= MF_NOCLEARMEM;
+ 
+diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h
+index ff5ec45..5adbf4b 100644
+--- a/vgasrc/vgabios.h
++++ b/vgasrc/vgabios.h
+@@ -39,6 +39,7 @@ struct saveBDAstate {
+ };
+ 
+ // Mode flags
++#define MF_LEGACY     0x0001
+ #define MF_GRAYSUM    0x0002
+ #define MF_NOPALETTE  0x0008
+ #define MF_CUSTOMCRTC 0x0800
+-- 
+1.7.1
+
diff --git a/SPECS/seabios.spec b/SPECS/seabios.spec
index 4e6fdce..b576da9 100644
--- a/SPECS/seabios.spec
+++ b/SPECS/seabios.spec
@@ -1,6 +1,6 @@
 Name:           seabios
 Version:        1.7.2.2
-Release:        4%{?dist}
+Release:        12%{?dist}
 Summary:        Open-source legacy BIOS implementation
 
 Group:          Applications/Emulators
@@ -20,6 +20,7 @@ Source12:       config.vga.qxl
 Source13:       config.vga.stdvga
 Source14:       config.vga.vmware
 Source15:       config.base
+Source16:       config.base-256k
 
 # Add pvpanic device driver (rhbz 967777)
 Patch1: Add-pvpanic-device-driver.patch
@@ -49,13 +50,36 @@ Patch12: seabios-usb-add-xhci-support.patch
 Patch13: seabios-xhci-adaptions-for-old-rhel7-seabios-codebase.patch
 # For bz#1016974 - [HP 7.0 FEAT]: Increase KVM guest supported memory to 4TiB
 Patch14: seabios-allow-1TB-of-RAM.patch
+# For bz#1038604 - make seabios 256k for rhel7 machine types
+Patch15: seabios-build-explicitly-set-ROM-size.patch
+# For bz#1034877 - export acpi tables to guests (seabios)
+Patch16: seabios-biostables-support-looking-up-RSDP.patch
+# For bz#1034877 - export acpi tables to guests (seabios)
+Patch17: seabios-romfile_loader-utility-to-patch-in-memory-ROM-files.patch
+# For bz#1034877 - export acpi tables to guests (seabios)
+Patch18: seabios-acpi-load-and-link-tables-through-romfile-loader.patch
+# For bz#979898 - [qemu-kvm]The win2k3-32 guest display is abnormal when using -vga cirrus
+Patch19: seabios-vgabios-Fix-cirrus-memory-clear-on-mode-switch.patch
+# For bz#1013418 - qemu-kvm with a virtio-scsi controler without devices attached quits after stop/cont in HMP/QMP
+Patch20: seabios-init_virtio_scsi-reset-the-HBA-before-freeing-its-vi.patch
+# For bz#1052837 - The wrong DMI structures could not be decoded while booting vm with -smbios params
+Patch21: seabios-smbios-catch-zero-length-strings.patch
+# For bz#1049860 - Guest agent command hang there after restore the guest from the save file
+Patch22: seabios-resume-restore-piix-pm-config-registers-after-resume.patch
+# For bz#1055832 - can not see seabios GUI when boot with 155 virtio-blk-pci disks via pci-bridge
+Patch23: seabios-pci-align-64bit-pci-regions-to-1G.patch
+# For bz#1055832 - can not see seabios GUI when boot with 155 virtio-blk-pci disks via pci-bridge
+Patch24: seabios-pci-log-pci-windows.patch
+# For bz#1055832 - can not see seabios GUI when boot with 155 virtio-blk-pci disks via pci-bridge
+Patch25: seabios-pci-improve-io-address-space-allocation.patch
+# For bz#1050775 - [whql]KVM internal error. Suberror: 1 when win8.1-32 guest run HCK jobs
+Patch26: seabios-Workaround-for-a-win8.1-32-S4-resume-bug.patch
 
 BuildRequires: python iasl
 ExclusiveArch: x86_64
 
 Requires: %{name}-bin = %{version}-%{release}
 Requires: seavgabios-bin = %{version}-%{release}
-Buildarch: x86_64
 
 # Seabios is noarch, but required on architectures which cannot build it.
 # Disable debuginfo because it is of no use to us.
@@ -78,8 +102,6 @@ that a typical x86 proprietary BIOS implements.
 
 %package bin
 Summary: Seabios for x86
-Buildarch: noarch
-
 
 %description bin
 SeaBIOS is an open-source legacy BIOS implementation which can be used as
@@ -89,10 +111,8 @@ that a typical x86 proprietary BIOS implements.
 
 %package -n seavgabios-bin
 Summary: Seavgabios for x86
-Buildarch: noarch
-
-Obsoletes: vgabios < vgabios-0.6c-10
-Provides: vgabios = vgabios-0.6c-10
+Obsoletes: vgabios < 0.6c-10
+Provides: vgabios = 0.6c-10
 
 
 %description -n seavgabios-bin
@@ -115,22 +135,40 @@ SeaVGABIOS is an open-source VGABIOS implementation.
 %patch12 -p1
 %patch13 -p1
 %patch14 -p1
+%patch15 -p1
+%patch16 -p1
+%patch17 -p1
+%patch18 -p1
+%patch19 -p1
+%patch20 -p1
+%patch21 -p1
+%patch22 -p1
+%patch23 -p1
+%patch24 -p1
+%patch25 -p1
+%patch26 -p1
 
 # Store version to be used
 echo "%{name}-%{version}-%release" > .version
 
 %build
-cp %{SOURCE15} .config
-make oldnoconfig V=1
-sed -i 's,CONFIG_DEBUG_LEVEL=.*,CONFIG_DEBUG_LEVEL=%{debug_level},g' .config
-
 export CFLAGS="$RPM_OPT_FLAGS"
 mkdir binaries
 
-# seabios
+# seabios 128k
+cp %{SOURCE15} .config
+make oldnoconfig V=1
+sed -i 's,CONFIG_DEBUG_LEVEL=.*,CONFIG_DEBUG_LEVEL=%{debug_level},g' .config
 make
 cp out/bios.bin binaries
 
+# seabios 256k
+cp %{SOURCE16} .config
+make oldnoconfig V=1
+sed -i 's,CONFIG_DEBUG_LEVEL=.*,CONFIG_DEBUG_LEVEL=%{debug_level},g' .config
+make
+cp out/bios.bin binaries/bios-256k.bin
+
 # seavgabios
 for config in %{SOURCE10} %{SOURCE11} %{SOURCE12} %{SOURCE13} %{SOURCE14}; do
 	name=${config#*config.vga.}
@@ -146,7 +184,7 @@ done
 %install
 mkdir -p $RPM_BUILD_ROOT%{_datadir}/seabios
 mkdir -p $RPM_BUILD_ROOT%{_datadir}/seavgabios
-install -m 0644 binaries/bios.bin $RPM_BUILD_ROOT%{_datadir}/seabios
+install -m 0644 binaries/bios*.bin $RPM_BUILD_ROOT%{_datadir}/seabios
 install -m 0644 binaries/vgabios*.bin $RPM_BUILD_ROOT%{_datadir}/seavgabios
 
 
@@ -156,7 +194,7 @@ install -m 0644 binaries/vgabios*.bin $RPM_BUILD_ROOT%{_datadir}/seavgabios
 
 %files bin
 %dir %{_datadir}/seabios/
-%{_datadir}/seabios/bios.bin
+%{_datadir}/seabios/bios*.bin
 
 %files -n seavgabios-bin
 %dir %{_datadir}/seavgabios/
@@ -164,6 +202,52 @@ install -m 0644 binaries/vgabios*.bin $RPM_BUILD_ROOT%{_datadir}/seavgabios
 
 
 %changelog
+* Tue Mar 11 2014 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-12.el7
+- seabios-Workaround-for-a-win8.1-32-S4-resume-bug.patch [bz#1050775]
+- Resolves: bz#1050775
+  ([whql]KVM internal error. Suberror: 1 when win8.1-32 guest run HCK jobs)
+
+* Wed Feb 05 2014 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-11.el7
+- seabios-init_virtio_scsi-reset-the-HBA-before-freeing-its-vi.patch [bz#1013418]
+- seabios-smbios-catch-zero-length-strings.patch [bz#1052837]
+- seabios-resume-restore-piix-pm-config-registers-after-resume.patch [bz#1049860]
+- seabios-pci-align-64bit-pci-regions-to-1G.patch [bz#1055832]
+- seabios-pci-log-pci-windows.patch [bz#1055832]
+- seabios-pci-improve-io-address-space-allocation.patch [bz#1055832]
+- Resolves: bz#1013418
+  (qemu-kvm with a virtio-scsi controler without devices attached quits after stop/cont in HMP/QMP)
+- Resolves: bz#1049860
+  (Guest agent command hang there after restore the guest from the save file)
+- Resolves: bz#1052837
+  (The wrong DMI structures could not be decoded while booting vm with -smbios params)
+- Resolves: bz#1055832
+  (can not see seabios GUI when boot with 155 virtio-blk-pci disks via pci-bridge)
+
+* Mon Jan 13 2014 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-10.el7
+- Fixed seavgabios-bin obsoletes/provides [bz#1035452]
+- Resolves: bz#1035452
+  ( seavgabios-bin has bad obsoletes/provides for "vgabios")
+
+* Mon Jan 13 2014 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-8.el7
+- seabios-vgabios-Fix-cirrus-memory-clear-on-mode-switch.patch [bz#979898]
+- Resolves: bz#979898
+  ([qemu-kvm]The win2k3-32 guest display is abnormal when using -vga cirrus)
+
+* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 1.7.2.2-7
+- Mass rebuild 2013-12-27
+
+* Tue Dec 17 2013 Michal Novotny <minovotn@redhat.com> - seabios-1.7.2.2-6.el7
+- seabios-biostables-support-looking-up-RSDP.patch [bz#1034877]
+- seabios-romfile_loader-utility-to-patch-in-memory-ROM-files.patch [bz#1034877]
+- seabios-acpi-load-and-link-tables-through-romfile-loader.patch [bz#1034877]
+- Resolves: bz#1034877
+  (export acpi tables to guests (seabios))
+
+* Tue Dec 10 2013 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-5.el7
+- seabios-build-explicitly-set-ROM-size.patch [bz#1038604]
+- Resolves: bz#1038604
+  (make seabios 256k for rhel7 machine types)
+
 * Tue Nov 05 2013 Miroslav Rezanina <mrezanin@redhat.com> - 1.7.2.2-4.el7
 - seabios-Introduce-and-convert-pmm-code-to-use-standard-list-.patch [bz#947051]
 - seabios-Fix-error-in-hlist_for_each_entry_safe-macro.patch [bz#947051]