thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-pc-bios-s390x-Clear-out-leftover-S390EP-string.patch

c687bc
From c6f62870f27ece45e944d1818f6aa04b3e024959 Mon Sep 17 00:00:00 2001
c687bc
From: Thomas Huth <thuth@redhat.com>
c687bc
Date: Thu, 10 Dec 2020 08:32:41 -0500
c687bc
Subject: [PATCH 5/5] pc-bios: s390x: Clear out leftover S390EP string
c687bc
c687bc
RH-Author: Thomas Huth <thuth@redhat.com>
c687bc
Message-id: <20201210083241.173509-5-thuth@redhat.com>
c687bc
Patchwork-id: 100369
c687bc
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 4/4] pc-bios: s390x: Clear out leftover S390EP string
c687bc
Bugzilla: 1903135
c687bc
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
c687bc
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
c687bc
RH-Acked-by: David Hildenbrand <david@redhat.com>
c687bc
c687bc
From: Eric Farman <farman@linux.ibm.com>
c687bc
c687bc
A Linux binary will have the string "S390EP" at address 0x10008,
c687bc
which is important in getting the guest up off the ground. In the
c687bc
case of a reboot (specifically chreipl going to a new device),
c687bc
we should defer to the PSW at address zero for the new config,
c687bc
which will re-write "S390EP" from the new image.
c687bc
c687bc
Let's clear it out at this point so that a reipl to, say, a DASD
c687bc
passthrough device drives the IPL path from scratch without disrupting
c687bc
disrupting the order of operations for other boots.
c687bc
c687bc
Rather than hardcoding the address of this magic (again), let's
c687bc
define it somewhere so that the two users are visibly related.
c687bc
c687bc
Signed-off-by: Eric Farman <farman@linux.ibm.com>
c687bc
Message-Id: <20201120160117.59366-3-farman@linux.ibm.com>
c687bc
Signed-off-by: Thomas Huth <thuth@redhat.com>
c687bc
(cherry picked from commit 3d6519968bb10260fc724c491fb4275f7c0b78ac)
c687bc
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
c687bc
---
c687bc
 pc-bios/s390-ccw/jump2ipl.c  | 2 +-
c687bc
 pc-bios/s390-ccw/main.c      | 6 ++++++
c687bc
 pc-bios/s390-ccw/s390-arch.h | 3 +++
c687bc
 3 files changed, 10 insertions(+), 1 deletion(-)
c687bc
c687bc
diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
c687bc
index 767012bf0c9..6c6823b5db8 100644
c687bc
--- a/pc-bios/s390-ccw/jump2ipl.c
c687bc
+++ b/pc-bios/s390-ccw/jump2ipl.c
c687bc
@@ -78,7 +78,7 @@ void jump_to_low_kernel(void)
c687bc
      * kernel start address (when jumping to the PSW-at-zero address instead,
c687bc
      * the kernel startup code fails when we booted from a network device).
c687bc
      */
c687bc
-    if (!memcmp((char *)0x10008, "S390EP", 6)) {
c687bc
+    if (!memcmp((char *)S390EP, "S390EP", 6)) {
c687bc
         jump_to_IPL_code(KERN_IMAGE_START);
c687bc
     }
c687bc
 
c687bc
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
c687bc
index e3a1a3053d0..c04b910082b 100644
c687bc
--- a/pc-bios/s390-ccw/main.c
c687bc
+++ b/pc-bios/s390-ccw/main.c
c687bc
@@ -185,6 +185,12 @@ static void boot_setup(void)
c687bc
     memcpy(lpmsg + 10, loadparm_str, 8);
c687bc
     sclp_print(lpmsg);
c687bc
 
c687bc
+    /*
c687bc
+     * Clear out any potential S390EP magic (see jump_to_low_kernel()),
c687bc
+     * so we don't taint our decision-making process during a reboot.
c687bc
+     */
c687bc
+    memset((char *)S390EP, 0, 6);
c687bc
+
c687bc
     have_iplb = store_iplb(&iplb);
c687bc
 }
c687bc
 
c687bc
diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
c687bc
index 6da44d4436c..a741488aaa1 100644
c687bc
--- a/pc-bios/s390-ccw/s390-arch.h
c687bc
+++ b/pc-bios/s390-ccw/s390-arch.h
c687bc
@@ -95,6 +95,9 @@ typedef struct LowCore {
c687bc
 
c687bc
 extern LowCore *lowcore;
c687bc
 
c687bc
+/* Location of "S390EP" in a Linux binary (see arch/s390/boot/head.S) */
c687bc
+#define S390EP 0x10008
c687bc
+
c687bc
 static inline void set_prefix(uint32_t address)
c687bc
 {
c687bc
     asm volatile("spx %0" : : "m" (address) : "memory");
c687bc
-- 
c687bc
2.27.0
c687bc