diff --git a/SOURCES/seabios-resume-Don-t-attempt-to-use-generic-reboot-mechanism.patch b/SOURCES/seabios-resume-Don-t-attempt-to-use-generic-reboot-mechanism.patch new file mode 100644 index 0000000..f5b86d3 --- /dev/null +++ b/SOURCES/seabios-resume-Don-t-attempt-to-use-generic-reboot-mechanism.patch @@ -0,0 +1,103 @@ +From 18b770a509ef5d3404f1ddfae74c019d7029445e Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Wed, 12 Apr 2017 06:36:21 +0200 +Subject: [PATCH 2/2] resume: Don't attempt to use generic reboot mechanisms on + QEMU + +RH-Author: Gerd Hoffmann +Message-id: <20170412063621.25904-3-kraxel@redhat.com> +Patchwork-id: 74683 +O-Subject: [RHEL-7.3.z seabios PATCH 2/2] resume: Don't attempt to use generic reboot mechanisms on QEMU +Bugzilla: 1440706 +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Paolo Bonzini +RH-Acked-by: Dr. David Alan Gilbert + +From: Kevin O'Connor + +On QEMU it's necessary to manually reset the BIOS memory region +between 0xc0000-0x100000 on a reboot. After this manual memory reset +is completed, it's not valid to use the generic reset mechanisms. +Rename qemu_prep_reset() to qemu_reboot() and change the function to +immediately reboot after the code memcpy. + +This fixes a bug that could cause code corruption on reboots - calling +the udelay() function (as invoked by i8042_reboot and/or pci_reboot) +was not valid after the BIOS was memcpy'd. + +RHEL-7.3.z note: no need to move PORT_PCI_REBOOT around, we don't +have upstream 4d8510cdcca0 ("pci: Split low-level pci code from +higher-level 'struct pci_device' code", 2016-02-03). + +Reported-by: "Dr. David Alan Gilbert" +Tested-by: Dr. David Alan Gilbert +Signed-off-by: Kevin O'Connor +(cherry picked from commit c68aff57ce317d9f2d69d20eba893a10d964f316) +Signed-off-by: Miroslav Rezanina +--- + src/fw/shadow.c | 14 +++++++++++++- + src/resume.c | 4 ++-- + src/util.h | 2 +- + 3 files changed, 16 insertions(+), 4 deletions(-) + +diff --git a/src/fw/shadow.c b/src/fw/shadow.c +index 4486884..e91202a 100644 +--- a/src/fw/shadow.c ++++ b/src/fw/shadow.c +@@ -157,7 +157,7 @@ make_bios_readonly(void) + } + + void +-qemu_prep_reset(void) ++qemu_reboot(void) + { + if (!CONFIG_QEMU || runningOnXen()) + return; +@@ -177,4 +177,16 @@ qemu_prep_reset(void) + memcpy(hrp + 4, hrp + 4 + BIOS_SRC_OFFSET, cend - (hrp + 4)); + barrier(); + HaveRunPost = 0; ++ barrier(); ++ ++ // Request a QEMU system reset. Do the reset in this function as ++ // the BIOS code was overwritten above and not all BIOS ++ // functionality may be available. ++ ++ // Attempt PCI style reset ++ outb(0x02, PORT_PCI_REBOOT); ++ outb(0x06, PORT_PCI_REBOOT); ++ ++ // Next try triple faulting the CPU to force a reset ++ asm volatile("int3"); + } +diff --git a/src/resume.c b/src/resume.c +index afeadcf..9f264fb 100644 +--- a/src/resume.c ++++ b/src/resume.c +@@ -120,8 +120,8 @@ tryReboot(void) + { + dprintf(1, "Attempting a hard reboot\n"); + +- // Setup for reset on qemu. +- qemu_prep_reset(); ++ // Use a QEMU specific reboot on QEMU ++ qemu_reboot(); + + // Reboot using ACPI RESET_REG + acpi_reboot(); +diff --git a/src/util.h b/src/util.h +index cba3359..b6b7dd3 100644 +--- a/src/util.h ++++ b/src/util.h +@@ -119,7 +119,7 @@ void pirtable_setup(void); + // fw/shadow.c + void make_bios_writable(void); + void make_bios_readonly(void); +-void qemu_prep_reset(void); ++void qemu_reboot(void); + + // fw/smbios.c + void smbios_legacy_setup(void); +-- +1.8.3.1 + diff --git a/SOURCES/seabios-resume-Make-KVM-soft-reboot-loop-detection-more-flex.patch b/SOURCES/seabios-resume-Make-KVM-soft-reboot-loop-detection-more-flex.patch new file mode 100644 index 0000000..14d9d09 --- /dev/null +++ b/SOURCES/seabios-resume-Make-KVM-soft-reboot-loop-detection-more-flex.patch @@ -0,0 +1,81 @@ +From 51e8e987d3156c4a16428f922b1c0e5984451c39 Mon Sep 17 00:00:00 2001 +From: Gerd Hoffmann +Date: Wed, 12 Apr 2017 06:36:20 +0200 +Subject: [PATCH 1/2] resume: Make KVM soft reboot loop detection more flexible + +RH-Author: Gerd Hoffmann +Message-id: <20170412063621.25904-2-kraxel@redhat.com> +Patchwork-id: 74685 +O-Subject: [RHEL-7.3.z seabios PATCH 1/2] resume: Make KVM soft reboot loop detection more flexible +Bugzilla: 1440706 +RH-Acked-by: Laszlo Ersek +RH-Acked-by: Paolo Bonzini +RH-Acked-by: Dr. David Alan Gilbert + +From: Kevin O'Connor + +Move the check for soft reboot loops from resume.c to shadow.c and +directly check for the case where the copy of the BIOS in flash +appears to be a memory alias instead. This prevents a hang if an +external reboot request occurs during the BIOS memcpy. + +Signed-off-by: Kevin O'Connor +(cherry picked from commit b837e68d5a6c1a5945513f1995875445a1594c8a) +Signed-off-by: Miroslav Rezanina +--- + src/fw/shadow.c | 15 +++++++++++++-- + src/resume.c | 9 --------- + 2 files changed, 13 insertions(+), 11 deletions(-) + +diff --git a/src/fw/shadow.c b/src/fw/shadow.c +index ee87d36..4486884 100644 +--- a/src/fw/shadow.c ++++ b/src/fw/shadow.c +@@ -163,7 +163,18 @@ qemu_prep_reset(void) + return; + // QEMU doesn't map 0xc0000-0xfffff back to the original rom on a + // reset, so do that manually before invoking a hard reset. ++ void *cstart = VSYMBOL(code32flat_start), *cend = VSYMBOL(code32flat_end); ++ void *hrp = &HaveRunPost; ++ if (readl(hrp + BIOS_SRC_OFFSET)) { ++ // Some old versions of KVM don't store a pristine copy of the ++ // BIOS in high memory. Try to shutdown the machine instead. ++ dprintf(1, "Unable to hard-reboot machine - attempting shutdown.\n"); ++ apm_shutdown(); ++ } ++ // Copy the BIOS making sure to only reset HaveRunPost at end + make_bios_writable(); +- memcpy(VSYMBOL(code32flat_start), VSYMBOL(code32flat_start) + BIOS_SRC_OFFSET +- , SYMBOL(code32flat_end) - SYMBOL(code32flat_start)); ++ memcpy(cstart, cstart + BIOS_SRC_OFFSET, hrp - cstart); ++ memcpy(hrp + 4, hrp + 4 + BIOS_SRC_OFFSET, cend - (hrp + 4)); ++ barrier(); ++ HaveRunPost = 0; + } +diff --git a/src/resume.c b/src/resume.c +index a5465d8..afeadcf 100644 +--- a/src/resume.c ++++ b/src/resume.c +@@ -114,19 +114,10 @@ s3_resume(void) + farcall16big(&br); + } + +-u8 HaveAttemptedReboot VARLOW; +- + // Attempt to invoke a hard-reboot. + static void + tryReboot(void) + { +- if (HaveAttemptedReboot) { +- // Hard reboot has failed - try to shutdown machine. +- dprintf(1, "Unable to hard-reboot machine - attempting shutdown.\n"); +- apm_shutdown(); +- } +- HaveAttemptedReboot = 1; +- + dprintf(1, "Attempting a hard reboot\n"); + + // Setup for reset on qemu. +-- +1.8.3.1 + diff --git a/SPECS/seabios.spec b/SPECS/seabios.spec index 8dff892..436e821 100644 --- a/SPECS/seabios.spec +++ b/SPECS/seabios.spec @@ -1,6 +1,6 @@ Name: seabios Version: 1.9.1 -Release: 5%{?dist}.2 +Release: 5%{?dist}.3 Summary: Open-source legacy BIOS implementation Group: Applications/Emulators @@ -39,6 +39,10 @@ Patch10: seabios-acpi_extract-Make-the-generated-.hex-files-more-huma.patch Patch11: seabios-acpi_extract-Don-t-generate-unused-and-empty-q35-acp.patch # For bz#1400102 - decouple the SeaBIOS build from iasl Patch12: seabios-acpi-Don-t-build-SSDT-files-on-every-build-store-the.patch +# For bz#1440706 - reboot hangs on rhel6 machine types (~1/20 times) +Patch13: seabios-resume-Make-KVM-soft-reboot-loop-detection-more-flex.patch +# For bz#1440706 - reboot hangs on rhel6 machine types (~1/20 times) +Patch14: seabios-resume-Don-t-attempt-to-use-generic-reboot-mechanism.patch BuildRequires: python iasl ExclusiveArch: x86_64 %{power64} @@ -100,6 +104,8 @@ SeaVGABIOS is an open-source VGABIOS implementation. %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 +%patch14 -p1 # Store version to be used @@ -154,6 +160,12 @@ install -m 0644 binaries/vgabios*.bin $RPM_BUILD_ROOT%{_datadir}/seavgabios %endif %changelog +* Thu May 11 2017 Miroslav Rezanina - 1.9.1-5.el7_3.3 +- seabios-resume-Make-KVM-soft-reboot-loop-detection-more-flex.patch [bz#1440706] +- seabios-resume-Don-t-attempt-to-use-generic-reboot-mechanism.patch [bz#1440706] +- Resolves: bz#1440706 + (reboot hangs on rhel6 machine types (~1/20 times)) + * Fri Feb 10 2017 Miroslav Rezanina - 1.9.1-5.el7_3.2 - seabios-acpi_extract-Move-main-code-to-new-function-main.patch [bz#1400102] - seabios-acpi_extract-Make-the-generated-.hex-files-more-huma.patch [bz#1400102]