Skip to contentSkip to conversation

S390x KVM support v5

PATCH New Alexander Graf 1 participant 12 messages Dec 5, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover S390x KVM support v5

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!

Also reset functionality is missing. It'd need to be rewritten once we get a firmware anyways, so there's no point in implementing anything 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

v4 -> v5:

- remove zipl loader
- remove early printk

v5 -> v6:

- make SMP work
- fix typos
- fix coding style (bleks)
- fail on non-virtio nics
- use more constants (vs magic numbers)
- don't use _... function names
- move cpu_get_phys_page_debug to correct patch
- add register defines
- use __builtin___clear_cache

Alexander Graf (11):
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
Set default console to virtio on S390x
Add S390 maintainer information

 MAINTAINERS                       |    3 +
 Makefile.target                   |    2 +
 configure                         |   29 ++-
 cpu-exec.c                        |    2 +
 dyngen-exec.h                     |    2 +-
 exec.c                            |    6 +
 gdbstub.c                         |   52 ++++
 hw/s390-virtio-bus.c              |  395 ++++++++++++++++++++++++++++++
 hw/s390-virtio-bus.h              |   65 +++++
 hw/s390-virtio.c                  |  255 ++++++++++++++++++++
 target-s390x/cpu.h                |  271 +++++++++++++++++++++
 target-s390x/exec.h               |   56 +++++
 target-s390x/helper.c             |   84 +++++++
 target-s390x/kvm.c                |  482 +++++++++++++++++++++++++++++++++++++
 target-s390x/machine.c            |   30 +++
 target-s390x/op_helper.c          |   74 ++++++
 target-s390x/translate.c          |   63 +++++
 tcg/s390/tcg-target.c             |  105 ++++++++
 tcg/s390/tcg-target.h             |   69 ++++++
 vl.c                              |   26 ++
 20 files changed, 2062 insertions(+), 9 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 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/11 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.

---

v5 -> v6:

- add comment for asce register requirement
- move cpu_get_phys_page_debug
- coding style

---
 cpu-exec.c               |    2 +
 target-s390x/cpu.h       |  122 ++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/exec.h      |   51 +++++++++++++++++++
 target-s390x/helper.c    |   62 +++++++++++++++++++++++
 target-s390x/op_helper.c |   74 ++++++++++++++++++++++++++++
 target-s390x/translate.c |   63 ++++++++++++++++++++++++
 6 files changed, 374 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 +122 -0

122 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 +62 -0

62 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 +63 -0

63 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#2 lore raw

PATCH 2/11 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 |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
configure +18 -7
index cab0ed4..77c3ec1 100755
@@ -183,9 +183,12 @@ case "$cpu" in
   mips*)
     cpu="mips"
   ;;
-  s390*)
+  s390)
     cpu="s390"
   ;;
+  s390x)
+    cpu="s390x"
+  ;;
   sparc|sun4[cdmuv])
     cpu="sparc"
   ;;
@@ -881,7 +884,7 @@ else
 
 # if cross compiling, cannot launch a program, so make a static guess
 case "$cpu" in
-  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|sparc|sparc64)
+  armv4b|hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
     bigendian=yes
   ;;
 esac
@@ -891,7 +894,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
@@ -1901,7 +1904,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)
@@ -2188,7 +2191,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
@@ -2356,6 +2359,12 @@ case "$target_arch2" in
     echo "TARGET_ABI32=y" >> $config_target_mak
     target_phys_bits=64
   ;;
+  s390x)
+    target_phys_bits=64
+  ;;
+  s390x)
+    target_phys_bits=64
+  ;;
   *)
     echo "Unsupported target CPU"
     exit 1
@@ -2424,7 +2433,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
     ;;
   *)
@@ -2457,6 +2466,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
@@ -2492,7 +2503,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/11 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.

---

v5 -> v6:

- remove cpu_get_phys_page_debug
- add register defines
- use __builtin___clear_cache
- add comment on non-tcg_abort'ed functions

---
 dyngen-exec.h         |    2 +-
 tcg/s390/tcg-target.c |  105 +++++++++++++++++++++++++++++++++++++++++++++++++
 tcg/s390/tcg-target.h |   69 ++++++++++++++++++++++++++++++++
 3 files changed, 175 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.
tcg/s390/tcg-target.c new file +105 -0

105 lines not on this page · raw message

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

69 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/11 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!

---

v5 -> v6:

- use constants for sclp commands (kvm.c)
- change _kvm... to kvm_..._internal
- coding style

---
 configure          |    4 +-
 target-s390x/kvm.c |  482 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 485 insertions(+), 1 deletions(-)
 create mode 100644 target-s390x/kvm.c
configure +3 -1
index 77c3ec1..b944e49 100755
@@ -1377,6 +1377,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
@@ -2393,7 +2395,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 +482 -0

482 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/11 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 :-).

---

v5 -> v6:

- correct typo

---
 exec.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
exec.c +6 -0
index eb1ee51..7b7fb5b 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_S390X) && defined(CONFIG_KVM)
+    /* XXX S390 KVM requires the topmost vma of the RAM to be < 256GB */
+    new_block->host = mmap((void*)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/11 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 4a198ae..4c2dc82 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

PATCH 7/11 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.

---

v5 -> v6:

- coding style

---
 Makefile.target      |    2 +
 hw/s390-virtio-bus.c |  395 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/s390-virtio-bus.h |   65 ++++++++
 3 files changed, 462 insertions(+), 0 deletions(-)
 create mode 100644 hw/s390-virtio-bus.c
 create mode 100644 hw/s390-virtio-bus.h
Makefile.target +2 -0
index 891ea08..725cbeb 100644
@@ -293,6 +293,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 +395 -0

395 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
#8 lore raw

PATCH 8/11 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!

---

v4 -> v5

- disable early console

v5 -> v6:

- make SMP work (use CPU 0 as CPU 0)
- fix typo "allicate"
- fail on non-virtio nics
- coding style

---
 Makefile.target  |    2 +-
 hw/s390-virtio.c |  255 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 256 insertions(+), 1 deletions(-)
 create mode 100644 hw/s390-virtio.c
Makefile.target +1 -1
index 725cbeb..7c1f30c 100644
@@ -293,7 +293,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 +255 -0

255 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#9 lore raw

PATCH 9/11 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 5a4f7d4..5320b1c 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
#10 lore raw

PATCH 10/11 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 1981e6e..09a0ec5 100644
@@ -4711,6 +4711,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;
@@ -4724,6 +4738,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";
     monitor_flags[0] = MONITOR_IS_DEFAULT | MONITOR_USE_READLINE;
@@ -5640,6 +5655,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
#11 lore raw

PATCH 11/11 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