Pablo Greco e6a3ae
From 256d99ee0acedd9ca8f21c9ebec83eee5e905c9d Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Date: Mon, 14 Oct 2019 10:06:35 +0100
Pablo Greco e6a3ae
Subject: [PATCH 10/21] s390-bios: Map low core memory
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-id: <20191014100645.22862-8-thuth@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 91786
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 07/17] s390-bios: Map low core memory
Pablo Greco e6a3ae
Bugzilla: 1664376
Pablo Greco e6a3ae
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
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
Pablo Greco e6a3ae
From: "Jason J. Herne" <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Create a new header for basic architecture specific definitions and add a
Pablo Greco e6a3ae
mapping of low core memory. This mapping will be used by the real dasd boot
Pablo Greco e6a3ae
process.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Jason J. Herne <jjherne@linux.ibm.com>
Pablo Greco e6a3ae
Acked-by: Cornelia Huck <cohuck@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Thomas Huth <thuth@redhat.com>
Pablo Greco e6a3ae
Message-Id: <1554388475-18329-7-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 c95df3d108028ff5a709ee3aefdb14401b07cb39)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 pc-bios/s390-ccw/main.c      |  2 +
Pablo Greco e6a3ae
 pc-bios/s390-ccw/s390-arch.h | 90 ++++++++++++++++++++++++++++++++++++++++++++
Pablo Greco e6a3ae
 2 files changed, 92 insertions(+)
Pablo Greco e6a3ae
 create mode 100644 pc-bios/s390-ccw/s390-arch.h
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
Pablo Greco e6a3ae
index 10f04c6..e403b5f 100644
Pablo Greco e6a3ae
--- a/pc-bios/s390-ccw/main.c
Pablo Greco e6a3ae
+++ b/pc-bios/s390-ccw/main.c
Pablo Greco e6a3ae
@@ -9,6 +9,7 @@
Pablo Greco e6a3ae
  */
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 #include "libc.h"
Pablo Greco e6a3ae
+#include "s390-arch.h"
Pablo Greco e6a3ae
 #include "s390-ccw.h"
Pablo Greco e6a3ae
 #include "cio.h"
Pablo Greco e6a3ae
 #include "virtio.h"
Pablo Greco e6a3ae
@@ -19,6 +20,7 @@ static char loadparm_str[LOADPARM_LEN + 1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
Pablo Greco e6a3ae
 QemuIplParameters qipl;
Pablo Greco e6a3ae
 IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE)));
Pablo Greco e6a3ae
 static bool have_iplb;
Pablo Greco e6a3ae
+LowCore const *lowcore; /* Yes, this *is* a pointer to address 0 */
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
 #define LOADPARM_PROMPT "PROMPT  "
Pablo Greco e6a3ae
 #define LOADPARM_EMPTY  "        "
Pablo Greco e6a3ae
diff --git a/pc-bios/s390-ccw/s390-arch.h b/pc-bios/s390-ccw/s390-arch.h
Pablo Greco e6a3ae
new file mode 100644
Pablo Greco e6a3ae
index 0000000..5e92c7a
Pablo Greco e6a3ae
--- /dev/null
Pablo Greco e6a3ae
+++ b/pc-bios/s390-ccw/s390-arch.h
Pablo Greco e6a3ae
@@ -0,0 +1,90 @@
Pablo Greco e6a3ae
+/*
Pablo Greco e6a3ae
+ * S390 Basic Architecture
Pablo Greco e6a3ae
+ *
Pablo Greco e6a3ae
+ * Copyright (c) 2019 Jason J. Herne <jjherne@us.ibm.com>
Pablo Greco e6a3ae
+ *
Pablo Greco e6a3ae
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
Pablo Greco e6a3ae
+ * your option) any later version. See the COPYING file in the top-level
Pablo Greco e6a3ae
+ * directory.
Pablo Greco e6a3ae
+ */
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+#ifndef S390_ARCH_H
Pablo Greco e6a3ae
+#define S390_ARCH_H
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+typedef struct PSW {
Pablo Greco e6a3ae
+    uint64_t mask;
Pablo Greco e6a3ae
+    uint64_t addr;
Pablo Greco e6a3ae
+} __attribute__ ((aligned(8))) PSW;
Pablo Greco e6a3ae
+_Static_assert(sizeof(struct PSW) == 16, "PSW size incorrect");
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+/* Older PSW format used by LPSW instruction */
Pablo Greco e6a3ae
+typedef struct PSWLegacy {
Pablo Greco e6a3ae
+    uint32_t mask;
Pablo Greco e6a3ae
+    uint32_t addr;
Pablo Greco e6a3ae
+} __attribute__ ((aligned(8))) PSWLegacy;
Pablo Greco e6a3ae
+_Static_assert(sizeof(struct PSWLegacy) == 8, "PSWLegacy size incorrect");
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+/* s390 psw bit masks */
Pablo Greco e6a3ae
+#define PSW_MASK_IOINT      0x0200000000000000ULL
Pablo Greco e6a3ae
+#define PSW_MASK_WAIT       0x0002000000000000ULL
Pablo Greco e6a3ae
+#define PSW_MASK_EAMODE     0x0000000100000000ULL
Pablo Greco e6a3ae
+#define PSW_MASK_BAMODE     0x0000000080000000ULL
Pablo Greco e6a3ae
+#define PSW_MASK_ZMODE      (PSW_MASK_EAMODE | PSW_MASK_BAMODE)
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+/* Low core mapping */
Pablo Greco e6a3ae
+typedef struct LowCore {
Pablo Greco e6a3ae
+    /* prefix area: defined by architecture */
Pablo Greco e6a3ae
+    PSWLegacy       ipl_psw;                  /* 0x000 */
Pablo Greco e6a3ae
+    uint32_t        ccw1[2];                  /* 0x008 */
Pablo Greco e6a3ae
+    uint32_t        ccw2[2];                  /* 0x010 */
Pablo Greco e6a3ae
+    uint8_t         pad1[0x80 - 0x18];        /* 0x018 */
Pablo Greco e6a3ae
+    uint32_t        ext_params;               /* 0x080 */
Pablo Greco e6a3ae
+    uint16_t        cpu_addr;                 /* 0x084 */
Pablo Greco e6a3ae
+    uint16_t        ext_int_code;             /* 0x086 */
Pablo Greco e6a3ae
+    uint16_t        svc_ilen;                 /* 0x088 */
Pablo Greco e6a3ae
+    uint16_t        svc_code;                 /* 0x08a */
Pablo Greco e6a3ae
+    uint16_t        pgm_ilen;                 /* 0x08c */
Pablo Greco e6a3ae
+    uint16_t        pgm_code;                 /* 0x08e */
Pablo Greco e6a3ae
+    uint32_t        data_exc_code;            /* 0x090 */
Pablo Greco e6a3ae
+    uint16_t        mon_class_num;            /* 0x094 */
Pablo Greco e6a3ae
+    uint16_t        per_perc_atmid;           /* 0x096 */
Pablo Greco e6a3ae
+    uint64_t        per_address;              /* 0x098 */
Pablo Greco e6a3ae
+    uint8_t         exc_access_id;            /* 0x0a0 */
Pablo Greco e6a3ae
+    uint8_t         per_access_id;            /* 0x0a1 */
Pablo Greco e6a3ae
+    uint8_t         op_access_id;             /* 0x0a2 */
Pablo Greco e6a3ae
+    uint8_t         ar_access_id;             /* 0x0a3 */
Pablo Greco e6a3ae
+    uint8_t         pad2[0xA8 - 0xA4];        /* 0x0a4 */
Pablo Greco e6a3ae
+    uint64_t        trans_exc_code;           /* 0x0a8 */
Pablo Greco e6a3ae
+    uint64_t        monitor_code;             /* 0x0b0 */
Pablo Greco e6a3ae
+    uint16_t        subchannel_id;            /* 0x0b8 */
Pablo Greco e6a3ae
+    uint16_t        subchannel_nr;            /* 0x0ba */
Pablo Greco e6a3ae
+    uint32_t        io_int_parm;              /* 0x0bc */
Pablo Greco e6a3ae
+    uint32_t        io_int_word;              /* 0x0c0 */
Pablo Greco e6a3ae
+    uint8_t         pad3[0xc8 - 0xc4];        /* 0x0c4 */
Pablo Greco e6a3ae
+    uint32_t        stfl_fac_list;            /* 0x0c8 */
Pablo Greco e6a3ae
+    uint8_t         pad4[0xe8 - 0xcc];        /* 0x0cc */
Pablo Greco e6a3ae
+    uint64_t        mcic;                     /* 0x0e8 */
Pablo Greco e6a3ae
+    uint8_t         pad5[0xf4 - 0xf0];        /* 0x0f0 */
Pablo Greco e6a3ae
+    uint32_t        external_damage_code;     /* 0x0f4 */
Pablo Greco e6a3ae
+    uint64_t        failing_storage_address;  /* 0x0f8 */
Pablo Greco e6a3ae
+    uint8_t         pad6[0x110 - 0x100];      /* 0x100 */
Pablo Greco e6a3ae
+    uint64_t        per_breaking_event_addr;  /* 0x110 */
Pablo Greco e6a3ae
+    uint8_t         pad7[0x120 - 0x118];      /* 0x118 */
Pablo Greco e6a3ae
+    PSW             restart_old_psw;          /* 0x120 */
Pablo Greco e6a3ae
+    PSW             external_old_psw;         /* 0x130 */
Pablo Greco e6a3ae
+    PSW             svc_old_psw;              /* 0x140 */
Pablo Greco e6a3ae
+    PSW             program_old_psw;          /* 0x150 */
Pablo Greco e6a3ae
+    PSW             mcck_old_psw;             /* 0x160 */
Pablo Greco e6a3ae
+    PSW             io_old_psw;               /* 0x170 */
Pablo Greco e6a3ae
+    uint8_t         pad8[0x1a0 - 0x180];      /* 0x180 */
Pablo Greco e6a3ae
+    PSW             restart_new_psw;          /* 0x1a0 */
Pablo Greco e6a3ae
+    PSW             external_new_psw;         /* 0x1b0 */
Pablo Greco e6a3ae
+    PSW             svc_new_psw;              /* 0x1c0 */
Pablo Greco e6a3ae
+    PSW             program_new_psw;          /* 0x1d0 */
Pablo Greco e6a3ae
+    PSW             mcck_new_psw;             /* 0x1e0 */
Pablo Greco e6a3ae
+    PSW             io_new_psw;               /* 0x1f0 */
Pablo Greco e6a3ae
+} __attribute__((packed, aligned(8192))) LowCore;
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+extern LowCore const *lowcore;
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+#endif
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae