Blame SOURCES/kvm-s390-bios-Support-booting-from-real-dasd-device.patch

016a62
From 2267eadd85126ea711cc8314c7df45a70486651c Mon Sep 17 00:00:00 2001
016a62
From: Thomas Huth <thuth@redhat.com>
016a62
Date: Mon, 14 Oct 2019 10:06:44 +0100
016a62
Subject: [PATCH 19/21] s390-bios: Support booting from real dasd device
016a62
016a62
RH-Author: Thomas Huth <thuth@redhat.com>
016a62
Message-id: <20191014100645.22862-17-thuth@redhat.com>
016a62
Patchwork-id: 91791
016a62
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 16/17] s390-bios: Support booting from real dasd device
016a62
Bugzilla: 1664376
016a62
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
016a62
RH-Acked-by: David Hildenbrand <david@redhat.com>
016a62
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
016a62
016a62
From: "Jason J. Herne" <jjherne@linux.ibm.com>
016a62
016a62
Allows guest to boot from a vfio configured real dasd device.
016a62
016a62
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
016a62
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
016a62
Message-Id: <1554388475-18329-16-git-send-email-jjherne@linux.ibm.com>
016a62
Signed-off-by: Thomas Huth <thuth@redhat.com>
016a62
(cherry picked from commit efa47d36da89f4b23c315a7cc085fab0d15eb47c)
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
016a62
Conflicts:
016a62
	MAINTAINERS
016a62
	(simple contextual conflict due to missing downstream commits)
016a62
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 MAINTAINERS                  |   3 +-
016a62
 docs/devel/s390-dasd-ipl.txt | 133 ++++++++++++++++++++++++
016a62
 pc-bios/s390-ccw/Makefile    |   2 +-
016a62
 pc-bios/s390-ccw/dasd-ipl.c  | 235 +++++++++++++++++++++++++++++++++++++++++++
016a62
 pc-bios/s390-ccw/dasd-ipl.h  |  16 +++
016a62
 pc-bios/s390-ccw/main.c      |   5 +
016a62
 pc-bios/s390-ccw/s390-arch.h |  13 +++
016a62
 7 files changed, 405 insertions(+), 2 deletions(-)
016a62
 create mode 100644 docs/devel/s390-dasd-ipl.txt
016a62
 create mode 100644 pc-bios/s390-ccw/dasd-ipl.c
016a62
 create mode 100644 pc-bios/s390-ccw/dasd-ipl.h
016a62
016a62
diff --git a/MAINTAINERS b/MAINTAINERS
016a62
index 9b74756..770885a 100644
016a62
--- a/MAINTAINERS
016a62
+++ b/MAINTAINERS
016a62
@@ -896,7 +896,8 @@ M: Thomas Huth <thuth@redhat.com>
016a62
 S: Supported
016a62
 F: pc-bios/s390-ccw/
016a62
 F: pc-bios/s390-ccw.img
016a62
-T: git git://github.com/borntraeger/qemu.git s390-next
016a62
+F: docs/devel/s390-dasd-ipl.txt
016a62
+T: git https://github.com/borntraeger/qemu.git s390-next
016a62
 L: qemu-s390x@nongnu.org
016a62
 
016a62
 UniCore32 Machines
016a62
diff --git a/docs/devel/s390-dasd-ipl.txt b/docs/devel/s390-dasd-ipl.txt
016a62
new file mode 100644
016a62
index 0000000..9107e04
016a62
--- /dev/null
016a62
+++ b/docs/devel/s390-dasd-ipl.txt
016a62
@@ -0,0 +1,133 @@
016a62
+*****************************
016a62
+***** s390 hardware IPL *****
016a62
+*****************************
016a62
+
016a62
+The s390 hardware IPL process consists of the following steps.
016a62
+
016a62
+1. A READ IPL ccw is constructed in memory location 0x0.
016a62
+    This ccw, by definition, reads the IPL1 record which is located on the disk
016a62
+    at cylinder 0 track 0 record 1. Note that the chain flag is on in this ccw
016a62
+    so when it is complete another ccw will be fetched and executed from memory
016a62
+    location 0x08.
016a62
+
016a62
+2. Execute the Read IPL ccw at 0x00, thereby reading IPL1 data into 0x00.
016a62
+    IPL1 data is 24 bytes in length and consists of the following pieces of
016a62
+    information: [psw][read ccw][tic ccw]. When the machine executes the Read
016a62
+    IPL ccw it read the 24-bytes of IPL1 to be read into memory starting at
016a62
+    location 0x0. Then the ccw program at 0x08 which consists of a read
016a62
+    ccw and a tic ccw is automatically executed because of the chain flag from
016a62
+    the original READ IPL ccw. The read ccw will read the IPL2 data into memory
016a62
+    and the TIC (Transfer In Channel) will transfer control to the channel
016a62
+    program contained in the IPL2 data. The TIC channel command is the
016a62
+    equivalent of a branch/jump/goto instruction for channel programs.
016a62
+    NOTE: The ccws in IPL1 are defined by the architecture to be format 0.
016a62
+
016a62
+3. Execute IPL2.
016a62
+    The TIC ccw instruction at the end of the IPL1 channel program will begin
016a62
+    the execution of the IPL2 channel program. IPL2 is stage-2 of the boot
016a62
+    process and will contain a larger channel program than IPL1. The point of
016a62
+    IPL2 is to find and load either the operating system or a small program that
016a62
+    loads the operating system from disk. At the end of this step all or some of
016a62
+    the real operating system is loaded into memory and we are ready to hand
016a62
+    control over to the guest operating system. At this point the guest
016a62
+    operating system is entirely responsible for loading any more data it might
016a62
+    need to function. NOTE: The IPL2 channel program might read data into memory
016a62
+    location 0 thereby overwriting the IPL1 psw and channel program. This is ok
016a62
+    as long as the data placed in location 0 contains a psw whose instruction
016a62
+    address points to the guest operating system code to execute at the end of
016a62
+    the IPL/boot process.
016a62
+    NOTE: The ccws in IPL2 are defined by the architecture to be format 0.
016a62
+
016a62
+4. Start executing the guest operating system.
016a62
+    The psw that was loaded into memory location 0 as part of the ipl process
016a62
+    should contain the needed flags for the operating system we have loaded. The
016a62
+    psw's instruction address will point to the location in memory where we want
016a62
+    to start executing the operating system. This psw is loaded (via LPSW
016a62
+    instruction) causing control to be passed to the operating system code.
016a62
+
016a62
+In a non-virtualized environment this process, handled entirely by the hardware,
016a62
+is kicked off by the user initiating a "Load" procedure from the hardware
016a62
+management console. This "Load" procedure crafts a special "Read IPL" ccw in
016a62
+memory location 0x0 that reads IPL1. It then executes this ccw thereby kicking
016a62
+off the reading of IPL1 data. Since the channel program from IPL1 will be
016a62
+written immediately after the special "Read IPL" ccw, the IPL1 channel program
016a62
+will be executed immediately (the special read ccw has the chaining bit turned
016a62
+on). The TIC at the end of the IPL1 channel program will cause the IPL2 channel
016a62
+program to be executed automatically. After this sequence completes the "Load"
016a62
+procedure then loads the psw from 0x0.
016a62
+
016a62
+**********************************************************
016a62
+***** How this all pertains to QEMU (and the kernel) *****
016a62
+**********************************************************
016a62
+
016a62
+In theory we should merely have to do the following to IPL/boot a guest
016a62
+operating system from a DASD device:
016a62
+
016a62
+1. Place a "Read IPL" ccw into memory location 0x0 with chaining bit on.
016a62
+2. Execute channel program at 0x0.
016a62
+3. LPSW 0x0.
016a62
+
016a62
+However, our emulation of the machine's channel program logic within the kernel
016a62
+is missing one key feature that is required for this process to work:
016a62
+non-prefetch of ccw data.
016a62
+
016a62
+When we start a channel program we pass the channel subsystem parameters via an
016a62
+ORB (Operation Request Block). One of those parameters is a prefetch bit. If the
016a62
+bit is on then the vfio-ccw kernel driver is allowed to read the entire channel
016a62
+program from guest memory before it starts executing it. This means that any
016a62
+channel commands that read additional channel commands will not work as expected
016a62
+because the newly read commands will only exist in guest memory and NOT within
016a62
+the kernel's channel subsystem memory. The kernel vfio-ccw driver currently
016a62
+requires this bit to be on for all channel programs. This is a problem because
016a62
+the IPL process consists of transferring control from the "Read IPL" ccw
016a62
+immediately to the IPL1 channel program that was read by "Read IPL".
016a62
+
016a62
+Not being able to turn off prefetch will also prevent the TIC at the end of the
016a62
+IPL1 channel program from transferring control to the IPL2 channel program.
016a62
+
016a62
+Lastly, in some cases (the zipl bootloader for example) the IPL2 program also
016a62
+transfers control to another channel program segment immediately after reading
016a62
+it from the disk. So we need to be able to handle this case.
016a62
+
016a62
+**************************
016a62
+***** What QEMU does *****
016a62
+**************************
016a62
+
016a62
+Since we are forced to live with prefetch we cannot use the very simple IPL
016a62
+procedure we defined in the preceding section. So we compensate by doing the
016a62
+following.
016a62
+
016a62
+1. Place "Read IPL" ccw into memory location 0x0, but turn off chaining bit.
016a62
+2. Execute "Read IPL" at 0x0.
016a62
+
016a62
+   So now IPL1's psw is at 0x0 and IPL1's channel program is at 0x08.
016a62
+
016a62
+4. Write a custom channel program that will seek to the IPL2 record and then
016a62
+   execute the READ and TIC ccws from IPL1.  Normally the seek is not required
016a62
+   because after reading the IPL1 record the disk is automatically positioned
016a62
+   to read the very next record which will be IPL2. But since we are not reading
016a62
+   both IPL1 and IPL2 as part of the same channel program we must manually set
016a62
+   the position.
016a62
+
016a62
+5. Grab the target address of the TIC instruction from the IPL1 channel program.
016a62
+   This address is where the IPL2 channel program starts.
016a62
+
016a62
+   Now IPL2 is loaded into memory somewhere, and we know the address.
016a62
+
016a62
+6. Execute the IPL2 channel program at the address obtained in step #5.
016a62
+
016a62
+   Because this channel program can be dynamic, we must use a special algorithm
016a62
+   that detects a READ immediately followed by a TIC and breaks the ccw chain
016a62
+   by turning off the chain bit in the READ ccw. When control is returned from
016a62
+   the kernel/hardware to the QEMU bios code we immediately issue another start
016a62
+   subchannel to execute the remaining TIC instruction. This causes the entire
016a62
+   channel program (starting from the TIC) and all needed data to be refetched
016a62
+   thereby stepping around the limitation that would otherwise prevent this
016a62
+   channel program from executing properly.
016a62
+
016a62
+   Now the operating system code is loaded somewhere in guest memory and the psw
016a62
+   in memory location 0x0 will point to entry code for the guest operating
016a62
+   system.
016a62
+
016a62
+7. LPSW 0x0.
016a62
+   LPSW transfers control to the guest operating system and we're done.
016a62
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
016a62
index acca961..d6a6e18 100644
016a62
--- a/pc-bios/s390-ccw/Makefile
016a62
+++ b/pc-bios/s390-ccw/Makefile
016a62
@@ -10,7 +10,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw)
016a62
 .PHONY : all clean build-all
016a62
 
016a62
 OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \
016a62
-	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o
016a62
+	  virtio.o virtio-scsi.o virtio-blkdev.o libc.o cio.o dasd-ipl.o
016a62
 
016a62
 QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS))
016a62
 QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float
016a62
diff --git a/pc-bios/s390-ccw/dasd-ipl.c b/pc-bios/s390-ccw/dasd-ipl.c
016a62
new file mode 100644
016a62
index 0000000..0fc879b
016a62
--- /dev/null
016a62
+++ b/pc-bios/s390-ccw/dasd-ipl.c
016a62
@@ -0,0 +1,235 @@
016a62
+/*
016a62
+ * S390 IPL (boot) from a real DASD device via vfio framework.
016a62
+ *
016a62
+ * Copyright (c) 2019 Jason J. Herne <jjherne@us.ibm.com>
016a62
+ *
016a62
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
016a62
+ * your option) any later version. See the COPYING file in the top-level
016a62
+ * directory.
016a62
+ */
016a62
+
016a62
+#include "libc.h"
016a62
+#include "s390-ccw.h"
016a62
+#include "s390-arch.h"
016a62
+#include "dasd-ipl.h"
016a62
+#include "helper.h"
016a62
+
016a62
+static char prefix_page[PAGE_SIZE * 2]
016a62
+            __attribute__((__aligned__(PAGE_SIZE * 2)));
016a62
+
016a62
+static void enable_prefixing(void)
016a62
+{
016a62
+    memcpy(&prefix_page, lowcore, 4096);
016a62
+    set_prefix(ptr2u32(&prefix_page));
016a62
+}
016a62
+
016a62
+static void disable_prefixing(void)
016a62
+{
016a62
+    set_prefix(0);
016a62
+    /* Copy io interrupt info back to low core */
016a62
+    memcpy((void *)&lowcore->subchannel_id, prefix_page + 0xB8, 12);
016a62
+}
016a62
+
016a62
+static bool is_read_tic_ccw_chain(Ccw0 *ccw)
016a62
+{
016a62
+    Ccw0 *next_ccw = ccw + 1;
016a62
+
016a62
+    return ((ccw->cmd_code == CCW_CMD_DASD_READ ||
016a62
+            ccw->cmd_code == CCW_CMD_DASD_READ_MT) &&
016a62
+            ccw->chain && next_ccw->cmd_code == CCW_CMD_TIC);
016a62
+}
016a62
+
016a62
+static bool dynamic_cp_fixup(uint32_t ccw_addr, uint32_t  *next_cpa)
016a62
+{
016a62
+    Ccw0 *cur_ccw = (Ccw0 *)(uint64_t)ccw_addr;
016a62
+    Ccw0 *tic_ccw;
016a62
+
016a62
+    while (true) {
016a62
+        /* Skip over inline TIC (it might not have the chain bit on)  */
016a62
+        if (cur_ccw->cmd_code == CCW_CMD_TIC &&
016a62
+            cur_ccw->cda == ptr2u32(cur_ccw) - 8) {
016a62
+            cur_ccw += 1;
016a62
+            continue;
016a62
+        }
016a62
+
016a62
+        if (!cur_ccw->chain) {
016a62
+            break;
016a62
+        }
016a62
+        if (is_read_tic_ccw_chain(cur_ccw)) {
016a62
+            /*
016a62
+             * Breaking a chain of CCWs may alter the semantics or even the
016a62
+             * validity of a channel program. The heuristic implemented below
016a62
+             * seems to work well in practice for the channel programs
016a62
+             * generated by zipl.
016a62
+             */
016a62
+            tic_ccw = cur_ccw + 1;
016a62
+            *next_cpa = tic_ccw->cda;
016a62
+            cur_ccw->chain = 0;
016a62
+            return true;
016a62
+        }
016a62
+        cur_ccw += 1;
016a62
+    }
016a62
+    return false;
016a62
+}
016a62
+
016a62
+static int run_dynamic_ccw_program(SubChannelId schid, uint16_t cutype,
016a62
+                                   uint32_t cpa)
016a62
+{
016a62
+    bool has_next;
016a62
+    uint32_t next_cpa = 0;
016a62
+    int rc;
016a62
+
016a62
+    do {
016a62
+        has_next = dynamic_cp_fixup(cpa, &next_cpa);
016a62
+
016a62
+        print_int("executing ccw chain at ", cpa);
016a62
+        enable_prefixing();
016a62
+        rc = do_cio(schid, cutype, cpa, CCW_FMT0);
016a62
+        disable_prefixing();
016a62
+
016a62
+        if (rc) {
016a62
+            break;
016a62
+        }
016a62
+        cpa = next_cpa;
016a62
+    } while (has_next);
016a62
+
016a62
+    return rc;
016a62
+}
016a62
+
016a62
+static void make_readipl(void)
016a62
+{
016a62
+    Ccw0 *ccwIplRead = (Ccw0 *)0x00;
016a62
+
016a62
+    /* Create Read IPL ccw at address 0 */
016a62
+    ccwIplRead->cmd_code = CCW_CMD_READ_IPL;
016a62
+    ccwIplRead->cda = 0x00; /* Read into address 0x00 in main memory */
016a62
+    ccwIplRead->chain = 0; /* Chain flag */
016a62
+    ccwIplRead->count = 0x18; /* Read 0x18 bytes of data */
016a62
+}
016a62
+
016a62
+static void run_readipl(SubChannelId schid, uint16_t cutype)
016a62
+{
016a62
+    if (do_cio(schid, cutype, 0x00, CCW_FMT0)) {
016a62
+        panic("dasd-ipl: Failed to run Read IPL channel program\n");
016a62
+    }
016a62
+}
016a62
+
016a62
+/*
016a62
+ * The architecture states that IPL1 data should consist of a psw followed by
016a62
+ * format-0 READ and TIC CCWs. Let's sanity check.
016a62
+ */
016a62
+static void check_ipl1(void)
016a62
+{
016a62
+    Ccw0 *ccwread = (Ccw0 *)0x08;
016a62
+    Ccw0 *ccwtic = (Ccw0 *)0x10;
016a62
+
016a62
+    if (ccwread->cmd_code != CCW_CMD_DASD_READ ||
016a62
+        ccwtic->cmd_code != CCW_CMD_TIC) {
016a62
+        panic("dasd-ipl: IPL1 data invalid. Is this disk really bootable?\n");
016a62
+    }
016a62
+}
016a62
+
016a62
+static void check_ipl2(uint32_t ipl2_addr)
016a62
+{
016a62
+    Ccw0 *ccw = u32toptr(ipl2_addr);
016a62
+
016a62
+    if (ipl2_addr == 0x00) {
016a62
+        panic("IPL2 address invalid. Is this disk really bootable?\n");
016a62
+    }
016a62
+    if (ccw->cmd_code == 0x00) {
016a62
+        panic("IPL2 ccw data invalid. Is this disk really bootable?\n");
016a62
+    }
016a62
+}
016a62
+
016a62
+static uint32_t read_ipl2_addr(void)
016a62
+{
016a62
+    Ccw0 *ccwtic = (Ccw0 *)0x10;
016a62
+
016a62
+    return ccwtic->cda;
016a62
+}
016a62
+
016a62
+static void ipl1_fixup(void)
016a62
+{
016a62
+    Ccw0 *ccwSeek = (Ccw0 *) 0x08;
016a62
+    Ccw0 *ccwSearchID = (Ccw0 *) 0x10;
016a62
+    Ccw0 *ccwSearchTic = (Ccw0 *) 0x18;
016a62
+    Ccw0 *ccwRead = (Ccw0 *) 0x20;
016a62
+    CcwSeekData *seekData = (CcwSeekData *) 0x30;
016a62
+    CcwSearchIdData *searchData = (CcwSearchIdData *) 0x38;
016a62
+
016a62
+    /* move IPL1 CCWs to make room for CCWs needed to locate record 2 */
016a62
+    memcpy(ccwRead, (void *)0x08, 16);
016a62
+
016a62
+    /* Disable chaining so we don't TIC to IPL2 channel program */
016a62
+    ccwRead->chain = 0x00;
016a62
+
016a62
+    ccwSeek->cmd_code = CCW_CMD_DASD_SEEK;
016a62
+    ccwSeek->cda = ptr2u32(seekData);
016a62
+    ccwSeek->chain = 1;
016a62
+    ccwSeek->count = sizeof(*seekData);
016a62
+    seekData->reserved = 0x00;
016a62
+    seekData->cyl = 0x00;
016a62
+    seekData->head = 0x00;
016a62
+
016a62
+    ccwSearchID->cmd_code = CCW_CMD_DASD_SEARCH_ID_EQ;
016a62
+    ccwSearchID->cda = ptr2u32(searchData);
016a62
+    ccwSearchID->chain = 1;
016a62
+    ccwSearchID->count = sizeof(*searchData);
016a62
+    searchData->cyl = 0;
016a62
+    searchData->head = 0;
016a62
+    searchData->record = 2;
016a62
+
016a62
+    /* Go back to Search CCW if correct record not yet found */
016a62
+    ccwSearchTic->cmd_code = CCW_CMD_TIC;
016a62
+    ccwSearchTic->cda = ptr2u32(ccwSearchID);
016a62
+}
016a62
+
016a62
+static void run_ipl1(SubChannelId schid, uint16_t cutype)
016a62
+ {
016a62
+    uint32_t startAddr = 0x08;
016a62
+
016a62
+    if (do_cio(schid, cutype, startAddr, CCW_FMT0)) {
016a62
+        panic("dasd-ipl: Failed to run IPL1 channel program\n");
016a62
+    }
016a62
+}
016a62
+
016a62
+static void run_ipl2(SubChannelId schid, uint16_t cutype, uint32_t addr)
016a62
+{
016a62
+    if (run_dynamic_ccw_program(schid, cutype, addr)) {
016a62
+        panic("dasd-ipl: Failed to run IPL2 channel program\n");
016a62
+    }
016a62
+}
016a62
+
016a62
+/*
016a62
+ * Limitations in vfio-ccw support complicate the IPL process. Details can
016a62
+ * be found in docs/devel/s390-dasd-ipl.txt
016a62
+ */
016a62
+void dasd_ipl(SubChannelId schid, uint16_t cutype)
016a62
+{
016a62
+    PSWLegacy *pswl = (PSWLegacy *) 0x00;
016a62
+    uint32_t ipl2_addr;
016a62
+
016a62
+    /* Construct Read IPL CCW and run it to read IPL1 from boot disk */
016a62
+    make_readipl();
016a62
+    run_readipl(schid, cutype);
016a62
+    ipl2_addr = read_ipl2_addr();
016a62
+    check_ipl1();
016a62
+
016a62
+    /*
016a62
+     * Fixup IPL1 channel program to account for vfio-ccw limitations, then run
016a62
+     * it to read IPL2 channel program from boot disk.
016a62
+     */
016a62
+    ipl1_fixup();
016a62
+    run_ipl1(schid, cutype);
016a62
+    check_ipl2(ipl2_addr);
016a62
+
016a62
+    /*
016a62
+     * Run IPL2 channel program to read operating system code from boot disk
016a62
+     */
016a62
+    run_ipl2(schid, cutype, ipl2_addr);
016a62
+
016a62
+    /* Transfer control to the guest operating system */
016a62
+    pswl->mask |= PSW_MASK_EAMODE;   /* Force z-mode */
016a62
+    pswl->addr |= PSW_MASK_BAMODE;   /* ...          */
016a62
+    jump_to_low_kernel();
016a62
+}
016a62
diff --git a/pc-bios/s390-ccw/dasd-ipl.h b/pc-bios/s390-ccw/dasd-ipl.h
016a62
new file mode 100644
016a62
index 0000000..c394828
016a62
--- /dev/null
016a62
+++ b/pc-bios/s390-ccw/dasd-ipl.h
016a62
@@ -0,0 +1,16 @@
016a62
+/*
016a62
+ * S390 IPL (boot) from a real DASD device via vfio framework.
016a62
+ *
016a62
+ * Copyright (c) 2019 Jason J. Herne <jjherne@us.ibm.com>
016a62
+ *
016a62
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
016a62
+ * your option) any later version. See the COPYING file in the top-level
016a62
+ * directory.
016a62
+ */
016a62
+
016a62
+#ifndef DASD_IPL_H
016a62
+#define DASD_IPL_H
016a62
+
016a62
+void dasd_ipl(SubChannelId schid, uint16_t cutype);
016a62
+
016a62
+#endif /* DASD_IPL_H */
016a62
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
016a62
index 57a1013..3c449ad 100644
016a62
--- a/pc-bios/s390-ccw/main.c
016a62
+++ b/pc-bios/s390-ccw/main.c
016a62
@@ -13,6 +13,7 @@
016a62
 #include "s390-ccw.h"
016a62
 #include "cio.h"
016a62
 #include "virtio.h"
016a62
+#include "dasd-ipl.h"
016a62
 
016a62
 char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
016a62
 static SubChannelId blk_schid = { .one = 1 };
016a62
@@ -209,6 +210,10 @@ int main(void)
016a62
 
016a62
     cutype = cu_type(blk_schid);
016a62
     switch (cutype) {
016a62
+    case CU_TYPE_DASD_3990:
016a62
+    case CU_TYPE_DASD_2107:
016a62
+        dasd_ipl(blk_schid, cutype); /* no return */
016a62
+        break;
016a62
     case CU_TYPE_VIRTIO:
016a62
         virtio_setup();
016a62
         zipl_load(); /* no return */
016a62
diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
016a62
index 5e92c7a..504fc7c 100644
016a62
--- a/pc-bios/s390-ccw/s390-arch.h
016a62
+++ b/pc-bios/s390-ccw/s390-arch.h
016a62
@@ -87,4 +87,17 @@ typedef struct LowCore {
016a62
 
016a62
 extern LowCore const *lowcore;
016a62
 
016a62
+static inline void set_prefix(uint32_t address)
016a62
+{
016a62
+    asm volatile("spx %0" : : "m" (address) : "memory");
016a62
+}
016a62
+
016a62
+static inline uint32_t store_prefix(void)
016a62
+{
016a62
+    uint32_t address;
016a62
+
016a62
+    asm volatile("stpx %0" : "=m" (address));
016a62
+    return address;
016a62
+}
016a62
+
016a62
 #endif
016a62
-- 
016a62
1.8.3.1
016a62