* [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest
@ 2015-02-12 17:02 Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 1/4] s390x/ipl: always load the bios for ccw machine Jens Freimann
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Jens Freimann @ 2015-02-12 17:02 UTC (permalink / raw)
To: Christian Borntraeger, Alexander Graf, Cornelia Huck
Cc: Jens Freimann, qemu-devel
Cornelia, Alex, Christian,
these patches add support to chane the IPL device from within the guest.
Jens
Fan Zhang (4):
s390x/ipl: always load the bios for ccw machine
s390x/ipl: support diagnose 308 subcodes 5 and 6
s390x/ipl: drop reipl parameters on resets
s390x/ipl: make s390x ipl device aware of migration
hw/s390x/ipl.c | 233 +++++++++++++++++++++++++++++++++------------
hw/s390x/ipl.h | 25 +++++
hw/s390x/s390-virtio-ccw.c | 2 +-
hw/s390x/s390-virtio.c | 8 +-
hw/s390x/s390-virtio.h | 3 +-
target-s390x/kvm.c | 3 +-
target-s390x/misc_helper.c | 33 ++++++-
7 files changed, 240 insertions(+), 67 deletions(-)
create mode 100644 hw/s390x/ipl.h
--
2.1.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/4] s390x/ipl: always load the bios for ccw machine
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
@ 2015-02-12 17:02 ` Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 2/4] s390x/ipl: support diagnose 308 subcodes 5 and 6 Jens Freimann
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jens Freimann @ 2015-02-12 17:02 UTC (permalink / raw)
To: Christian Borntraeger, Alexander Graf, Cornelia Huck
Cc: Jens Freimann, qemu-devel, Fan Zhang
From: Fan Zhang <zhangfan@linux.vnet.ibm.com>
We will need bios support in order to be able to support selecting a
different boot device via diagnose 308 in the ccw machine, so let's
make the bios mandatory for the ccw machine.
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Fan Zhang <zhangfan@linux.vnet.ibm.com>
---
hw/s390x/ipl.c | 105 +++++++++++++++++++++++++--------------------
hw/s390x/s390-virtio-ccw.c | 2 +-
hw/s390x/s390-virtio.c | 6 ++-
hw/s390x/s390-virtio.h | 3 +-
4 files changed, 66 insertions(+), 50 deletions(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 4ba8409..4014a6a 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -50,6 +50,8 @@ typedef struct S390IPLState {
/*< private >*/
SysBusDevice parent_obj;
uint64_t start_addr;
+ uint64_t bios_start_addr;
+ bool enforce_bios;
/*< public >*/
char *kernel;
@@ -65,11 +67,14 @@ static int s390_ipl_init(SysBusDevice *dev)
uint64_t pentry = KERN_IMAGE_START;
int kernel_size;
- if (!ipl->kernel) {
- int bios_size;
- char *bios_filename;
+ int bios_size;
+ char *bios_filename;
- /* Load zipl bootloader */
+ /*
+ * Always load the bios if it was enforced,
+ * even if an external kernel has been defined.
+ */
+ if (!ipl->kernel || ipl->enforce_bios) {
if (bios_name == NULL) {
bios_name = ipl->firmware;
}
@@ -79,12 +84,12 @@ static int s390_ipl_init(SysBusDevice *dev)
hw_error("could not find stage1 bootloader\n");
}
- bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL,
- NULL, 1, ELF_MACHINE, 0);
+ bios_size = load_elf(bios_filename, NULL, NULL, &ipl->bios_start_addr,
+ NULL, NULL, 1, ELF_MACHINE, 0);
if (bios_size < 0) {
bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START,
4096);
- ipl->start_addr = ZIPL_IMAGE_START;
+ ipl->bios_start_addr = ZIPL_IMAGE_START;
if (bios_size > 4096) {
hw_error("stage1 bootloader is > 4k\n");
}
@@ -94,52 +99,59 @@ static int s390_ipl_init(SysBusDevice *dev)
if (bios_size == -1) {
hw_error("could not load bootloader '%s'\n", bios_name);
}
- return 0;
- }
- kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
- NULL, 1, ELF_MACHINE, 0);
- if (kernel_size < 0) {
- kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
- }
- if (kernel_size < 0) {
- fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
- return -1;
- }
- /*
- * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
- * kernel parameters here as well. Note: For old kernels (up to 3.2)
- * we can not rely on the ELF entry point - it was 0x800 (the SALIPL
- * loader) and it won't work. For this case we force it to 0x10000, too.
- */
- if (pentry == KERN_IMAGE_START || pentry == 0x800) {
- ipl->start_addr = KERN_IMAGE_START;
- /* Overwrite parameters in the kernel image, which are "rom" */
- strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
- } else {
- ipl->start_addr = pentry;
+ /* default boot target is the bios */
+ ipl->start_addr = ipl->bios_start_addr;
}
- if (ipl->initrd) {
- ram_addr_t initrd_offset;
- int initrd_size;
-
- initrd_offset = INITRD_START;
- while (kernel_size + 0x100000 > initrd_offset) {
- initrd_offset += 0x100000;
+ if (ipl->kernel) {
+ kernel_size = load_elf(ipl->kernel, NULL, NULL, &pentry, NULL,
+ NULL, 1, ELF_MACHINE, 0);
+ if (kernel_size < 0) {
+ kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
+ }
+ if (kernel_size < 0) {
+ fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
+ return -1;
}
- initrd_size = load_image_targphys(ipl->initrd, initrd_offset,
- ram_size - initrd_offset);
- if (initrd_size == -1) {
- fprintf(stderr, "qemu: could not load initrd '%s'\n", ipl->initrd);
- exit(1);
+ /*
+ * Is it a Linux kernel (starting at 0x10000)? If yes, we fill in the
+ * kernel parameters here as well. Note: For old kernels (up to 3.2)
+ * we can not rely on the ELF entry point - it was 0x800 (the SALIPL
+ * loader) and it won't work. For this case we force it to 0x10000, too.
+ */
+ if (pentry == KERN_IMAGE_START || pentry == 0x800) {
+ ipl->start_addr = KERN_IMAGE_START;
+ /* Overwrite parameters in the kernel image, which are "rom" */
+ strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
+ } else {
+ ipl->start_addr = pentry;
}
- /* we have to overwrite values in the kernel image, which are "rom" */
- stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
- stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
- }
+ if (ipl->initrd) {
+ ram_addr_t initrd_offset;
+ int initrd_size;
+
+ initrd_offset = INITRD_START;
+ while (kernel_size + 0x100000 > initrd_offset) {
+ initrd_offset += 0x100000;
+ }
+ initrd_size = load_image_targphys(ipl->initrd, initrd_offset,
+ ram_size - initrd_offset);
+ if (initrd_size == -1) {
+ fprintf(stderr, "qemu: could not load initrd '%s'\n",
+ ipl->initrd);
+ exit(1);
+ }
+ /*
+ * we have to overwrite values in the kernel image,
+ * which are "rom"
+ */
+ stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
+ stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
+ }
+ }
return 0;
}
@@ -148,6 +160,7 @@ static Property s390_ipl_properties[] = {
DEFINE_PROP_STRING("initrd", S390IPLState, initrd),
DEFINE_PROP_STRING("cmdline", S390IPLState, cmdline),
DEFINE_PROP_STRING("firmware", S390IPLState, firmware),
+ DEFINE_PROP_BOOL("enforce_bios", S390IPLState, enforce_bios, false),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 71bafe0..8f0ae59 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -126,7 +126,7 @@ static void ccw_init(MachineState *machine)
css_bus = virtual_css_bus_init();
s390_sclp_init();
s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
- machine->initrd_filename, "s390-ccw.img");
+ machine->initrd_filename, "s390-ccw.img", true);
s390_flic_init();
dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE);
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index c215cd8..13f9e49 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -128,7 +128,8 @@ static void s390_virtio_register_hcalls(void)
void s390_init_ipl_dev(const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
- const char *firmware)
+ const char *firmware,
+ bool enforce_bios)
{
DeviceState *dev;
@@ -141,6 +142,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
}
qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
qdev_prop_set_string(dev, "firmware", firmware);
+ qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
qdev_init_nofail(dev);
}
@@ -221,7 +223,7 @@ static void s390_init(MachineState *machine)
s390_bus = s390_virtio_bus_init(&my_ram_size);
s390_sclp_init();
s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
- machine->initrd_filename, ZIPL_FILENAME);
+ machine->initrd_filename, ZIPL_FILENAME, false);
s390_flic_init();
/* register hypercalls */
diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h
index 33847ae..75b67ed 100644
--- a/hw/s390x/s390-virtio.h
+++ b/hw/s390x/s390-virtio.h
@@ -26,7 +26,8 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys);
void s390_init_ipl_dev(const char *kernel_filename,
const char *kernel_cmdline,
const char *initrd_filename,
- const char *firmware);
+ const char *firmware,
+ bool enforce_bios);
void s390_create_virtio_net(BusState *bus, const char *name);
void s390_nmi(NMIState *n, int cpu_index, Error **errp);
#endif
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/4] s390x/ipl: support diagnose 308 subcodes 5 and 6
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 1/4] s390x/ipl: always load the bios for ccw machine Jens Freimann
@ 2015-02-12 17:02 ` Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 3/4] s390x/ipl: drop reipl parameters on resets Jens Freimann
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Jens Freimann @ 2015-02-12 17:02 UTC (permalink / raw)
To: Christian Borntraeger, Alexander Graf, Cornelia Huck
Cc: Jens Freimann, qemu-devel, Fan Zhang
From: Fan Zhang <zhangfan@linux.vnet.ibm.com>
To support dynamically updating the IPL device from inside the KVM
guest on the s390 platform, DIAG 308 instruction is intercepted
in QEMU to handle the request.
Subcode 5 allows to specify a new boot device, which is saved for
later in the s390_ipl device. This also allows to switch from an
external kernel to a boot device.
Subcode 6 retrieves boot device configuration that has been previously
set.
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Fan Zhang <zhangfan@linux.vnet.ibm.com>
---
hw/s390x/ipl.c | 87 ++++++++++++++++++++++++++++++++++++++--------
hw/s390x/ipl.h | 24 +++++++++++++
hw/s390x/s390-virtio.c | 2 ++
target-s390x/misc_helper.c | 33 ++++++++++++++++--
4 files changed, 129 insertions(+), 17 deletions(-)
create mode 100644 hw/s390x/ipl.h
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 4014a6a..231713d 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -18,6 +18,7 @@
#include "hw/sysbus.h"
#include "hw/s390x/virtio-ccw.h"
#include "hw/s390x/css.h"
+#include "ipl.h"
#define KERN_IMAGE_START 0x010000UL
#define KERN_PARM_AREA 0x010480UL
@@ -52,12 +53,17 @@ typedef struct S390IPLState {
uint64_t start_addr;
uint64_t bios_start_addr;
bool enforce_bios;
+ IplParameterBlock iplb;
+ bool iplb_valid;
/*< public >*/
char *kernel;
char *initrd;
char *cmdline;
char *firmware;
+ uint8_t cssid;
+ uint8_t ssid;
+ uint16_t devno;
} S390IPLState;
@@ -164,6 +170,69 @@ static Property s390_ipl_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+/*
+ * In addition to updating the iplstate, this function returns:
+ * - 0 if system was ipled with external kernel
+ * - -1 if no valid boot device was found
+ * - ccw id of the boot device otherwise
+ */
+static uint64_t s390_update_iplstate(CPUS390XState *env, S390IPLState *ipl)
+{
+ DeviceState *dev_st;
+
+ if (ipl->iplb_valid) {
+ ipl->cssid = 0;
+ ipl->ssid = 0;
+ ipl->devno = ipl->iplb.devno;
+ goto out;
+ }
+
+ if (ipl->kernel) {
+ return 0;
+ }
+
+ dev_st = get_boot_device(0);
+ if (dev_st) {
+ VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast(
+ OBJECT(qdev_get_parent_bus(dev_st)->parent),
+ TYPE_VIRTIO_CCW_DEVICE);
+ if (ccw_dev) {
+ ipl->cssid = ccw_dev->sch->cssid;
+ ipl->ssid = ccw_dev->sch->ssid;
+ ipl->devno = ccw_dev->sch->devno;
+ goto out;
+ }
+ }
+
+ return -1;
+out:
+ return ipl->cssid << 24 | ipl->ssid << 16 | ipl->devno;
+}
+
+int s390_ipl_update_diag308(IplParameterBlock *iplb)
+{
+ S390IPLState *ipl;
+
+ ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
+ if (ipl) {
+ ipl->iplb = *iplb;
+ ipl->iplb_valid = true;
+ return 0;
+ }
+ return -1;
+}
+
+IplParameterBlock *s390_ipl_get_iplb(void)
+{
+ S390IPLState *ipl;
+
+ ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
+ if (!ipl || !ipl->iplb_valid) {
+ return NULL;
+ }
+ return &ipl->iplb;
+}
+
static void s390_ipl_reset(DeviceState *dev)
{
S390IPLState *ipl = S390_IPL(dev);
@@ -173,21 +242,9 @@ static void s390_ipl_reset(DeviceState *dev)
env->psw.addr = ipl->start_addr;
env->psw.mask = IPL_PSW_MASK;
- if (!ipl->kernel) {
- /* Tell firmware, if there is a preferred boot device */
- env->regs[7] = -1;
- DeviceState *dev_st = get_boot_device(0);
- if (dev_st) {
- VirtioCcwDevice *ccw_dev = (VirtioCcwDevice *) object_dynamic_cast(
- OBJECT(qdev_get_parent_bus(dev_st)->parent),
- TYPE_VIRTIO_CCW_DEVICE);
-
- if (ccw_dev) {
- env->regs[7] = ccw_dev->sch->cssid << 24 |
- ccw_dev->sch->ssid << 16 |
- ccw_dev->sch->devno;
- }
- }
+ if (!ipl->kernel || ipl->iplb_valid) {
+ env->psw.addr = ipl->bios_start_addr;
+ env->regs[7] = s390_update_iplstate(env, ipl);
}
s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
new file mode 100644
index 0000000..f1d082f
--- /dev/null
+++ b/hw/s390x/ipl.h
@@ -0,0 +1,24 @@
+/*
+ * s390 IPL device
+ *
+ * Copyright 2015 IBM Corp.
+ * Author(s): Zhang Fan <bjfanzh@cn.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef HW_S390_IPL_H
+#define HW_S390_IPL_H
+
+typedef struct IplParameterBlock {
+ uint8_t reserved1[110];
+ uint16_t devno;
+ uint8_t reserved2[88];
+} IplParameterBlock;
+
+int s390_ipl_update_diag308(IplParameterBlock *iplb);
+IplParameterBlock *s390_ipl_get_iplb(void);
+
+#endif
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 13f9e49..412e49b 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -143,6 +143,8 @@ void s390_init_ipl_dev(const char *kernel_filename,
qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
qdev_prop_set_string(dev, "firmware", firmware);
qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
+ object_property_add_child(qdev_get_machine(), "s390-ipl",
+ OBJECT(dev), NULL);
qdev_init_nofail(dev);
}
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index ef9758a..1c3df8e 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -25,6 +25,7 @@
#include <string.h>
#include "sysemu/kvm.h"
#include "qemu/timer.h"
+#include "exec/address-spaces.h"
#ifdef CONFIG_KVM
#include <linux/kvm.h>
#endif
@@ -34,6 +35,7 @@
#include "sysemu/cpus.h"
#include "sysemu/sysemu.h"
#include "hw/s390x/ebcdic.h"
+#include "hw/s390x/ipl.h"
#endif
/* #define DEBUG_HELPER */
@@ -151,12 +153,15 @@ static int load_normal_reset(S390CPU *cpu)
return 0;
}
+#define DIAG_308_RC_OK 0x0001
#define DIAG_308_RC_NO_CONF 0x0102
#define DIAG_308_RC_INVALID 0x0402
+
void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)
{
uint64_t addr = env->regs[r1];
uint64_t subcode = env->regs[r3];
+ IplParameterBlock *iplb;
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, ILEN_LATER_INC);
@@ -180,14 +185,38 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)
program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC);
return;
}
- env->regs[r1+1] = DIAG_308_RC_INVALID;
+ if (!address_space_access_valid(&address_space_memory, addr,
+ sizeof(IplParameterBlock), false)) {
+ program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC);
+ return;
+ }
+ iplb = g_malloc0(sizeof(struct IplParameterBlock));
+ cpu_physical_memory_read(addr, iplb, sizeof(struct IplParameterBlock));
+ if (!s390_ipl_update_diag308(iplb)) {
+ env->regs[r1 + 1] = DIAG_308_RC_OK;
+ } else {
+ env->regs[r1 + 1] = DIAG_308_RC_INVALID;
+ }
+ g_free(iplb);
return;
case 6:
if ((r1 & 1) || (addr & 0x0fffULL)) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER_INC);
return;
}
- env->regs[r1+1] = DIAG_308_RC_NO_CONF;
+ if (!address_space_access_valid(&address_space_memory, addr,
+ sizeof(IplParameterBlock), true)) {
+ program_interrupt(env, PGM_ADDRESSING, ILEN_LATER_INC);
+ return;
+ }
+ iplb = s390_ipl_get_iplb();
+ if (iplb) {
+ cpu_physical_memory_write(addr, iplb,
+ sizeof(struct IplParameterBlock));
+ env->regs[r1 + 1] = DIAG_308_RC_OK;
+ } else {
+ env->regs[r1 + 1] = DIAG_308_RC_NO_CONF;
+ }
return;
default:
hw_error("Unhandled diag308 subcode %" PRIx64, subcode);
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 3/4] s390x/ipl: drop reipl parameters on resets
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 1/4] s390x/ipl: always load the bios for ccw machine Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 2/4] s390x/ipl: support diagnose 308 subcodes 5 and 6 Jens Freimann
@ 2015-02-12 17:02 ` Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 4/4] s390x/ipl: make s390x ipl device aware of migration Jens Freimann
2015-02-13 16:36 ` [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Christian Borntraeger
4 siblings, 0 replies; 6+ messages in thread
From: Jens Freimann @ 2015-02-12 17:02 UTC (permalink / raw)
To: Christian Borntraeger, Alexander Graf, Cornelia Huck
Cc: Jens Freimann, qemu-devel, Fan Zhang
From: Fan Zhang <zhangfan@linux.vnet.ibm.com>
Whenever a reboot initiated by the guest is done, the reipl parameters should
remain valid. The disk configured by the guest is to be used for
ipl'ing. External reboot/reset request (e.g. via virsh reset guest) should
completely reset the guest to the initial state, and therefore also reset the
reipl parameters, resulting in an ipl behaviour of the initially configured
guest. This could be an external kernel or a disk.
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Fan Zhang <zhangfan@linux.vnet.ibm.com>
---
hw/s390x/ipl.c | 15 +++++++++++++++
hw/s390x/ipl.h | 1 +
target-s390x/kvm.c | 3 ++-
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 231713d..a1aa051 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -55,6 +55,7 @@ typedef struct S390IPLState {
bool enforce_bios;
IplParameterBlock iplb;
bool iplb_valid;
+ bool reipl_requested;
/*< public >*/
char *kernel;
@@ -233,6 +234,15 @@ IplParameterBlock *s390_ipl_get_iplb(void)
return &ipl->iplb;
}
+void s390_reipl_request(void)
+{
+ S390IPLState *ipl;
+
+ ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
+ ipl->reipl_requested = true;
+ qemu_system_reset_request();
+}
+
static void s390_ipl_reset(DeviceState *dev)
{
S390IPLState *ipl = S390_IPL(dev);
@@ -242,6 +252,11 @@ static void s390_ipl_reset(DeviceState *dev)
env->psw.addr = ipl->start_addr;
env->psw.mask = IPL_PSW_MASK;
+ if (!ipl->reipl_requested) {
+ ipl->iplb_valid = false;
+ }
+ ipl->reipl_requested = false;
+
if (!ipl->kernel || ipl->iplb_valid) {
env->psw.addr = ipl->bios_start_addr;
env->regs[7] = s390_update_iplstate(env, ipl);
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index f1d082f..70497bc 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -20,5 +20,6 @@ typedef struct IplParameterBlock {
int s390_ipl_update_diag308(IplParameterBlock *iplb);
IplParameterBlock *s390_ipl_get_iplb(void);
+void s390_reipl_request(void);
#endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 6f2d5b4..8c2f228 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -42,6 +42,7 @@
#include "qapi-event.h"
#include "hw/s390x/s390-pci-inst.h"
#include "hw/s390x/s390-pci-bus.h"
+#include "hw/s390x/ipl.h"
/* #define DEBUG_KVM */
@@ -1397,7 +1398,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
ret = handle_intercept(cpu);
break;
case KVM_EXIT_S390_RESET:
- qemu_system_reset_request();
+ s390_reipl_request();
break;
case KVM_EXIT_S390_TSCH:
ret = handle_tsch(cpu);
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 4/4] s390x/ipl: make s390x ipl device aware of migration
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
` (2 preceding siblings ...)
2015-02-12 17:02 ` [Qemu-devel] [PATCH 3/4] s390x/ipl: drop reipl parameters on resets Jens Freimann
@ 2015-02-12 17:02 ` Jens Freimann
2015-02-13 16:36 ` [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Christian Borntraeger
4 siblings, 0 replies; 6+ messages in thread
From: Jens Freimann @ 2015-02-12 17:02 UTC (permalink / raw)
To: Christian Borntraeger, Alexander Graf, Cornelia Huck
Cc: Jens Freimann, qemu-devel, Fan Zhang
From: Fan Zhang <zhangfan@linux.vnet.ibm.com>
We have to migrate the reipl parameters, so a reboot on the migrated machine
will behave just like on the origin. Otherwise, the reipl parameters configured
by the guest would be lost.
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Fan Zhang <zhangfan@linux.vnet.ibm.com>
---
hw/s390x/ipl.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index a1aa051..b57adbd 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -67,6 +67,33 @@ typedef struct S390IPLState {
uint16_t devno;
} S390IPLState;
+static const VMStateDescription vmstate_iplb = {
+ .name = "ipl/iplb",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT8_ARRAY(reserved1, IplParameterBlock, 110),
+ VMSTATE_UINT16(devno, IplParameterBlock),
+ VMSTATE_UINT8_ARRAY(reserved2, IplParameterBlock, 88),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static const VMStateDescription vmstate_ipl = {
+ .name = "ipl",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(start_addr, S390IPLState),
+ VMSTATE_UINT64(bios_start_addr, S390IPLState),
+ VMSTATE_STRUCT(iplb, S390IPLState, 0, vmstate_iplb, IplParameterBlock),
+ VMSTATE_BOOL(iplb_valid, S390IPLState),
+ VMSTATE_UINT8(cssid, S390IPLState),
+ VMSTATE_UINT8(ssid, S390IPLState),
+ VMSTATE_UINT16(devno, S390IPLState),
+ VMSTATE_END_OF_LIST()
+ }
+};
static int s390_ipl_init(SysBusDevice *dev)
{
@@ -273,6 +300,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data)
k->init = s390_ipl_init;
dc->props = s390_ipl_properties;
dc->reset = s390_ipl_reset;
+ dc->vmsd = &vmstate_ipl;
}
static const TypeInfo s390_ipl_info = {
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
` (3 preceding siblings ...)
2015-02-12 17:02 ` [Qemu-devel] [PATCH 4/4] s390x/ipl: make s390x ipl device aware of migration Jens Freimann
@ 2015-02-13 16:36 ` Christian Borntraeger
4 siblings, 0 replies; 6+ messages in thread
From: Christian Borntraeger @ 2015-02-13 16:36 UTC (permalink / raw)
To: Jens Freimann, Alexander Graf, Cornelia Huck; +Cc: qemu-devel
Am 12.02.2015 um 18:02 schrieb Jens Freimann:
> Cornelia, Alex, Christian,
>
> these patches add support to chane the IPL device from within the guest.
>
> Jens
>
>
> Fan Zhang (4):
> s390x/ipl: always load the bios for ccw machine
> s390x/ipl: support diagnose 308 subcodes 5 and 6
> s390x/ipl: drop reipl parameters on resets
> s390x/ipl: make s390x ipl device aware of migration
>
> hw/s390x/ipl.c | 233 +++++++++++++++++++++++++++++++++------------
> hw/s390x/ipl.h | 25 +++++
> hw/s390x/s390-virtio-ccw.c | 2 +-
> hw/s390x/s390-virtio.c | 8 +-
> hw/s390x/s390-virtio.h | 3 +-
> target-s390x/kvm.c | 3 +-
> target-s390x/misc_helper.c | 33 ++++++-
> 7 files changed, 240 insertions(+), 67 deletions(-)
> create mode 100644 hw/s390x/ipl.h
>
Thanks
Tested and applied to s390/queue
- /sys/firmware/reipl/ works
- lsreipl works
- using a slightly fixed chreipl works
- data is keep during managedsave/restore
- switch from external kernel to disk also works
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-02-13 16:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 17:02 [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 1/4] s390x/ipl: always load the bios for ccw machine Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 2/4] s390x/ipl: support diagnose 308 subcodes 5 and 6 Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 3/4] s390x/ipl: drop reipl parameters on resets Jens Freimann
2015-02-12 17:02 ` [Qemu-devel] [PATCH 4/4] s390x/ipl: make s390x ipl device aware of migration Jens Freimann
2015-02-13 16:36 ` [Qemu-devel] [PATCH 0/4] s390x/kvm: add support to change the IPL device in guest Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).