|
|
989152 |
From 18b770a509ef5d3404f1ddfae74c019d7029445e Mon Sep 17 00:00:00 2001
|
|
|
989152 |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
989152 |
Date: Wed, 12 Apr 2017 06:36:21 +0200
|
|
|
989152 |
Subject: [PATCH 2/2] resume: Don't attempt to use generic reboot mechanisms on
|
|
|
989152 |
QEMU
|
|
|
989152 |
|
|
|
989152 |
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
989152 |
Message-id: <20170412063621.25904-3-kraxel@redhat.com>
|
|
|
989152 |
Patchwork-id: 74683
|
|
|
989152 |
O-Subject: [RHEL-7.3.z seabios PATCH 2/2] resume: Don't attempt to use generic reboot mechanisms on QEMU
|
|
|
989152 |
Bugzilla: 1440706
|
|
|
989152 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
989152 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
989152 |
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
989152 |
|
|
|
989152 |
From: Kevin O'Connor <kevin@koconnor.net>
|
|
|
989152 |
|
|
|
989152 |
On QEMU it's necessary to manually reset the BIOS memory region
|
|
|
989152 |
between 0xc0000-0x100000 on a reboot. After this manual memory reset
|
|
|
989152 |
is completed, it's not valid to use the generic reset mechanisms.
|
|
|
989152 |
Rename qemu_prep_reset() to qemu_reboot() and change the function to
|
|
|
989152 |
immediately reboot after the code memcpy.
|
|
|
989152 |
|
|
|
989152 |
This fixes a bug that could cause code corruption on reboots - calling
|
|
|
989152 |
the udelay() function (as invoked by i8042_reboot and/or pci_reboot)
|
|
|
989152 |
was not valid after the BIOS was memcpy'd.
|
|
|
989152 |
|
|
|
989152 |
RHEL-7.3.z note: no need to move PORT_PCI_REBOOT around, we don't
|
|
|
989152 |
have upstream 4d8510cdcca0 ("pci: Split low-level pci code from
|
|
|
989152 |
higher-level 'struct pci_device' code", 2016-02-03).
|
|
|
989152 |
|
|
|
989152 |
Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
989152 |
Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
989152 |
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
|
|
|
989152 |
(cherry picked from commit c68aff57ce317d9f2d69d20eba893a10d964f316)
|
|
|
989152 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
989152 |
---
|
|
|
989152 |
src/fw/shadow.c | 14 +++++++++++++-
|
|
|
989152 |
src/resume.c | 4 ++--
|
|
|
989152 |
src/util.h | 2 +-
|
|
|
989152 |
3 files changed, 16 insertions(+), 4 deletions(-)
|
|
|
989152 |
|
|
|
989152 |
diff --git a/src/fw/shadow.c b/src/fw/shadow.c
|
|
|
989152 |
index 4486884..e91202a 100644
|
|
|
989152 |
--- a/src/fw/shadow.c
|
|
|
989152 |
+++ b/src/fw/shadow.c
|
|
|
989152 |
@@ -157,7 +157,7 @@ make_bios_readonly(void)
|
|
|
989152 |
}
|
|
|
989152 |
|
|
|
989152 |
void
|
|
|
989152 |
-qemu_prep_reset(void)
|
|
|
989152 |
+qemu_reboot(void)
|
|
|
989152 |
{
|
|
|
989152 |
if (!CONFIG_QEMU || runningOnXen())
|
|
|
989152 |
return;
|
|
|
989152 |
@@ -177,4 +177,16 @@ qemu_prep_reset(void)
|
|
|
989152 |
memcpy(hrp + 4, hrp + 4 + BIOS_SRC_OFFSET, cend - (hrp + 4));
|
|
|
989152 |
barrier();
|
|
|
989152 |
HaveRunPost = 0;
|
|
|
989152 |
+ barrier();
|
|
|
989152 |
+
|
|
|
989152 |
+ // Request a QEMU system reset. Do the reset in this function as
|
|
|
989152 |
+ // the BIOS code was overwritten above and not all BIOS
|
|
|
989152 |
+ // functionality may be available.
|
|
|
989152 |
+
|
|
|
989152 |
+ // Attempt PCI style reset
|
|
|
989152 |
+ outb(0x02, PORT_PCI_REBOOT);
|
|
|
989152 |
+ outb(0x06, PORT_PCI_REBOOT);
|
|
|
989152 |
+
|
|
|
989152 |
+ // Next try triple faulting the CPU to force a reset
|
|
|
989152 |
+ asm volatile("int3");
|
|
|
989152 |
}
|
|
|
989152 |
diff --git a/src/resume.c b/src/resume.c
|
|
|
989152 |
index afeadcf..9f264fb 100644
|
|
|
989152 |
--- a/src/resume.c
|
|
|
989152 |
+++ b/src/resume.c
|
|
|
989152 |
@@ -120,8 +120,8 @@ tryReboot(void)
|
|
|
989152 |
{
|
|
|
989152 |
dprintf(1, "Attempting a hard reboot\n");
|
|
|
989152 |
|
|
|
989152 |
- // Setup for reset on qemu.
|
|
|
989152 |
- qemu_prep_reset();
|
|
|
989152 |
+ // Use a QEMU specific reboot on QEMU
|
|
|
989152 |
+ qemu_reboot();
|
|
|
989152 |
|
|
|
989152 |
// Reboot using ACPI RESET_REG
|
|
|
989152 |
acpi_reboot();
|
|
|
989152 |
diff --git a/src/util.h b/src/util.h
|
|
|
989152 |
index cba3359..b6b7dd3 100644
|
|
|
989152 |
--- a/src/util.h
|
|
|
989152 |
+++ b/src/util.h
|
|
|
989152 |
@@ -119,7 +119,7 @@ void pirtable_setup(void);
|
|
|
989152 |
// fw/shadow.c
|
|
|
989152 |
void make_bios_writable(void);
|
|
|
989152 |
void make_bios_readonly(void);
|
|
|
989152 |
-void qemu_prep_reset(void);
|
|
|
989152 |
+void qemu_reboot(void);
|
|
|
989152 |
|
|
|
989152 |
// fw/smbios.c
|
|
|
989152 |
void smbios_legacy_setup(void);
|
|
|
989152 |
--
|
|
|
989152 |
1.8.3.1
|
|
|
989152 |
|