Skip to contentSkip to conversation

S390x KVM support v4

PATCH In review Alexander Graf 7 participants 40 messages Nov 24, 2009 – Nov 25, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover S390x KVM support v4

While S390x was one of the first targets that were supported by KVM it always lacked qemu system emulation support.

In order to change that sad fact, I figured I'd just take on the task myself, taking kuli (http://www.ibm.com/developerworks/linux/linux390/kuli.html),
Documentation/s390/kvm.txt and lguest as starting points to write a clean, qemu'ish S390x Virtio machine emulation.

So now you can run Linux VMs on Linux on z/VM on LPAR on zSeries!

This is the resulting code. Please comment on things you like and also on the ones you don't :-).

The patchset is based on Uli's S390x userspace emulation patches. There's not really that much shared functionality, but I didn't want to reimplement the configure wheels. So make sure to have his patches applied first.

Please only run S390x system virtualization using io threads. S390x has very few intercepts and even less that actually reach userspace. So you'll end up with a non-responsive VM without a dedicated IO thread.

Use: $ ./configure --target-list=s390x-softmmu --enable-io-thread

Currently only -kernel, -initrd and friends work. Booting from a real dasd device is not supported.

Also to actually run this code you need a patch for an ugly bug in the kernel module that Carsten sent a patch to on the ML.

I verified that the userspace actually works on a 2.6.27 (SLES11) kernel, so if it doesn't work on current git, please tell me! I'm too afraid that I might end up in a 3270 terminal to update the kernel on my z/VM instance :-).

##### WARNING #####

Apparently the qemu review process has scared off yet another developer for now.

So I'm sending this patchset without relying on Uli's set but rather implemented small stubs for TCG host and TCG guest support, so we can run on KVM. He promised me to send it again "soon" - whenever that is.

These stubs don't serve any purpose but to get KVM running, so you get no x86 on S390X or S390X on x86 for now!

##################

v1 -> v2:

- use new kvm_run variables
- use DO_UPCAST
- add bridge device for "info qtree"

v2 -> v3:

- move memory allocation logic to qemu_ram_alloc

v3 -> v4:

- minor bugfixes
- adjust to more recent qdev nic code
- zipl loader
- include fake emulation series

Alexander Graf (13):
S/390 CPU fake emulation
S/390 host/target build system support
S/390 fake TCG implementation
Add KVM support for S390x
Allocate physical memory in low virtual address space Add support for S390x system emulation
Add S390x virtio machine bus
Add S390x virtio machine description
S390 GDB stub
Implement early printk in virtio-console
Set default console to virtio on S390x
Add zipl bootloader interpreter
Add S390 maintainer information

 MAINTAINERS                       |    3 +
 Makefile.target                   |    2 +
 configure                         |   24 ++-
 cpu-exec.c                        |    2 +
 dyngen-exec.h                     |    2 +-
 exec.c                            |    6 +
 gdbstub.c                         |   52 ++++
 hw/s390-virtio-bus.c              |  385 ++++++++++++++++++++++++++++++
 hw/s390-virtio-bus.h              |   65 +++++
 hw/s390-virtio.c                  |  248 ++++++++++++++++++++
 hw/s390-zipl.c                    |  233 +++++++++++++++++++
 hw/virtio-console.c               |    7 +
 hw/virtio-console.h               |    2 +
 target-s390x/cpu.h                |  269 +++++++++++++++++++++
 target-s390x/exec.h               |   56 +++++
 target-s390x/helper.c             |   84 +++++++
 target-s390x/kvm.c                |  463 +++++++++++++++++++++++++++++++++++++
 target-s390x/machine.c            |   30 +++
 target-s390x/op_helper.c          |   74 ++++++
 target-s390x/translate.c          |   57 +++++
 tcg/s390/tcg-target.c             |  103 ++++++++
 tcg/s390/tcg-target.h             |   48 ++++
 vl.c                              |   26 ++
 23 files changed, 2233 insertions(+), 8 deletions(-)
 create mode 100644 default-configs/s390x-softmmu.mak
 create mode 100644 hw/s390-virtio-bus.c
 create mode 100644 hw/s390-virtio-bus.h
 create mode 100644 hw/s390-virtio.c
 create mode 100644 hw/s390-zipl.c
 create mode 100644 target-s390x/cpu.h
 create mode 100644 target-s390x/exec.h
 create mode 100644 target-s390x/helper.c
 create mode 100644 target-s390x/kvm.c
 create mode 100644 target-s390x/machine.c
 create mode 100644 target-s390x/op_helper.c
 create mode 100644 target-s390x/translate.c
 create mode 100644 tcg/s390/tcg-target.c
 create mode 100644 tcg/s390/tcg-target.h
#1 lore raw

PATCH 1/13 S/390 CPU fake emulation

Because Qemu currently requires a TCG target to exist and there are quite some useful helpers here to lay the groundwork for out KVM target, let's create a stub TCG emulation target for S390X CPUs.

This is required to make tcg happy. The emulation target itself won't work though.

---
 cpu-exec.c               |    2 +
 target-s390x/cpu.h       |  119 ++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/exec.h      |   51 ++++++++++++++++++++
 target-s390x/helper.c    |   57 ++++++++++++++++++++++
 target-s390x/op_helper.c |   74 ++++++++++++++++++++++++++++
 target-s390x/translate.c |   57 ++++++++++++++++++++++
 6 files changed, 360 insertions(+), 0 deletions(-)
 create mode 100644 target-s390x/cpu.h
 create mode 100644 target-s390x/exec.h
 create mode 100644 target-s390x/helper.c
 create mode 100644 target-s390x/op_helper.c
 create mode 100644 target-s390x/translate.c
cpu-exec.c +2 -0
index 2c0765c..af4595b 100644
@@ -249,6 +249,7 @@ int cpu_exec(CPUState *env1)
 #elif defined(TARGET_MIPS)
 #elif defined(TARGET_SH4)
 #elif defined(TARGET_CRIS)
+#elif defined(TARGET_S390X)
     /* XXXXX */
 #else
 #error unsupported target CPU
@@ -673,6 +674,7 @@ int cpu_exec(CPUState *env1)
 #elif defined(TARGET_SH4)
 #elif defined(TARGET_ALPHA)
 #elif defined(TARGET_CRIS)
+#elif defined(TARGET_S390X)
     /* XXXXX */
 #else
 #error unsupported target CPU
target-s390x/cpu.h new file +119 -0

119 lines not on this page · raw message

target-s390x/exec.h new file +51 -0

51 lines not on this page · raw message

target-s390x/helper.c new file +57 -0

57 lines not on this page · raw message

target-s390x/op_helper.c new file +74 -0

74 lines not on this page · raw message

target-s390x/translate.c new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/13 S/390 host/target build system support

In reply to Alexander Graf

This patch makes configure aware of S390 hosts and guests. When not explicitly defined using --target-list= no S390 targets will be built though.

---
 configure |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
configure +14 -6
index e108dfb..72a6f91 100755
@@ -158,9 +158,12 @@ case "$cpu" in
   parisc|parisc64)
     cpu="hppa"
   ;;
-  s390*)
+  s390)
     cpu="s390"
   ;;
+  s390x)
+    cpu="s390x"
+  ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
   ;;
@@ -860,7 +863,7 @@ fi
 # host long bits test
 hostlongbits="32"
 case "$cpu" in
-  x86_64|alpha|ia64|sparc64|ppc64)
+  x86_64|alpha|ia64|sparc64|ppc64|s390x)
     hostlongbits=64
   ;;
 esac
@@ -1872,7 +1875,7 @@ echo >> $config_host_mak
 echo "CONFIG_QEMU_SHAREDIR=\"$prefix$datasuffix\"" >> $config_host_mak
 
 case "$cpu" in
-  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
+  i386|x86_64|alpha|cris|hppa|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
     ARCH=$cpu
   ;;
   armv4b|armv4l)
@@ -2158,7 +2161,7 @@ target_arch2=`echo $target | cut -d '-' -f 1`
 target_bigendian="no"
 
 case "$target_arch2" in
-  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|sh4eb|sparc|sparc64|sparc32plus)
+  armeb|m68k|microblaze|mips|mipsn32|mips64|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus)
   target_bigendian=yes
   ;;
 esac
@@ -2330,6 +2333,9 @@ case "$target_arch2" in
     echo "TARGET_ABI32=y" >> $config_target_mak
     target_phys_bits=64
   ;;
+  s390x)
+    target_phys_bits=64
+  ;;
   *)
     echo "Unsupported target CPU"
     exit 1
@@ -2398,7 +2404,7 @@ if test ! -z "$gdb_xml_files" ; then
 fi
 
 case "$target_arch2" in
-  arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|sparc|sparc64|sparc32plus)
+  arm|armeb|m68k|microblaze|mips|mipsel|mipsn32|mipsn32el|mips64|mips64el|ppc|ppc64|ppc64abi32|ppcemb|s390x|sparc|sparc64|sparc32plus)
     echo "CONFIG_SOFTFLOAT=y" >> $config_target_mak
     ;;
   *)
@@ -2431,6 +2437,8 @@ ldflags=""
 
 if test "$ARCH" = "sparc64" ; then
   cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
+elif test "$ARCH" = "s390x" ; then
+  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
 else
   cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
 fi
@@ -2466,7 +2474,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do
   ppc*)
     echo "CONFIG_PPC_DIS=y"  >> $config_target_mak
   ;;
-  s390)
+  s390*)
     echo "CONFIG_S390_DIS=y"  >> $config_target_mak
   ;;
   sh4)
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/13 S/390 fake TCG implementation

In reply to Alexander Graf

Qemu won't let us run a KVM target without having host TCG support. Well, for now we don't have any so let's implement a fake target that only stubs out everything.

I tried to keep the patch as close to Uli's source as possible, so whenever he feels like it he can easily diff his version against this one.

---
 dyngen-exec.h         |    2 +-
 target-s390x/helper.c |    5 ++
 tcg/s390/tcg-target.c |  103 +++++++++++++++++++++++++++++++++++++++++++++++++
 tcg/s390/tcg-target.h |   48 +++++++++++++++++++++++
 4 files changed, 157 insertions(+), 1 deletions(-)
 create mode 100644 tcg/s390/tcg-target.c
 create mode 100644 tcg/s390/tcg-target.h
dyngen-exec.h +1 -1
index 86e61c3..0353f36 100644
@@ -117,7 +117,7 @@ extern int printf(const char *, ...);
 
 /* The return address may point to the start of the next instruction.
    Subtracting one gets us the call instruction itself.  */
-#if defined(__s390__)
+#if defined(__s390__) && !defined(__s390x__)
 # define GETPC() ((void*)(((unsigned long)__builtin_return_address(0) & 0x7fffffffUL) - 1))
 #elif defined(__arm__)
 /* Thumb return addresses have the low bit set, so we need to subtract two.
target-s390x/helper.c +5 -0
index 4e23b4a..0e222e3 100644
@@ -44,6 +44,11 @@ CPUS390XState *cpu_s390x_init(const char *cpu_model)
     return env;
 }
 
+target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
+{
+    return addr;
+}
+
 void cpu_reset(CPUS390XState *env)
 {
     if (qemu_loglevel_mask(CPU_LOG_RESET)) {
tcg/s390/tcg-target.c new file +103 -0

103 lines not on this page · raw message

tcg/s390/tcg-target.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/13 Add KVM support for S390x

In reply to Alexander Graf

S390x was one of the first platforms that received support for KVM back in the day. Unfortunately until now there hasn't been a qemu implementation that would enable users to actually run guests.

So let's include support for KVM S390x in qemu!

---
 configure          |    4 +-
 target-s390x/kvm.c |  463 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 466 insertions(+), 1 deletions(-)
 create mode 100644 target-s390x/kvm.c
configure +3 -1
index 72a6f91..0e1db51 100755
@@ -1346,6 +1346,8 @@ EOF
             kvm_cflags="$kvm_cflags -I$kerneldir/arch/x86/include"
 	elif test "$cpu" = "ppc" -a -d "$kerneldir/arch/powerpc/include" ; then
 	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/powerpc/include"
+	elif test "$cpu" = "s390x" -a -d "$kerneldir/arch/s390/include" ; then
+	    kvm_cflags="$kvm_cflags -I$kerneldir/arch/s390/include"
         elif test -d "$kerneldir/arch/$cpu/include" ; then
             kvm_cflags="$kvm_cflags -I$kerneldir/arch/$cpu/include"
       fi
@@ -2364,7 +2366,7 @@ case "$target_arch2" in
     fi
 esac
 case "$target_arch2" in
-  i386|x86_64|ppcemb|ppc|ppc64)
+  i386|x86_64|ppcemb|ppc|ppc64|s390x)
     # Make sure the target and host cpus are compatible
     if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
       \( "$target_arch2" = "$cpu" -o \
target-s390x/kvm.c new file +463 -0

463 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/13 Allocate physical memory in low virtual address space

In reply to Alexander Graf

KVM on S390x requires the virtual address space of the guest's RAM to be within the first 256GB.

The general direction I'd like to see KVM on S390 move is that this requirement is losened, but for now that's what we're stuck with.

So let's just hack up qemu_ram_alloc until KVM behaves nicely :-).

---
 exec.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
exec.c +6 -0
index 076d26b..59150d0 100644
@@ -2411,7 +2411,13 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
     size = TARGET_PAGE_ALIGN(size);
     new_block = qemu_malloc(sizeof(*new_block));
 
+#if defined(TARGET_S390) && defined(CONFIG_KVM)
+    /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
+    new_block->host = mmap(0x1000000, size, PROT_EXEC|PROT_READ|PROT_WRITE,
+                           MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+#else
     new_block->host = qemu_vmalloc(size);
+#endif
 #ifdef MADV_MERGEABLE
     madvise(new_block->host, size, MADV_MERGEABLE);
 #endif
Signature · 1 line
1.6.0.2
#6 lore raw

PATCH 6/13 Add support for S390x system emulation

In reply to Alexander Graf

Let's enable the basics for system emulation so we can run virtual machines with KVM!

---
 target-s390x/cpu.h                |  153 ++++++++++++++++++++++++++++++++++++-
 target-s390x/exec.h               |    5 +
 target-s390x/helper.c             |   22 +++++
 target-s390x/machine.c            |   30 +++++++
 4 files changed, 208 insertions(+), 2 deletions(-)
 create mode 100644 default-configs/s390x-softmmu.mak
 create mode 100644 target-s390x/machine.c
default-configs/s390x-softmmu.mak new file +0 -0
new file mode 100644
index 0000000..e69de29
target-s390x/cpu.h +151 -2

175 lines not on this page · raw message

target-s390x/exec.h +5 -0
index 5198359..13dc7dd 100644
@@ -22,9 +22,14 @@
 
 register struct CPUS390XState *env asm(AREG0);
 
+#include "config.h"
 #include "cpu.h"
 #include "exec-all.h"
 
+#if !defined(CONFIG_USER_ONLY)
+#include "softmmu_exec.h"
+#endif /* !defined(CONFIG_USER_ONLY) */
+
 static inline int cpu_has_work(CPUState *env)
 {
     return env->interrupt_request & CPU_INTERRUPT_HARD; // guess
target-s390x/helper.c +22 -0
index 0e222e3..f4c4e04 100644
@@ -27,6 +27,9 @@
 #include "gdbstub.h"
 #include "qemu-common.h"
 
+#include <linux/kvm.h>
+#include "kvm.h"
+
 CPUS390XState *cpu_s390x_init(const char *cpu_model)
 {
     CPUS390XState *env;
@@ -60,3 +63,22 @@ void cpu_reset(CPUS390XState *env)
     /* FIXME: reset vector? */
     tlb_flush(env, 1);
 }
+
+#ifndef CONFIG_USER_ONLY
+
+int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
+                                int mmu_idx, int is_softmmu)
+{
+    target_ulong phys;
+    int prot;
+
+    /* XXX: implement mmu */
+
+    phys = address;
+    prot = PAGE_READ | PAGE_WRITE;
+
+    return tlb_set_page(env, address & TARGET_PAGE_MASK,
+                        phys & TARGET_PAGE_MASK, prot,
+                        mmu_idx, is_softmmu);
+}
+#endif /* CONFIG_USER_ONLY */
target-s390x/machine.c new file +30 -0
new file mode 100644
index 0000000..3e79be6
@@ -0,0 +1,30 @@
+/*
+ * QEMU S390x machine definitions
+ *
+ * Copyright (c) 2009 Alexander Graf <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "hw/hw.h"
+#include "hw/boards.h"
+
+void cpu_save(QEMUFile *f, void *opaque)
+{
+}
+
+int cpu_load(QEMUFile *f, void *opaque, int version_id)
+{
+    return 0;
+}
Signature · 1 line
1.6.0.2
#7 lore raw

Re: [Qemu-devel] [PATCH 06/13] Add support for S390x system emulation

target-s390x/cpu.h line 33

Quoted 9 lines
target-s390x/cpu.h +1 -2
@@ -30,8 +30,7 @@
 
 #include "softfloat.h"
 
-#define NB_MMU_MODES 2 // guess
-#define MMU_USER_IDX 0 // guess
+#define NB_MMU_MODES 2

The fact that you're modifying a file you added earlier in the same patch series gives me very little confidence...

Paul

#8 lore raw

Re: [Qemu-devel] [PATCH 06/13] Add support for S390x system emulation

Quoted 4 lines · Paul Brook
Quoted 4 lines
target-s390x/cpu.h +0 -0
@@ -30,8 +30,7 @@
 
Quoted 8 lines

target-s390x/cpu.h line 33

Quoted 5 lines
target-s390x/cpu.h +1 -2
 #include "softfloat.h"
 
-#define NB_MMU_MODES 2 // guess
-#define MMU_USER_IDX 0 // guess
+#define NB_MMU_MODES 2

The fact that you're modifying a file you added earlier in the same patch series gives me very little confidence...

I tried to keep the later patches as close to what they were in previous version as possible. If you like I can merge the changes, but I figured this makes is easier for review.

Alex

#9 lore raw

PATCH 7/13 Add S390x virtio machine bus

In reply to Alexander Graf

On S390x we don't want to go through the hassle of emulating real existing hardware, because we don't need to for running Linux.

So let's instead implement a machine that is 100% based on VirtIO which we fortunately implement already.

This patch implements the bus that is the groundwork for such an S390x virtio machine.

---
 Makefile.target      |    2 +
 hw/s390-virtio-bus.c |  385 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/s390-virtio-bus.h |   65 +++++++++
 3 files changed, 452 insertions(+), 0 deletions(-)
 create mode 100644 hw/s390-virtio-bus.c
 create mode 100644 hw/s390-virtio-bus.h
Makefile.target +2 -0
index 91aa4a2..2b9f85d 100644
@@ -297,6 +297,8 @@ obj-sh4-y += ide/core.o ide/mmio.o
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
 
+obj-s390x-y = s390-virtio-bus.o
+
 main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
 vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
hw/s390-virtio-bus.c new file +385 -0

385 lines not on this page · raw message

hw/s390-virtio-bus.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#10 lore raw

PATCH 8/13 Add S390x virtio machine description

In reply to Alexander Graf

In order to use the new S390x virtio bus we just introduced, we also need a machine description that sets up the machine according to our PV specification.

Let's add that machine description and be happy!

---
 Makefile.target  |    2 +-
 hw/s390-virtio.c |  243 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 244 insertions(+), 1 deletions(-)
 create mode 100644 hw/s390-virtio.c
Makefile.target +1 -1
index 2b9f85d..d47d879 100644
@@ -297,7 +297,7 @@ obj-sh4-y += ide/core.o ide/mmio.o
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
 
-obj-s390x-y = s390-virtio-bus.o
+obj-s390x-y = s390-virtio-bus.o s390-virtio.o 
 
 main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
hw/s390-virtio.c new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#11 lore raw

PATCH 9/13 S390 GDB stub

In reply to Alexander Graf

In order to debug funny kernel breakages it's always good to have a working gdb stub around.

While Uli's patches don't include one one, I needed one that's at least good enough for 'bt' and some variable examinations during early bootup.

So here it is - the absolute basics to get the qemu gdb stub running with s390x targets.

---
 gdbstub.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
gdbstub.c +52 -0
index 055093f..1ba6ad0 100644
@@ -1348,6 +1348,55 @@ static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
 
     return 8;
 }
+#elif defined (TARGET_S390X)
+
+#define NUM_CORE_REGS S390_NUM_TOTAL_REGS
+
+static int cpu_gdb_read_register(CPUState *env, uint8_t *mem_buf, int n)
+{
+    switch (n) {
+        case S390_PSWM_REGNUM: GET_REGL(env->psw.mask); break;
+        case S390_PSWA_REGNUM: GET_REGL(env->psw.addr); break;
+        case S390_R0_REGNUM ... S390_R15_REGNUM:
+            GET_REGL(env->regs[n-S390_R0_REGNUM]); break;
+        case S390_A0_REGNUM ... S390_A15_REGNUM:
+            GET_REG32(env->aregs[n-S390_A0_REGNUM]); break;
+        case S390_FPC_REGNUM: GET_REG32(env->fpc); break;
+        case S390_F0_REGNUM ... S390_F15_REGNUM:
+            /* XXX */
+            break;
+        case S390_PC_REGNUM: GET_REGL(env->psw.addr); break;
+        case S390_CC_REGNUM: GET_REG32(env->cc); break;
+    }
+
+    return 0;
+}
+
+static int cpu_gdb_write_register(CPUState *env, uint8_t *mem_buf, int n)
+{
+    target_ulong tmpl;
+    uint32_t tmp32;
+    int r = 8;
+    tmpl = ldtul_p(mem_buf);
+    tmp32 = ldl_p(mem_buf);
+
+    switch (n) {
+        case S390_PSWM_REGNUM: env->psw.mask = tmpl; break;
+        case S390_PSWA_REGNUM: env->psw.addr = tmpl; break;
+        case S390_R0_REGNUM ... S390_R15_REGNUM:
+            env->regs[n-S390_R0_REGNUM] = tmpl; break;
+        case S390_A0_REGNUM ... S390_A15_REGNUM:
+            env->aregs[n-S390_A0_REGNUM] = tmp32; r=4; break;
+        case S390_FPC_REGNUM: env->fpc = tmp32; r=4; break;
+        case S390_F0_REGNUM ... S390_F15_REGNUM:
+            /* XXX */
+            break;
+        case S390_PC_REGNUM: env->psw.addr = tmpl; break;
+        case S390_CC_REGNUM: env->cc = tmp32; r=4; break;
+    }
+
+    return r;
+}
 #else
 
 #define NUM_CORE_REGS 0
@@ -1616,6 +1665,9 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)
     s->c_cpu->pc = pc;
 #elif defined (TARGET_ALPHA)
     s->c_cpu->pc = pc;
+#elif defined (TARGET_S390X)
+    cpu_synchronize_state(s->c_cpu);
+    s->c_cpu->psw.addr = pc;
 #endif
 }
 
Signature · 1 line
1.6.0.2
#12 lore raw

PATCH 10/13 Implement early printk in virtio-console

In reply to Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created anyways.

---
 hw/virtio-console.c |    7 +++++++
 hw/virtio-console.h |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
hw/virtio-console.c +7 -0
index 57f8f89..cd6cf20 100644
@@ -105,6 +105,13 @@ static void vcon_event(void *opaque, int event)
     /* we will ignore any event for the time being */
 }
 
+void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf)
+{
+    VirtIOConsole *s = to_virtio_console(vdev);
+
+    qemu_chr_write(s->chr, buf, strlen((char*)buf));
+}
+
 static void virtio_console_save(QEMUFile *f, void *opaque)
 {
     VirtIOConsole *s = opaque;
hw/virtio-console.h +2 -0
index 84d0717..f3ccc3c 100644
@@ -16,4 +16,6 @@
 /* The ID for virtio console */
 #define VIRTIO_ID_CONSOLE 3
 
+void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf);
+
 #endif
Signature · 1 line
1.6.0.2
#13 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 6 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created anyways.

What is this used for?

Quoted 36 lines
---
 hw/virtio-console.c |    7 +++++++
 hw/virtio-console.h |    2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)
hw/virtio-console.c +7 -0
index 57f8f89..cd6cf20 100644
@@ -105,6 +105,13 @@ static void vcon_event(void *opaque, int event)
     /* we will ignore any event for the time being */
 }
 
+void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf)
+{
+    VirtIOConsole *s = to_virtio_console(vdev);
+
+    qemu_chr_write(s->chr, buf, strlen((char*)buf));
+}
+
 static void virtio_console_save(QEMUFile *f, void *opaque)
 {
     VirtIOConsole *s = opaque;
hw/virtio-console.h +2 -0
index 84d0717..f3ccc3c 100644
@@ -16,4 +16,6 @@
 /* The ID for virtio console */
 #define VIRTIO_ID_CONSOLE 3
 
+void virtio_console_print_early(VirtIODevice *vdev, uint8_t *buf);
+
 #endif
#14 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 9 lines · Anthony Liguori
Quoted 6 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created anyways.

What is this used for?

This is used for console output before virtio is initialized. I didn't invent it - that's the way it's implemented in the s390 kernels today.

Alex

#15 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 8 lines · Alexander Graf
Quoted 5 lines · Anthony Liguori
Quoted 3 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

So instead we just forward everything to the virtio console that we created anyways.

What is this used for?

This is used for console output before virtio is initialized. I didn't invent it - that's the way it's implemented in the s390 kernels today.

I don't see any code that calls this function. Am I missing something obvious?

Quoted 1 line

Alex

Regards,

Anthony Liguori

#16 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Alexander Graf
Quoted 8 lines · Anthony Liguori
Quoted 6 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created anyways.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

What is this used for?

This is used for console output before virtio is initialized. I didn't invent it - that's the way it's implemented in the s390 kernels today.

I don't see any code that calls this function. Am I missing something obvious?

It gets called from target-s390x/kvm.c using a special hypercall instruction.

Alex

#17 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 22 lines · Alexander Graf
Quoted 19 lines · Anthony Liguori
Quoted 17 lines · Alexander Graf
Quoted 13 lines · Anthony Liguori
Quoted 7 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

So instead we just forward everything to the virtio console that we created anyways.

What is this used for?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This is used for console output before virtio is initialized. I didn't invent it - that's the way it's implemented in the s390 kernels today.

I don't see any code that calls this function. Am I missing something obvious?

It gets called from target-s390x/kvm.c using a special hypercall instruction.

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

Regards,

Anthony Liguori

Quoted 1 line

Alex

#18 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 24 lines · Anthony Liguori
Quoted 23 lines · Alexander Graf
Quoted 19 lines · Anthony Liguori
Quoted 8 lines · Alexander Graf
Quoted 5 lines · Anthony Liguori
Quoted 3 lines · Alexander Graf

On our S390x Virtio machine we don't have anywhere to display early printks on, because we don't know about VGA or serial ports.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

So instead we just forward everything to the virtio console that we created anyways.

What is this used for?

This is used for console output before virtio is initialized. I didn't invent it - that's the way it's implemented in the s390 kernels today.

I don't see any code that calls this function. Am I missing something obvious?

Quoted 7 lines
Quoted 2 lines

It gets called from target-s390x/kvm.c using a special hypercall instruction.

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

So you want me to implement char muxing and a bootloader within a week? :)

Alex

#19 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 7 lines · Alexander Graf
Quoted 4 lines

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

So you want me to implement char muxing and a bootloader within a week? :)

Char muxing is already there.

Don't know what to do about the bootloader bit. At this point, I'm curious about whether kboot would be a viable solution.

Quoted 1 line

Alex

Regards,

Anthony Liguori

#20 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 10 lines · Anthony Liguori
Quoted 7 lines · Alexander Graf
Quoted 4 lines

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

So you want me to implement char muxing and a bootloader within a week? :)

Char muxing is already there.

Ah :-). I guess I could also just create a separate console. It's only for early printk anyways.

Quoted 1 line

Don't know what to do about the bootloader bit. At this point, I'm curious about whether kboot would be a viable solution.

My opinion would be to leave it as is for now and switch to a real bootloader that runs inside the guest later.

Alex

#21 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

It will be a character device, once the device tree is initialized. Better ideas are welcome, just keep in mind basic things like kmalloc don't work yet.

#22 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 9 lines · Carsten Otte
Quoted 4 lines · Anthony Liguori

Oh, that's bad :-)

That should really be it's own character device. We don't really have a way to connect two character devices like that. Maybe muxing?

It will be a character device, once the device tree is initialized. Better ideas are welcome, just keep in mind basic things like kmalloc don't work yet.

Can't you just leave it out for this release? Early printk is great for debugging, but not essential if you just want to run a guest as long as you get it past the virtio init phase.

	Arnd <><
#23 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

Quoted 3 lines · Arnd Bergmann

Can't you just leave it out for this release? Early printk is great for debugging, but not essential if you just want to run a guest as long as you get it past the virtio init phase.

The upstream kernel assumes to have this hypercall available when running on kvm. You won't get past the virtio init phase if you leave it out for kernels <= 2.6.32.

#24 lore raw

Re: [Qemu-devel] [PATCH 10/13] Implement early printk in virtio-console

In reply to Anthony Liguori
Quoted 1 line · Anthony Liguori

What is this used for?

On x86 the kernel uses bios output for early prints. We don't have bios and do therefore need to bring up a console device as early as possible so that we can see kernel panics during I/O subsystem detection/startup. All s390 console devices do support this function (3215/3270 and ASCII console), and it is used only up to the point when the kernel has its console subsystem ready to run.

#25 lore raw

PATCH 11/13 Set default console to virtio on S390x

In reply to Alexander Graf

All "normal" system emulation targets in qemu I'm aware of display output on either VGA or serial output.

Our S390x virtio machine doesn't have such kind of legacy hardware. So instead we need to default to a virtio console.

I'm not particularly proud of this patch. It would be a lot better to have something in the machine description that tells us about the default terminal.

---
 vl.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
vl.c +26 -0
index c3f3c8f..46d9e01 100644
@@ -4663,6 +4663,20 @@ int main(int argc, char **argv, char **envp)
     cyls = heads = secs = 0;
     translation = BIOS_ATA_TRANSLATION_AUTO;
 
+#ifdef TARGET_S390X
+    for(i = 0; i < MAX_SERIAL_PORTS; i++)
+        serial_devices[i] = NULL;
+    serial_device_index = 0;
+
+    for(i = 0; i < MAX_PARALLEL_PORTS; i++)
+        parallel_devices[i] = NULL;
+    parallel_device_index = 0;
+
+    virtio_consoles[0] = "mon:stdio";
+    for(i = 1; i < MAX_VIRTIO_CONSOLES; i++)
+        virtio_consoles[i] = NULL;
+    virtio_console_index = 0;
+#else
     serial_devices[0] = "vc:80Cx24C";
     for(i = 1; i < MAX_SERIAL_PORTS; i++)
         serial_devices[i] = NULL;
@@ -4676,6 +4690,7 @@ int main(int argc, char **argv, char **envp)
     for(i = 0; i < MAX_VIRTIO_CONSOLES; i++)
         virtio_consoles[i] = NULL;
     virtio_console_index = 0;
+#endif
 
     monitor_devices[0] = "vc:80Cx24C";
     for (i = 1; i < MAX_MONITOR_DEVICES; i++) {
@@ -5587,6 +5602,17 @@ int main(int argc, char **argv, char **envp)
                 break;
             }
         }
+        for (i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
+            const char *devname = virtio_consoles[i];
+            if (devname && !strcmp(devname,"mon:stdio")) {
+                monitor_devices[0] = NULL;
+                break;
+            } else if (devname && !strcmp(devname,"stdio")) {
+                monitor_devices[0] = NULL;
+                virtio_consoles[i] = "mon:stdio";
+                break;
+            }
+        }
     }
 
     if (nb_numa_nodes > 0) {
Signature · 1 line
1.6.0.2
#26 lore raw

PATCH 12/13 Add zipl bootloader interpreter

In reply to Alexander Graf

The default bootloader on S390 is zipl. Because we don't emulate normal S390 hardware we need to write our own parser for the bootloader configuration, so we can boot off real hard disks.

This patch adds a pretty simple implementation of such an interpreter. It only supports 512 bytes sector sizes, always boots the default entry and doesn't work with reboots yet. But it's better than nothing.

---
 Makefile.target    |    2 +-
 hw/s390-virtio.c   |   11 ++-
 hw/s390-zipl.c     |  233 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu.h |    1 +
 4 files changed, 243 insertions(+), 4 deletions(-)
 create mode 100644 hw/s390-zipl.c
Makefile.target +1 -1
index d47d879..e147e09 100644
@@ -297,7 +297,7 @@ obj-sh4-y += ide/core.o ide/mmio.o
 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
 obj-m68k-y += m68k-semi.o dummy_m68k.o
 
-obj-s390x-y = s390-virtio-bus.o s390-virtio.o 
+obj-s390x-y = s390-virtio-bus.o s390-virtio.o s390-zipl.o
 
 main.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
hw/s390-virtio.c +8 -3
index c843e0d..a008c45 100644
@@ -29,6 +29,7 @@
 #include "hw/virtio-console.h"
 #include "hw/sysbus.h"
 #include "kvm.h"
+#include "s390-zipl.h"
 
 #include "hw/s390-virtio-bus.h"
 
@@ -166,6 +167,7 @@ static void s390_init(ram_addr_t _ram_size,
 
     env->halted = 0;
     env->exception_index = 0;
+    cpu_synchronize_state(env);
 
     if (kernel_filename) {
         kernel_size = load_image(kernel_filename, qemu_get_ram_ptr(0));
@@ -175,9 +177,7 @@ static void s390_init(ram_addr_t _ram_size,
             exit(1);
         }
 
-        cpu_synchronize_state(env);
-        env->psw.addr = KERN_IMAGE_START;
-        env->psw.mask = 0x0000000180000000UL;
+        env->reset_addr = KERN_IMAGE_START;
     }
 
     if (initrd_filename) {
@@ -223,7 +223,12 @@ static void s390_init(ram_addr_t _ram_size,
         dev = qdev_create((BusState *)s390_bus, "virtio-blk-s390");
         qdev_prop_set_drive(dev, "drive", dinfo);
         qdev_init_nofail(dev);
+
+        zipl_load(env, dinfo->bdrv);
     }
+
+    env->psw.mask = 0x0000000180000000UL;
+    env->psw.addr = env->reset_addr;
 }
 
 static QEMUMachine s390_machine = {
hw/s390-zipl.c new file +233 -0

233 lines not on this page · raw message

target-s390x/cpu.h +1 -0
index a74745c..2e286c7 100644
@@ -63,6 +63,7 @@ typedef struct CPUS390XState {
     int cc; /* condition code (0-3) */
     
     uint64_t __excp_addr;
+    uint64_t reset_addr;
     
     CPU_COMMON
 } CPUS390XState;
Signature · 1 line
1.6.0.2
#27 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 8 lines · Alexander Graf

The default bootloader on S390 is zipl. Because we don't emulate normal S390 hardware we need to write our own parser for the bootloader configuration, so we can boot off real hard disks.

This patch adds a pretty simple implementation of such an interpreter. It only supports 512 bytes sector sizes, always boots the default entry and doesn't work with reboots yet. But it's better than nothing.

This is a bit unfortunate. Wouldn't it be better to write a custom version of zipl that ran in the guest?

This is like implementing grub in qemu (or pygrub in Xen). The level of security exposure this introduces is really scary.

Regards,

Anthony Liguori

#28 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 11 lines · Anthony Liguori
Quoted 8 lines · Alexander Graf

The default bootloader on S390 is zipl. Because we don't emulate normal S390 hardware we need to write our own parser for the bootloader configuration, so we can boot off real hard disks.

This patch adds a pretty simple implementation of such an interpreter. It only supports 512 bytes sector sizes, always boots the default entry and doesn't work with reboots yet. But it's better than nothing.

This is a bit unfortunate. Wouldn't it be better to write a custom version of zipl that ran in the guest?

Yeah, I've been struggling quite a bit with this myself. Writing a custom version that runs in the guest means we have to create

1) extboot
2) input backdoor

Or implement virtio in that custom version. That sounds like a pretty huge project.

So I decided to go for the easy way for now and hopefully migrate to an in-guest version later.

Alex

#29 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 17 lines · Alexander Graf
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Alexander Graf

The default bootloader on S390 is zipl. Because we don't emulate normal S390 hardware we need to write our own parser for the bootloader configuration, so we can boot off real hard disks.

Quoted 7 lines
Quoted 5 lines

This patch adds a pretty simple implementation of such an interpreter. It only supports 512 bytes sector sizes, always boots the default entry and doesn't work with reboots yet. But it's better than nothing.

This is a bit unfortunate. Wouldn't it be better to write a custom version of zipl that ran in the guest?

Quoted 9 lines

Yeah, I've been struggling quite a bit with this myself. Writing a custom version that runs in the guest means we have to create

1) extboot
2) input backdoor

Or implement virtio in that custom version. That sounds like a pretty huge project.

So I decided to go for the easy way for now and hopefully migrate to an in-guest version later.

Can't you just use kboot?

Use a kernel loader to load the kboot module/initrd, include kboot as our firmware, then let kboot do the magic to launch the real linux kernel from disk.

Regards,

Anthony Liguori

#30 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 22 lines · Anthony Liguori
Quoted 21 lines · Alexander Graf
Quoted 6 lines · Anthony Liguori
Quoted 4 lines · Alexander Graf

The default bootloader on S390 is zipl. Because we don't emulate normal S390 hardware we need to write our own parser for the bootloader configuration, so we can boot off real hard disks.

Quoted 6 lines
Quoted 4 lines

This patch adds a pretty simple implementation of such an interpreter. It only supports 512 bytes sector sizes, always boots the default entry and doesn't work with reboots yet. But it's better than nothing.

This is a bit unfortunate. Wouldn't it be better to write a custom version of zipl that ran in the guest?

Yeah, I've been struggling quite a bit with this myself. Writing a custom version that runs in the guest means we have to create

1) extboot
2) input backdoor

Quoted 8 lines
Quoted 4 lines

Or implement virtio in that custom version. That sounds like a pretty huge project.

So I decided to go for the easy way for now and hopefully migrate to an in-guest version later.

Can't you just use kboot?

Use a kernel loader to load the kboot module/initrd, include kboot as our firmware, then let kboot do the magic to launch the real linux kernel from disk.

Hm, so we'd have to rely on kexec working properly? I've seen how badly that turned out on the PS3. I guess I'd rather write a virtio implementation :-).

Alex

#31 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 9 lines
Quoted 5 lines

Can't you just use kboot?

Use a kernel loader to load the kboot module/initrd, include kboot as our firmware, then let kboot do the magic to launch the real linux kernel from disk.

Hm, so we'd have to rely on kexec working properly? I've seen how badly
that turned out on the PS3. I guess I'd rather write a virtio implementation :-).

Way back in the mists of time (uh, something like that 2004-05) I had some discussions with some of the S390 people about using kboot for more flexible boot, since it tallied with their interests. Although at that point I had the impression that zipl was restricted to only one boot option anyhow, so if it can now choose from a list then maybe they just enhanced what they had.

Anthony, you might remember these discussions? I don't know if they went anywhere with it.

Cheers,
Mark

#32 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Hi Mark!

Quoted 4 lines · Mark Williamson

Way back in the mists of time (uh, something like that 2004-05) I had some discussions with some of the S390 people about using kboot for more flexible boot, since it tallied with their interests. Although at that point I had the impression that zipl was restricted to only one boot option anyhow, so if it can now choose from a list then maybe they just enhanced what they had.

Anthony, you might remember these discussions? I don't know if they went anywhere with it.

I do, that's why I brought it up. AFAICT, there hasn't been a lot of progress with kboot. Carsten or Alex would probably know better if anyone is actually using it on s390s.

Regards,

Anthony Liguori

Quoted 3 lines

Cheers,
Mark

#33 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 10 lines · Anthony Liguori

Hi Mark!

Quoted 7 lines · Mark Williamson

Way back in the mists of time (uh, something like that 2004-05) I had some discussions with some of the S390 people about using kboot for more flexible boot, since it tallied with their interests. Although at that point I had the impression that zipl was restricted to only one boot option anyhow, so if it can now choose from a list then maybe they just enhanced what they had.

Quoted 8 lines
Quoted 3 lines

Anthony, you might remember these discussions? I don't know if they went anywhere with it.

I do, that's why I brought it up. AFAICT, there hasn't been a lot of progress with kboot. Carsten or Alex would probably know better if anyone is actually using it on s390s.

No, not to my knowledge.

There have been some discussion as if kboot would be beneficial here, but especially for s390 it doesn't make a lot of sense.

kboot is okay for scenarios where you have a _lot_ of modules in the default kernel, but need only a very small subset to get the system bootstrapped. Then you can built a kboot kernel with the driver subset for bootstrapping and have that loading the 'normal' kernel which then loads all remaining modules.

If you have (like s390) only about 8 driver modules to care about it's pretty much pointless as the kboot kernel will have the same configuration than the normal kernel. So you'll end up with loading the same kernel twice.

And won't change the situation here, as you still have to do the initial bootstrap somehow. And as this should be quite close to the original system you'll end up having to support zipl anyway.

So back to the zipl question, it might be an idea to support initially the SCSI disk layout only. This has the advantage of being far simpler as the DASD disk layout and should be pretty straightforward to handle.

But that's me talking with no real knowledge of qemu bootstrap internals.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N�rnberg
GF: Markus Rex, HRB 16746 (AG N�rnberg)
#34 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

Quoted 15 lines · Hannes Reinecke
Quoted 14 lines · Anthony Liguori

Hi Mark!

Quoted 10 lines · Mark Williamson

Way back in the mists of time (uh, something like that 2004-05) I had some discussions with some of the S390 people about using kboot for more flexible boot, since it tallied with their interests. Although at that point I had the impression that zipl was restricted to only one boot option anyhow, so if it can now choose from a list then maybe they just enhanced what they had.

Anthony, you might remember these discussions? I don't know if they went anywhere with it.

Quoted 8 lines
Quoted 4 lines

I do, that's why I brought it up. AFAICT, there hasn't been a lot of progress with kboot. Carsten or Alex would probably know better if anyone is actually using it on s390s.

No, not to my knowledge.

There have been some discussion as if kboot would be beneficial here, but especially for s390 it doesn't make a lot of sense.

Thanks for clarifying this!

Quoted 6 lines

kboot is okay for scenarios where you have a _lot_ of modules in the default kernel, but need only a very small subset to get the system bootstrapped. Then you can built a kboot kernel with the driver subset for bootstrapping and have that loading the 'normal' kernel which then loads all remaining modules.

Quoted 7 lines

If you have (like s390) only about 8 driver modules to care about it's pretty much pointless as the kboot kernel will have the same configuration than the normal kernel. So you'll end up with loading the same kernel twice.

And won't change the situation here, as you still have to do the initial bootstrap somehow. And as this should be quite close to the original system you'll end up having to support zipl anyway.

Yes, you'd basically end up writing a zipl interpreter inside the initrd of kboot. Bleks.

Quoted 3 lines

So back to the zipl question, it might be an idea to support initially the SCSI disk layout only. This has the advantage of being far simpler as the DASD disk layout and should be pretty straightforward to handle.

That's exactly what my zipl patch does. DASD has 4k sector sizes, so DASD layouts are not supported. Fortunately virtio in qemu only exports 512 bytes sector sizes for now, so when you install the VM onto virtio, you're good.

Alex

#35 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

In reply to Hannes Reinecke
Quoted 3 lines · Hannes Reinecke

So back to the zipl question, it might be an idea to support initially the SCSI disk layout only. This has the advantage of being far simpler as the DASD disk layout and should be pretty straightforward to handle.

Issue is, the dasd disk layout is made for dasds. For eckd, the boot code assumes variable blocksize, and the loader uses channel programs. For both eckd and fba volumes, it assumes IBM disklabels and FICON channel programs. Virt-IO disks do have an msdos-style partition table as opposed to this.
That said, you'd need proper virtualiztion of a ficon dasd so that the guest could possibly run the dasd boot code. Virt-IO disks otoh are fixed block, have an msdos-style partition table, no channel programs, and thus look just like scsi disks with a different interface. Therefore, I think scsi boot is right for virt-IO disks. And zipl does already create this layout in the version found in Sles11 and FC12.

#36 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

In reply to Anthony Liguori
Quoted 1 line · Anthony Liguori

I do, that's why I brought it up. AFAICT, there hasn't been a lot of progress with kboot. Carsten or Alex would probably know better if anyone is actually using it on s390s.

I fail to see how kboot would solve this problem.

#37 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

Can't you just use kboot?

Use a kernel loader to load the kboot module/initrd, include kboot as our firmware, then let kboot do the magic to launch the real linux kernel from disk.

Hehe, and how would you load that initial kernel if you don't have bios?
No matter what, you do need a form of initial loading. And doing it the architected way is just plain right.

#38 lore raw

Re: [Qemu-devel] [PATCH 12/13] Add zipl bootloader interpreter

In reply to Anthony Liguori
Quoted 3 lines · Anthony Liguori

This is a bit unfortunate. Wouldn't it be better to write a custom version of zipl that ran in the guest?

This is like implementing grub in qemu (or pygrub in Xen). The level of security exposure this introduces is really scary.

Oh that's really the wrong way to see it. We don't have bios, and therefore we need _some_ functionality to start up initial code on the disk. The interface that Alex is implementing is also used by the real hardware to load from disk in case a scsi/fcp volume is used, and it is part of the published machine architecture. That's very unlike grub.

#39 lore raw

PATCH 13/13 Add S390 maintainer information

In reply to Alexander Graf

This patch adds information about who handles what when it comes to S390. I'll gladly support anything that's related to the device emulation model and S390 KVM parts.

Since this patchset doesn't implement S390 CPU emulation, I left that part with a question mark. As soon as Uli's patchset gets committed I'd recommend setting him there.

---
 MAINTAINERS |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
MAINTAINERS +3 -0
index d356495..56f107e 100644
@@ -20,6 +20,7 @@ SH4                ?
 CRIS               Edgar E. Iglesias
 Alpha              ?
 MicroBlaze         Edgar E. Iglesias
+S390               ?
 
 Machines (sorted by CPU):
 -------------------------
@@ -63,6 +64,8 @@ CRIS
 Alpha
 MicroBlaze
   petalogix_s3adsp1800.c  Edgar E. Iglesias
+S390
+  s390-*.c                Alexander Graf
 
 Generic Subsystems:
 -------------------  
Signature · 1 line
1.6.0.2