yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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