thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
902636
From 8350ad9c0f54519a06ec396c2997330615f4b470 Mon Sep 17 00:00:00 2001
902636
From: Thomas Huth <thuth@redhat.com>
902636
Date: Fri, 29 May 2020 05:53:58 -0400
902636
Subject: [PATCH 16/42] pc-bios: s390x: Save iplb location in lowcore
902636
902636
RH-Author: Thomas Huth <thuth@redhat.com>
902636
Message-id: <20200529055420.16855-17-thuth@redhat.com>
902636
Patchwork-id: 97027
902636
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH v2 16/38] pc-bios: s390x: Save iplb location in lowcore
902636
Bugzilla: 1828317
902636
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
902636
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
902636
RH-Acked-by: David Hildenbrand <david@redhat.com>
902636
902636
From: Janosch Frank <frankja@linux.ibm.com>
902636
902636
The POP states that for a list directed IPL the IPLB is stored into
902636
memory by the machine loader and its address is stored at offset 0x14
902636
of the lowcore.
902636
902636
ZIPL currently uses the address in offset 0x14 to access the IPLB and
902636
acquire flags about secure boot. If the IPLB address points into
902636
memory which has an unsupported mix of flags set, ZIPL will panic
902636
instead of booting the OS.
902636
902636
As the lowcore can have quite a high entropy for a guest that did drop
902636
out of protected mode (i.e. rebooted) we encountered the ZIPL panic
902636
quite often.
902636
902636
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
902636
Tested-by: Marc Hartmayer <mhartmay@linux.ibm.com>
902636
Message-Id: <20200304114231.23493-19-frankja@linux.ibm.com>
902636
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
Reviewed-by: David Hildenbrand <david@redhat.com>
902636
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
902636
(cherry picked from commit 9bfc04f9ef6802fff0fc77130ff345a541783363)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 pc-bios/s390-ccw/jump2ipl.c  |  1 +
902636
 pc-bios/s390-ccw/main.c      |  8 +++++++-
902636
 pc-bios/s390-ccw/netmain.c   |  1 +
902636
 pc-bios/s390-ccw/s390-arch.h | 10 ++++++++--
902636
 pc-bios/s390-ccw/s390-ccw.h  |  1 +
902636
 5 files changed, 18 insertions(+), 3 deletions(-)
902636
902636
diff --git a/pc-bios/s390-ccw/jump2ipl.c b/pc-bios/s390-ccw/jump2ipl.c
902636
index da13c43cc0..4eba2510b0 100644
902636
--- a/pc-bios/s390-ccw/jump2ipl.c
902636
+++ b/pc-bios/s390-ccw/jump2ipl.c
902636
@@ -35,6 +35,7 @@ void jump_to_IPL_code(uint64_t address)
902636
 {
902636
     /* store the subsystem information _after_ the bootmap was loaded */
902636
     write_subsystem_identification();
902636
+    write_iplb_location();
902636
 
902636
     /* prevent unknown IPL types in the guest */
902636
     if (iplb.pbt == S390_IPL_TYPE_QEMU_SCSI) {
902636
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
902636
index a21b386280..4e65b411e1 100644
902636
--- a/pc-bios/s390-ccw/main.c
902636
+++ b/pc-bios/s390-ccw/main.c
902636
@@ -9,6 +9,7 @@
902636
  */
902636
 
902636
 #include "libc.h"
902636
+#include "helper.h"
902636
 #include "s390-arch.h"
902636
 #include "s390-ccw.h"
902636
 #include "cio.h"
902636
@@ -22,7 +23,7 @@ QemuIplParameters qipl;
902636
 IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
902636
 static bool have_iplb;
902636
 static uint16_t cutype;
902636
-LowCore const *lowcore; /* Yes, this *is* a pointer to address 0 */
902636
+LowCore *lowcore; /* Yes, this *is* a pointer to address 0 */
902636
 
902636
 #define LOADPARM_PROMPT "PROMPT  "
902636
 #define LOADPARM_EMPTY  "        "
902636
@@ -42,6 +43,11 @@ void write_subsystem_identification(void)
902636
     *zeroes = 0;
902636
 }
902636
 
902636
+void write_iplb_location(void)
902636
+{
902636
+    lowcore->ptr_iplb = ptr2u32(&iplb);
902636
+}
902636
+
902636
 void panic(const char *string)
902636
 {
902636
     sclp_print(string);
902636
diff --git a/pc-bios/s390-ccw/netmain.c b/pc-bios/s390-ccw/netmain.c
902636
index f2dcc01e27..309ffa30d9 100644
902636
--- a/pc-bios/s390-ccw/netmain.c
902636
+++ b/pc-bios/s390-ccw/netmain.c
902636
@@ -40,6 +40,7 @@
902636
 #define DEFAULT_TFTP_RETRIES 20
902636
 
902636
 extern char _start[];
902636
+void write_iplb_location(void) {}
902636
 
902636
 #define KERNEL_ADDR             ((void *)0L)
902636
 #define KERNEL_MAX_SIZE         ((long)_start)
902636
diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
902636
index 504fc7c2f0..5f36361c02 100644
902636
--- a/pc-bios/s390-ccw/s390-arch.h
902636
+++ b/pc-bios/s390-ccw/s390-arch.h
902636
@@ -36,7 +36,13 @@ typedef struct LowCore {
902636
     /* prefix area: defined by architecture */
902636
     PSWLegacy       ipl_psw;                  /* 0x000 */
902636
     uint32_t        ccw1[2];                  /* 0x008 */
902636
-    uint32_t        ccw2[2];                  /* 0x010 */
902636
+    union {
902636
+        uint32_t        ccw2[2];                  /* 0x010 */
902636
+        struct {
902636
+            uint32_t reserved10;
902636
+            uint32_t ptr_iplb;
902636
+        };
902636
+    };
902636
     uint8_t         pad1[0x80 - 0x18];        /* 0x018 */
902636
     uint32_t        ext_params;               /* 0x080 */
902636
     uint16_t        cpu_addr;                 /* 0x084 */
902636
@@ -85,7 +91,7 @@ typedef struct LowCore {
902636
     PSW             io_new_psw;               /* 0x1f0 */
902636
 } __attribute__((packed, aligned(8192))) LowCore;
902636
 
902636
-extern LowCore const *lowcore;
902636
+extern LowCore *lowcore;
902636
 
902636
 static inline void set_prefix(uint32_t address)
902636
 {
902636
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
902636
index 11bce7d73c..21f27e7990 100644
902636
--- a/pc-bios/s390-ccw/s390-ccw.h
902636
+++ b/pc-bios/s390-ccw/s390-ccw.h
902636
@@ -57,6 +57,7 @@ void consume_io_int(void);
902636
 /* main.c */
902636
 void panic(const char *string);
902636
 void write_subsystem_identification(void);
902636
+void write_iplb_location(void);
902636
 extern char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
902636
 unsigned int get_loadparm_index(void);
902636
 
902636
-- 
902636
2.27.0
902636