Pablo Greco e6a3ae
From 4a1515fe8a1343c66ca3a889897568f13eedd7f3 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Date: Wed, 8 May 2019 13:37:49 +0100
Pablo Greco e6a3ae
Subject: [PATCH] s390-bios: Skip bootmap signature entries
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190508133749.11555-2-thuth@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 87209
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/1] s390-bios: Skip bootmap signature entries
Pablo Greco e6a3ae
Bugzilla: 1683275
Pablo Greco e6a3ae
RH-Acked-by: David Hildenbrand <david@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: "Jason J. Herne" <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Newer versions of zipl have the ability to write signature entries to the boot
Pablo Greco e6a3ae
script for secure boot. We don't yet support secure boot, but we need to skip
Pablo Greco e6a3ae
over signature entries while reading the boot script in order to maintain our
Pablo Greco e6a3ae
ability to boot guest operating systems that have a secure bootloader.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Reviewed-by: Farhan Ali <alifm@linux.ibm.com>
Pablo Greco e6a3ae
Message-Id: <1556543381-12671-1-git-send-email-jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Signed-off-by: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 2497b4a3c08426122d1a89b808c669a734469e5a)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 pc-bios/s390-ccw/bootmap.c | 19 +++++++++++++++++--
Pablo Greco e6a3ae
 pc-bios/s390-ccw/bootmap.h | 10 ++++++----
Pablo Greco e6a3ae
 2 files changed, 23 insertions(+), 6 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
Pablo Greco e6a3ae
index e41e715..ffbf671 100644
Pablo Greco e6a3ae
--- a/pc-bios/s390-ccw/bootmap.c
Pablo Greco e6a3ae
+++ b/pc-bios/s390-ccw/bootmap.c
Pablo Greco e6a3ae
@@ -309,7 +309,14 @@ static void run_eckd_boot_script(block_number_t bmt_block_nr,
Pablo Greco e6a3ae
     memset(sec, FREE_SPACE_FILLER, sizeof(sec));
Pablo Greco e6a3ae
     read_block(block_nr, sec, "Cannot read Boot Map Script");
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-    for (i = 0; bms->entry[i].type == BOOT_SCRIPT_LOAD; i++) {
Pablo Greco e6a3ae
+    for (i = 0; bms->entry[i].type == BOOT_SCRIPT_LOAD ||
Pablo Greco e6a3ae
+                bms->entry[i].type == BOOT_SCRIPT_SIGNATURE; i++) {
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+        /* We don't support secure boot yet, so we skip signature entries */
Pablo Greco e6a3ae
+        if (bms->entry[i].type == BOOT_SCRIPT_SIGNATURE) {
Pablo Greco e6a3ae
+            continue;
Pablo Greco e6a3ae
+        }
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
         address = bms->entry[i].address.load_address;
Pablo Greco e6a3ae
         block_nr = eckd_block_num(&bms->entry[i].blkptr.xeckd.bptr.chs);
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
@@ -544,7 +551,15 @@ static void zipl_run(ScsiBlockPtr *pte)
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     /* Load image(s) into RAM */
Pablo Greco e6a3ae
     entry = (ComponentEntry *)(&header[1]);
Pablo Greco e6a3ae
-    while (entry->component_type == ZIPL_COMP_ENTRY_LOAD) {
Pablo Greco e6a3ae
+    while (entry->component_type == ZIPL_COMP_ENTRY_LOAD ||
Pablo Greco e6a3ae
+           entry->component_type == ZIPL_COMP_ENTRY_SIGNATURE) {
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+        /* We don't support secure boot yet, so we skip signature entries */
Pablo Greco e6a3ae
+        if (entry->component_type == ZIPL_COMP_ENTRY_SIGNATURE) {
Pablo Greco e6a3ae
+            entry++;
Pablo Greco e6a3ae
+            continue;
Pablo Greco e6a3ae
+        }
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
         zipl_load_segment(entry);
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
         entry++;
Pablo Greco e6a3ae
diff --git a/pc-bios/s390-ccw/bootmap.h b/pc-bios/s390-ccw/bootmap.h
Pablo Greco e6a3ae
index 732c111..f1ce423 100644
Pablo Greco e6a3ae
--- a/pc-bios/s390-ccw/bootmap.h
Pablo Greco e6a3ae
+++ b/pc-bios/s390-ccw/bootmap.h
Pablo Greco e6a3ae
@@ -98,8 +98,9 @@ typedef struct ScsiMbr {
Pablo Greco e6a3ae
 #define ZIPL_COMP_HEADER_IPL    0x00
Pablo Greco e6a3ae
 #define ZIPL_COMP_HEADER_DUMP   0x01
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-#define ZIPL_COMP_ENTRY_LOAD    0x02
Pablo Greco e6a3ae
-#define ZIPL_COMP_ENTRY_EXEC    0x01
Pablo Greco e6a3ae
+#define ZIPL_COMP_ENTRY_EXEC      0x01
Pablo Greco e6a3ae
+#define ZIPL_COMP_ENTRY_LOAD      0x02
Pablo Greco e6a3ae
+#define ZIPL_COMP_ENTRY_SIGNATURE 0x03
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 typedef struct XEckdMbr {
Pablo Greco e6a3ae
     uint8_t magic[4];   /* == "xIPL"        */
Pablo Greco e6a3ae
@@ -117,8 +118,9 @@ typedef struct BootMapScriptEntry {
Pablo Greco e6a3ae
     BootMapPointer blkptr;
Pablo Greco e6a3ae
     uint8_t pad[7];
Pablo Greco e6a3ae
     uint8_t type;   /* == BOOT_SCRIPT_* */
Pablo Greco e6a3ae
-#define BOOT_SCRIPT_EXEC 0x01
Pablo Greco e6a3ae
-#define BOOT_SCRIPT_LOAD 0x02
Pablo Greco e6a3ae
+#define BOOT_SCRIPT_EXEC      0x01
Pablo Greco e6a3ae
+#define BOOT_SCRIPT_LOAD      0x02
Pablo Greco e6a3ae
+#define BOOT_SCRIPT_SIGNATURE 0x03
Pablo Greco e6a3ae
     union {
Pablo Greco e6a3ae
         uint64_t load_address;
Pablo Greco e6a3ae
         uint64_t load_psw;
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae