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

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