qemu-kvm/SOURCES/kvm-s390x-ipl-Try-to-detect-Linux-vs-non-Linux-for-initi.patch

90 lines
3.4 KiB
Diff

From 8128e12a8cb09bdb6bcb1b5735a9726f689e27c3 Mon Sep 17 00:00:00 2001
From: Cornelia Huck <cohuck@redhat.com>
Date: Wed, 17 Apr 2019 13:57:18 +0100
Subject: [PATCH 01/24] s390x/ipl: Try to detect Linux vs non Linux for initial
IPL PSW
RH-Author: Cornelia Huck <cohuck@redhat.com>
Message-id: <20190417135741.25297-2-cohuck@redhat.com>
Patchwork-id: 85783
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 01/24] s390x/ipl: Try to detect Linux vs non Linux for initial IPL PSW
Bugzilla: 1699070
RH-Acked-by: David Hildenbrand <david@redhat.com>
RH-Acked-by: Thomas Huth <thuth@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
From: Christian Borntraeger <borntraeger@de.ibm.com>
Right now the IPL device always starts from address 0x10000 (the usual
Linux entry point). To run other guests (e.g. test programs) it is
useful to use the IPL PSW from address 0. We can use the Linux magic
at 0x10008 to decide.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <20180612125933.262679-1-borntraeger@de.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
(cherry picked from commit acd7ef837d8987ad4ef2ab8f8e8c0f13ab413dd5)
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/s390x/ipl.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 150f6c0..617ac43 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -28,6 +28,7 @@
#include "qemu/option.h"
#define KERN_IMAGE_START 0x010000UL
+#define LINUX_MAGIC_ADDR 0x010008UL
#define KERN_PARM_AREA 0x010480UL
#define INITRD_START 0x800000UL
#define INITRD_PARM_START 0x010408UL
@@ -104,7 +105,9 @@ static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
static void s390_ipl_realize(DeviceState *dev, Error **errp)
{
S390IPLState *ipl = S390_IPL(dev);
- uint64_t pentry = KERN_IMAGE_START;
+ uint32_t *ipl_psw;
+ uint64_t pentry;
+ char *magic;
int kernel_size;
Error *err = NULL;
@@ -156,10 +159,24 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)
NULL, 1, EM_S390, 0, 0);
if (kernel_size < 0) {
kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
- }
- if (kernel_size < 0) {
- error_setg(&err, "could not load kernel '%s'", ipl->kernel);
- goto error;
+ if (kernel_size < 0) {
+ error_setg(&err, "could not load kernel '%s'", ipl->kernel);
+ goto error;
+ }
+ /* if this is Linux use KERN_IMAGE_START */
+ magic = rom_ptr(LINUX_MAGIC_ADDR);
+ if (magic && !memcmp(magic, "S390EP", 6)) {
+ pentry = KERN_IMAGE_START;
+ } else {
+ /* if not Linux load the address of the (short) IPL PSW */
+ ipl_psw = rom_ptr(4);
+ if (ipl_psw) {
+ pentry = be32_to_cpu(*ipl_psw) & 0x7fffffffUL;
+ } else {
+ error_setg(&err, "Could not get IPL PSW");
+ goto error;
+ }
+ }
}
/*
* Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
--
1.8.3.1