cryptospore / rpms / qemu-kvm

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