qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26
@ 2013-04-26 18:19 Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 01/24] S390: Make IPL reset address dynamic Alexander Graf
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

Hi Blue / Aurelien,

This is my current patch queue for s390.  Please pull.

Alex


The following changes since commit bf9b255f484fd61cbaa91faeff254140a0ecd18c:
  Anthony Liguori (1):
        gtk: refactor menu creation

are available in the git repository at:

  git://github.com/agraf/qemu.git s390-for-upstream

Alexander Graf (12):
      S390: Make IPL reset address dynamic
      S390: IPL: Support ELF firmware
      S390: IPL: Use different firmware for different machines
      S390: ccw firmware: Add start assembly
      S390: ccw firmware: Add main program
      S390: ccw firmware: Add sclp output
      S390: ccw firmware: Add virtio device drivers
      S390: ccw firmware: Add glue header
      S390: ccw firmware: Add bootmap interpreter
      S390: ccw firmware: Add Makefile
      S390: ccw firmware: Add compiled blob
      S390: CCW: Use new, working firmware by default

Christian Borntraeger (4):
      s390-ccw.img: replace while loop with a disabled wait on s390 bios
      s390-ccw.img: build s390-ccw rom on s3900 system by default
      s390-ccw.img: Take care of the elf->img transition
      s390-ccw.img: Fix compile warning in s390 ccw virtio code

Cornelia Huck (4):
      s390-ccw.img: Detect devices with stsch.
      s390-ccw.img: Enhance drain_irqs().
      s390-ccw.img: Rudimentary error checking.
      s390-ccw.img: Get queue config from host.

Dominik Dingel (1):
      Common: Add quick access to first boot device

Jason J. Herne (2):
      Allow selective runtime register synchronization
      Utilize selective runtime reg sync for hot code paths

KONRAD Frederic (1):
      virtio-rng-s390: add properties.

 .gitignore                    |    2 +
 Makefile                      |    1 +
 configure                     |    7 +-
 hw/s390x/ipl.c                |   41 +++---
 hw/s390x/s390-virtio-bus.c    |    8 +
 hw/s390x/s390-virtio-ccw.c    |    2 +-
 hw/s390x/s390-virtio.c        |    7 +-
 hw/s390x/s390-virtio.h        |    3 +-
 include/sysemu/sysemu.h       |    2 +
 pc-bios/s390-ccw.img          |  Bin 0 -> 9432 bytes
 pc-bios/s390-ccw/Makefile     |   26 ++++
 pc-bios/s390-ccw/bootmap.c    |  235 ++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/cio.h        |  322 +++++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/main.c       |   61 ++++++++
 pc-bios/s390-ccw/s390-ccw.h   |  134 +++++++++++++++++
 pc-bios/s390-ccw/sclp-ascii.c |   81 ++++++++++
 pc-bios/s390-ccw/sclp.h       |  107 ++++++++++++++
 pc-bios/s390-ccw/start.S      |   31 ++++
 pc-bios/s390-ccw/virtio.c     |  298 ++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.h     |  163 +++++++++++++++++++++
 target-s390x/cpu.h            |   17 ++
 target-s390x/kvm.c            |   82 ++++++++++-
 vl.c                          |   18 +++
 23 files changed, 1622 insertions(+), 26 deletions(-)
 create mode 100644 pc-bios/s390-ccw.img
 create mode 100644 pc-bios/s390-ccw/Makefile
 create mode 100644 pc-bios/s390-ccw/bootmap.c
 create mode 100644 pc-bios/s390-ccw/cio.h
 create mode 100644 pc-bios/s390-ccw/main.c
 create mode 100644 pc-bios/s390-ccw/s390-ccw.h
 create mode 100644 pc-bios/s390-ccw/sclp-ascii.c
 create mode 100644 pc-bios/s390-ccw/sclp.h
 create mode 100644 pc-bios/s390-ccw/start.S
 create mode 100644 pc-bios/s390-ccw/virtio.c
 create mode 100644 pc-bios/s390-ccw/virtio.h

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 01/24] S390: Make IPL reset address dynamic
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 02/24] S390: IPL: Support ELF firmware Alexander Graf
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

We can have different load addresses for different blobs we boot with.
Make the reset IP dynamic, so that we can handle things more flexibly.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/s390x/ipl.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 206d552..c43dfcd 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -48,8 +48,9 @@ typedef struct S390IPLClass {
 typedef struct S390IPLState {
     /*< private >*/
     SysBusDevice parent_obj;
-    /*< public >*/
+    uint64_t start_addr;
 
+    /*< public >*/
     char *kernel;
     char *initrd;
     char *cmdline;
@@ -82,6 +83,7 @@ static int s390_ipl_init(SysBusDevice *dev)
 
         bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START, 4096);
+        ipl->start_addr = ZIPL_IMAGE_START;
         g_free(bios_filename);
 
         if ((long)bios_size < 0) {
@@ -104,6 +106,13 @@ static int s390_ipl_init(SysBusDevice *dev)
         }
         /* we have to overwrite values in the kernel image, which are "rom" */
         strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
+
+        /*
+         * we can not rely on the ELF entry point, since up to 3.2 this
+         * value was 0x800 (the SALIPL loader) and it wont work. For
+         * all (Linux) cases 0x10000 (KERN_IMAGE_START) should be fine.
+         */
+        ipl->start_addr = KERN_IMAGE_START;
     }
     if (ipl->initrd) {
         ram_addr_t initrd_offset, initrd_size;
@@ -138,16 +147,7 @@ static void s390_ipl_reset(DeviceState *dev)
 {
     S390IPLState *ipl = S390_IPL(dev);
 
-    if (ipl->kernel) {
-        /*
-         * we can not rely on the ELF entry point, since up to 3.2 this
-         * value was 0x800 (the SALIPL loader) and it wont work. For
-         * all (Linux) cases 0x10000 (KERN_IMAGE_START) should be fine.
-         */
-        return s390_ipl_cpu(KERN_IMAGE_START);
-    } else {
-        return s390_ipl_cpu(ZIPL_IMAGE_START);
-    }
+    s390_ipl_cpu(ipl->start_addr);
 }
 
 static void s390_ipl_class_init(ObjectClass *klass, void *data)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 02/24] S390: IPL: Support ELF firmware
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 01/24] S390: Make IPL reset address dynamic Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 03/24] S390: IPL: Use different firmware for different machines Alexander Graf
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

Our firmware blob is always a raw file that we load at a fixed address today.
Support loading an ELF blob instead that we can map high up in memory.

This way we don't have to be so conscious about size constraints.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/s390x/ipl.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index c43dfcd..d1f7acd 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -82,17 +82,21 @@ static int s390_ipl_init(SysBusDevice *dev)
         }
 
         bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
-        bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START, 4096);
-        ipl->start_addr = ZIPL_IMAGE_START;
+        bios_size = load_elf(bios_filename, NULL, NULL, &ipl->start_addr, NULL,
+                             NULL, 1, ELF_MACHINE, 0);
+        if (bios_size == -1UL) {
+            bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START,
+                                            4096);
+            ipl->start_addr = ZIPL_IMAGE_START;
+            if (bios_size > 4096) {
+                hw_error("stage1 bootloader is > 4k\n");
+            }
+        }
         g_free(bios_filename);
 
         if ((long)bios_size < 0) {
             hw_error("could not load bootloader '%s'\n", bios_name);
         }
-
-        if (bios_size > 4096) {
-            hw_error("stage1 bootloader is > 4k\n");
-        }
         return 0;
     } else {
         kernel_size = load_elf(ipl->kernel, NULL, NULL, NULL, NULL,
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 03/24] S390: IPL: Use different firmware for different machines
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 01/24] S390: Make IPL reset address dynamic Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 02/24] S390: IPL: Support ELF firmware Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 04/24] S390: ccw firmware: Add start assembly Alexander Graf
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

We have a virtio-s390 and a virtio-ccw machine in QEMU. Both use vastly
different ways to do I/O. Having the same firmware blob for both doesn't
really make any sense.

Instead, let's parametrize the firmware file name, so that we can have
different blobs for different machines.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/s390x/ipl.c             |    5 +++--
 hw/s390x/s390-virtio-ccw.c |    2 +-
 hw/s390x/s390-virtio.c     |    7 +++++--
 hw/s390x/s390-virtio.h     |    3 ++-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index d1f7acd..ace5ff5 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -23,7 +23,6 @@
 #define INITRD_PARM_START               0x010408UL
 #define INITRD_PARM_SIZE                0x010410UL
 #define PARMFILE_START                  0x001000UL
-#define ZIPL_FILENAME                   "s390-zipl.rom"
 #define ZIPL_IMAGE_START                0x009000UL
 #define IPL_PSW_MASK                    (PSW_MASK_32 | PSW_MASK_64)
 
@@ -54,6 +53,7 @@ typedef struct S390IPLState {
     char *kernel;
     char *initrd;
     char *cmdline;
+    char *firmware;
 } S390IPLState;
 
 
@@ -78,7 +78,7 @@ static int s390_ipl_init(SysBusDevice *dev)
 
         /* Load zipl bootloader */
         if (bios_name == NULL) {
-            bios_name = ZIPL_FILENAME;
+            bios_name = ipl->firmware;
         }
 
         bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
@@ -144,6 +144,7 @@ static Property s390_ipl_properties[] = {
     DEFINE_PROP_STRING("kernel", S390IPLState, kernel),
     DEFINE_PROP_STRING("initrd", S390IPLState, initrd),
     DEFINE_PROP_STRING("cmdline", S390IPLState, cmdline),
+    DEFINE_PROP_STRING("firmware", S390IPLState, firmware),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index a49e440..8ea193e 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -83,7 +83,7 @@ static void ccw_init(QEMUMachineInitArgs *args)
     css_bus = virtual_css_bus_init();
     s390_sclp_init();
     s390_init_ipl_dev(args->kernel_filename, args->kernel_cmdline,
-                      args->initrd_filename);
+                      args->initrd_filename, "s390-zipl.rom");
 
     /* register hypercalls */
     virtio_ccw_register_hcalls();
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 46aec99..30d1118 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -49,6 +49,7 @@
 #endif
 
 #define MAX_BLK_DEVS                    10
+#define ZIPL_FILENAME                   "s390-zipl.rom"
 
 static VirtIOS390Bus *s390_bus;
 static S390CPU **ipi_states;
@@ -158,7 +159,8 @@ unsigned s390_del_running_cpu(S390CPU *cpu)
 
 void s390_init_ipl_dev(const char *kernel_filename,
                        const char *kernel_cmdline,
-                       const char *initrd_filename)
+                       const char *initrd_filename,
+                       const char *firmware)
 {
     DeviceState *dev;
 
@@ -170,6 +172,7 @@ void s390_init_ipl_dev(const char *kernel_filename,
         qdev_prop_set_string(dev, "initrd", initrd_filename);
     }
     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
+    qdev_prop_set_string(dev, "firmware", firmware);
     qdev_init_nofail(dev);
 }
 
@@ -247,7 +250,7 @@ static void s390_init(QEMUMachineInitArgs *args)
     s390_bus = s390_virtio_bus_init(&my_ram_size);
     s390_sclp_init();
     s390_init_ipl_dev(args->kernel_filename, args->kernel_cmdline,
-                      args->initrd_filename);
+                      args->initrd_filename, ZIPL_FILENAME);
 
     /* register hypercalls */
     s390_virtio_register_hcalls();
diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h
index a6c4c19..5c405e7 100644
--- a/hw/s390x/s390-virtio.h
+++ b/hw/s390x/s390-virtio.h
@@ -23,6 +23,7 @@ void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
 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 *initrd_filename,
+                       const char *firmware);
 void s390_create_virtio_net(BusState *bus, const char *name);
 #endif
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 04/24] S390: ccw firmware: Add start assembly
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (2 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 03/24] S390: IPL: Use different firmware for different machines Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 05/24] S390: ccw firmware: Add main program Alexander Graf
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

We want to write most of our code in C, so add a small assembly
stub that jumps straight into C code for us to continue booting.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/start.S |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/start.S

diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
new file mode 100644
index 0000000..c2b9a19
--- /dev/null
+++ b/pc-bios/s390-ccw/start.S
@@ -0,0 +1,16 @@
+/*
+ * First stage boot loader for virtio devices. The compiled output goes
+ * into the pc-bios directory of qemu.
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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.
+ */
+
+        .globl _start
+_start:
+
+larl	%r15, stack + 0x8000    /* Set up stack */
+j	main                    /* And call C */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 05/24] S390: ccw firmware: Add main program
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (3 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 04/24] S390: ccw firmware: Add start assembly Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 06/24] S390: ccw firmware: Add sclp output Alexander Graf
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

This C file is the main driving piece of the s390 ccw firmware. It
provides a search for a workable block device, sets it as the default
to boot off of and boots from it.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/main.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/main.c

diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
new file mode 100644
index 0000000..0913aac
--- /dev/null
+++ b/pc-bios/s390-ccw/main.c
@@ -0,0 +1,56 @@
+/*
+ * S390 virtio-ccw loading program
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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.
+ */
+
+#include "s390-ccw.h"
+
+struct subchannel_id blk_schid;
+char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
+
+void virtio_panic(const char *string)
+{
+    sclp_print(string);
+    while (1) { }
+}
+
+static void virtio_setup(void)
+{
+    struct irb irb;
+    int i;
+    int r;
+    bool found = false;
+
+    blk_schid.one = 1;
+
+    for (i = 0; i < 0x10000; i++) {
+        blk_schid.sch_no = i;
+        r = tsch(blk_schid, &irb);
+        if (r != 3) {
+            if (virtio_is_blk(blk_schid)) {
+                found = true;
+                break;
+            }
+        }
+    }
+
+    if (!found) {
+        virtio_panic("No virtio-blk device found!\n");
+    }
+
+    virtio_setup_block(blk_schid);
+}
+
+int main(void)
+{
+    sclp_setup();
+    virtio_setup();
+    if (zipl_load() < 0)
+        sclp_print("Failed to load OS from hard disk\n");
+    while (1) { }
+}
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 06/24] S390: ccw firmware: Add sclp output
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (4 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 05/24] S390: ccw firmware: Add main program Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 07/24] S390: ccw firmware: Add virtio device drivers Alexander Graf
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

In order to communicate with the user, we need an I/O mechanism that he
can read. Implement SCLP ASCII support, which happens to be the default
in the s390 ccw machine.

This file is missing read support for now. It can only print messages.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/sclp-ascii.c |   81 +++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/sclp.h       |  107 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 188 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/sclp-ascii.c
 create mode 100644 pc-bios/s390-ccw/sclp.h

diff --git a/pc-bios/s390-ccw/sclp-ascii.c b/pc-bios/s390-ccw/sclp-ascii.c
new file mode 100644
index 0000000..1c93937
--- /dev/null
+++ b/pc-bios/s390-ccw/sclp-ascii.c
@@ -0,0 +1,81 @@
+/*
+ * SCLP ASCII access driver
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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.
+ */
+
+#include "s390-ccw.h"
+#include "sclp.h"
+
+static char _sccb[PAGE_SIZE] __attribute__((__aligned__(4096)));
+
+/* Perform service call. Return 0 on success, non-zero otherwise. */
+static int sclp_service_call(unsigned int command, void *sccb)
+{
+        int cc;
+
+        asm volatile(
+                "       .insn   rre,0xb2200000,%1,%2\n"  /* servc %1,%2 */
+                "       ipm     %0\n"
+                "       srl     %0,28"
+                : "=&d" (cc) : "d" (command), "a" (__pa(sccb))
+                : "cc", "memory");
+        if (cc == 3)
+                return -EIO;
+        if (cc == 2)
+                return -EBUSY;
+        return 0;
+}
+
+static void sclp_set_write_mask(void)
+{
+    WriteEventMask *sccb = (void*)_sccb;
+
+    sccb->h.length = sizeof(WriteEventMask);
+    sccb->mask_length = sizeof(unsigned int);
+    sccb->receive_mask = SCLP_EVENT_MASK_MSG_ASCII;
+    sccb->cp_receive_mask = SCLP_EVENT_MASK_MSG_ASCII;
+    sccb->send_mask = SCLP_EVENT_MASK_MSG_ASCII;
+    sccb->cp_send_mask = SCLP_EVENT_MASK_MSG_ASCII;
+
+    sclp_service_call(SCLP_CMD_WRITE_EVENT_MASK, sccb);
+}
+
+void sclp_setup(void)
+{
+    sclp_set_write_mask();
+}
+
+static int _strlen(const char *str)
+{
+    int i;
+    for (i = 0; *str; i++)
+        str++;
+    return i;
+}
+
+static void _memcpy(char *dest, const char *src, int len)
+{
+    int i;
+    for (i = 0; i < len; i++)
+        dest[i] = src[i];
+}
+
+void sclp_print(const char *str)
+{
+    int len = _strlen(str);
+    WriteEventData *sccb = (void*)_sccb;
+
+    sccb->h.length = sizeof(WriteEventData) + len;
+    sccb->h.function_code = SCLP_FC_NORMAL_WRITE;
+    sccb->ebh.length = sizeof(EventBufferHeader) + len;
+    sccb->ebh.type = SCLP_EVENT_ASCII_CONSOLE_DATA;
+    sccb->ebh.flags = 0;
+    _memcpy(sccb->data, str, len);
+
+    sclp_service_call(SCLP_CMD_WRITE_EVENT_DATA, sccb);
+}
diff --git a/pc-bios/s390-ccw/sclp.h b/pc-bios/s390-ccw/sclp.h
new file mode 100644
index 0000000..3cbfb78
--- /dev/null
+++ b/pc-bios/s390-ccw/sclp.h
@@ -0,0 +1,107 @@
+/*
+ * SCLP ASCII access driver
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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 SCLP_H
+#define SCLP_H
+
+/* SCLP command codes */
+#define SCLP_CMDW_READ_SCP_INFO                 0x00020001
+#define SCLP_CMDW_READ_SCP_INFO_FORCED          0x00120001
+#define SCLP_CMD_READ_EVENT_DATA                0x00770005
+#define SCLP_CMD_WRITE_EVENT_DATA               0x00760005
+#define SCLP_CMD_READ_EVENT_DATA                0x00770005
+#define SCLP_CMD_WRITE_EVENT_DATA               0x00760005
+#define SCLP_CMD_WRITE_EVENT_MASK               0x00780005
+
+/* SCLP response codes */
+#define SCLP_RC_NORMAL_READ_COMPLETION          0x0010
+#define SCLP_RC_NORMAL_COMPLETION               0x0020
+#define SCLP_RC_INVALID_SCLP_COMMAND            0x01f0
+#define SCLP_RC_CONTAINED_EQUIPMENT_CHECK       0x0340
+#define SCLP_RC_INSUFFICIENT_SCCB_LENGTH        0x0300
+#define SCLP_RC_INVALID_FUNCTION                0x40f0
+#define SCLP_RC_NO_EVENT_BUFFERS_STORED         0x60f0
+#define SCLP_RC_INVALID_SELECTION_MASK          0x70f0
+#define SCLP_RC_INCONSISTENT_LENGTHS            0x72f0
+#define SCLP_RC_EVENT_BUFFER_SYNTAX_ERROR       0x73f0
+#define SCLP_RC_INVALID_MASK_LENGTH             0x74f0
+
+/* Service Call Control Block (SCCB) and its elements */
+
+#define SCCB_SIZE 4096
+
+#define SCLP_VARIABLE_LENGTH_RESPONSE           0x80
+#define SCLP_EVENT_BUFFER_ACCEPTED              0x80
+
+#define SCLP_FC_NORMAL_WRITE                    0
+
+typedef struct SCCBHeader {
+    uint16_t length;
+    uint8_t function_code;
+    uint8_t control_mask[3];
+    uint16_t response_code;
+} __attribute__((packed)) SCCBHeader;
+
+#define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
+
+typedef struct ReadInfo {
+    SCCBHeader h;
+    uint16_t rnmax;
+    uint8_t rnsize;
+} __attribute__((packed)) ReadInfo;
+
+typedef struct SCCB {
+    SCCBHeader h;
+    char data[SCCB_DATA_LEN];
+ } __attribute__((packed)) SCCB;
+
+/* SCLP event types */
+#define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
+#define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
+
+/* SCLP event masks */
+#define SCLP_EVENT_MASK_SIGNAL_QUIESCE          0x00000008
+#define SCLP_EVENT_MASK_MSG_ASCII               0x00000040
+
+#define SCLP_UNCONDITIONAL_READ                 0x00
+#define SCLP_SELECTIVE_READ                     0x01
+
+typedef struct WriteEventMask {
+    SCCBHeader h;
+    uint16_t _reserved;
+    uint16_t mask_length;
+    uint32_t cp_receive_mask;
+    uint32_t cp_send_mask;
+    uint32_t send_mask;
+    uint32_t receive_mask;
+} __attribute__((packed)) WriteEventMask;
+
+typedef struct EventBufferHeader {
+    uint16_t length;
+    uint8_t  type;
+    uint8_t  flags;
+    uint16_t _reserved;
+} __attribute__((packed)) EventBufferHeader;
+
+typedef struct WriteEventData {
+    SCCBHeader h;
+    EventBufferHeader ebh;
+    char data[0];
+} __attribute__((packed)) WriteEventData;
+
+typedef struct ReadEventData {
+    SCCBHeader h;
+    EventBufferHeader ebh;
+    uint32_t mask;
+} __attribute__((packed)) ReadEventData;
+
+#define __pa(x) (x)
+
+#endif /* SCLP_H */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 07/24] S390: ccw firmware: Add virtio device drivers
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (5 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 06/24] S390: ccw firmware: Add sclp output Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 08/24] S390: ccw firmware: Add glue header Alexander Graf
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

In order to boot, we need to be able to access a virtio-blk device through
the CCW bus. Implement support for this.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/cio.h    |  322 +++++++++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.c |  274 ++++++++++++++++++++++++++++++++++++++
 pc-bios/s390-ccw/virtio.h |  158 ++++++++++++++++++++++
 3 files changed, 754 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/cio.h
 create mode 100644 pc-bios/s390-ccw/virtio.c
 create mode 100644 pc-bios/s390-ccw/virtio.h

diff --git a/pc-bios/s390-ccw/cio.h b/pc-bios/s390-ccw/cio.h
new file mode 100644
index 0000000..cb5815a
--- /dev/null
+++ b/pc-bios/s390-ccw/cio.h
@@ -0,0 +1,322 @@
+/*
+ * Channel IO definitions
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * Inspired by various s390 headers in Linux 3.9.
+ *
+ * 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 CIO_H
+#define CIO_H
+
+/*
+ * path management control word
+ */
+struct pmcw {
+    __u32 intparm;        /* interruption parameter */
+    __u32 qf      : 1;    /* qdio facility */
+    __u32 w       : 1;
+    __u32 isc     : 3;    /* interruption sublass */
+    __u32 res5    : 3;    /* reserved zeros */
+    __u32 ena     : 1;    /* enabled */
+    __u32 lm      : 2;    /* limit mode */
+    __u32 mme     : 2;    /* measurement-mode enable */
+    __u32 mp      : 1;    /* multipath mode */
+    __u32 tf      : 1;    /* timing facility */
+    __u32 dnv     : 1;    /* device number valid */
+    __u32 dev     : 16;   /* device number */
+    __u8  lpm;            /* logical path mask */
+    __u8  pnom;           /* path not operational mask */
+    __u8  lpum;           /* last path used mask */
+    __u8  pim;            /* path installed mask */
+    __u16 mbi;            /* measurement-block index */
+    __u8  pom;            /* path operational mask */
+    __u8  pam;            /* path available mask */
+    __u8  chpid[8];       /* CHPID 0-7 (if available) */
+    __u32 unused1 : 8;    /* reserved zeros */
+    __u32 st      : 3;    /* subchannel type */
+    __u32 unused2 : 18;   /* reserved zeros */
+    __u32 mbfc    : 1;    /* measurement block format control */
+    __u32 xmwme   : 1;    /* extended measurement word mode enable */
+    __u32 csense  : 1;    /* concurrent sense; can be enabled ...*/
+                /*  ... per MSCH, however, if facility */
+                /*  ... is not installed, this results */
+                /*  ... in an operand exception.       */
+} __attribute__ ((packed));
+
+/* Target SCHIB configuration. */
+struct schib_config {
+    __u64 mba;
+    __u32 intparm;
+    __u16 mbi;
+    __u32 isc:3;
+    __u32 ena:1;
+    __u32 mme:2;
+    __u32 mp:1;
+    __u32 csense:1;
+    __u32 mbfc:1;
+} __attribute__ ((packed));
+
+struct scsw {
+    __u16 flags;
+    __u16 ctrl;
+    __u32 cpa;
+    __u8 dstat;
+    __u8 cstat;
+    __u16 count;
+} __attribute__ ((packed));
+
+#define SCSW_FCTL_CLEAR_FUNC 0x1000
+#define SCSW_FCTL_HALT_FUNC 0x2000
+#define SCSW_FCTL_START_FUNC 0x4000
+
+/*
+ * subchannel information block
+ */
+struct schib {
+    struct pmcw pmcw;     /* path management control word */
+    struct scsw scsw;     /* subchannel status word */
+    __u64 mba;            /* measurement block address */
+    __u8 mda[4];          /* model dependent area */
+} __attribute__ ((packed,aligned(4)));
+
+struct subchannel_id {
+        __u32 cssid  : 8;
+        __u32        : 4;
+        __u32 m      : 1;
+        __u32 ssid   : 2;
+        __u32 one    : 1;
+        __u32 sch_no : 16;
+} __attribute__ ((packed, aligned(4)));
+
+/*
+ * TPI info structure
+ */
+struct tpi_info {
+    struct subchannel_id schid;
+    __u32 intparm;         /* interruption parameter */
+    __u32 adapter_IO : 1;
+    __u32 reserved2  : 1;
+    __u32 isc        : 3;
+    __u32 reserved3  : 12;
+    __u32 int_type   : 3;
+    __u32 reserved4  : 12;
+} __attribute__ ((packed));
+
+/* channel command word (type 1) */
+struct ccw1 {
+    __u8 cmd_code;
+    __u8 flags;
+    __u16 count;
+    __u32 cda;
+} __attribute__ ((packed));
+
+#define CCW_FLAG_DC              0x80
+#define CCW_FLAG_CC              0x40
+#define CCW_FLAG_SLI             0x20
+#define CCW_FLAG_SKIP            0x10
+#define CCW_FLAG_PCI             0x08
+#define CCW_FLAG_IDA             0x04
+#define CCW_FLAG_SUSPEND         0x02
+
+#define CCW_CMD_NOOP             0x03
+#define CCW_CMD_BASIC_SENSE      0x04
+#define CCW_CMD_TIC              0x08
+#define CCW_CMD_SENSE_ID         0xe4
+
+#define CCW_CMD_SET_VQ           0x13
+#define CCW_CMD_VDEV_RESET       0x33
+#define CCW_CMD_READ_FEAT        0x12
+#define CCW_CMD_WRITE_FEAT       0x11
+#define CCW_CMD_READ_CONF        0x22
+#define CCW_CMD_WRITE_CONF       0x21
+#define CCW_CMD_WRITE_STATUS     0x31
+#define CCW_CMD_SET_IND          0x43
+#define CCW_CMD_SET_CONF_IND     0x53
+#define CCW_CMD_READ_VQ_CONF     0x32
+
+/*
+ * Command-mode operation request block
+ */
+struct cmd_orb {
+    __u32 intparm;    /* interruption parameter */
+    __u32 key:4;      /* flags, like key, suspend control, etc. */
+    __u32 spnd:1;     /* suspend control */
+    __u32 res1:1;     /* reserved */
+    __u32 mod:1;      /* modification control */
+    __u32 sync:1;     /* synchronize control */
+    __u32 fmt:1;      /* format control */
+    __u32 pfch:1;     /* prefetch control */
+    __u32 isic:1;     /* initial-status-interruption control */
+    __u32 alcc:1;     /* address-limit-checking control */
+    __u32 ssic:1;     /* suppress-suspended-interr. control */
+    __u32 res2:1;     /* reserved */
+    __u32 c64:1;      /* IDAW/QDIO 64 bit control  */
+    __u32 i2k:1;      /* IDAW 2/4kB block size control */
+    __u32 lpm:8;      /* logical path mask */
+    __u32 ils:1;      /* incorrect length */
+    __u32 zero:6;     /* reserved zeros */
+    __u32 orbx:1;     /* ORB extension control */
+    __u32 cpa;    /* channel program address */
+}  __attribute__ ((packed, aligned(4)));
+
+struct ciw {
+    __u8 type;
+    __u8 command;
+    __u16 count;
+};
+
+/*
+ * sense-id response buffer layout
+ */
+struct senseid {
+    /* common part */
+    __u8  reserved;   /* always 0x'FF' */
+    __u16 cu_type;    /* control unit type */
+    __u8  cu_model;   /* control unit model */
+    __u16 dev_type;   /* device type */
+    __u8  dev_model;  /* device model */
+    __u8  unused;     /* padding byte */
+    /* extended part */
+    struct ciw ciw[62];
+}  __attribute__ ((packed, aligned(4)));
+
+/* interruption response block */
+struct irb {
+    struct scsw scsw;
+    __u32 esw[5];
+    __u32 ecw[8];
+    __u32 emw[8];
+}  __attribute__ ((packed, aligned(4)));
+
+/*
+ * Some S390 specific IO instructions as inline
+ */
+
+static inline int stsch_err(struct subchannel_id schid, struct schib *addr)
+{
+    register struct subchannel_id reg1 asm ("1") = schid;
+    int ccode = -EIO;
+
+    asm volatile(
+        "    stsch    0(%3)\n"
+        "0:  ipm    %0\n"
+        "    srl    %0,28\n"
+        "1:\n"
+        : "+d" (ccode), "=m" (*addr)
+        : "d" (reg1), "a" (addr)
+        : "cc");
+    return ccode;
+}
+
+static inline int msch(struct subchannel_id schid, struct schib *addr)
+{
+    register struct subchannel_id reg1 asm ("1") = schid;
+    int ccode;
+
+    asm volatile(
+        "    msch    0(%2)\n"
+        "    ipm    %0\n"
+        "    srl    %0,28"
+        : "=d" (ccode)
+        : "d" (reg1), "a" (addr), "m" (*addr)
+        : "cc");
+    return ccode;
+}
+
+static inline int msch_err(struct subchannel_id schid, struct schib *addr)
+{
+    register struct subchannel_id reg1 asm ("1") = schid;
+    int ccode = -EIO;
+
+    asm volatile(
+        "    msch    0(%2)\n"
+        "0:  ipm    %0\n"
+        "    srl    %0,28\n"
+        "1:\n"
+        : "+d" (ccode)
+        : "d" (reg1), "a" (addr), "m" (*addr)
+        : "cc");
+    return ccode;
+}
+
+static inline int tsch(struct subchannel_id schid, struct irb *addr)
+{
+    register struct subchannel_id reg1 asm ("1") = schid;
+    int ccode;
+
+    asm volatile(
+        "    tsch    0(%3)\n"
+        "    ipm    %0\n"
+        "    srl    %0,28"
+        : "=d" (ccode), "=m" (*addr)
+        : "d" (reg1), "a" (addr)
+        : "cc");
+    return ccode;
+}
+
+static inline int ssch(struct subchannel_id schid, struct cmd_orb *addr)
+{
+    register struct subchannel_id reg1 asm("1") = schid;
+    int ccode = -EIO;
+
+    asm volatile(
+        "    ssch    0(%2)\n"
+        "0:  ipm    %0\n"
+        "    srl    %0,28\n"
+        "1:\n"
+        : "+d" (ccode)
+        : "d" (reg1), "a" (addr), "m" (*addr)
+        : "cc", "memory");
+    return ccode;
+}
+
+static inline int csch(struct subchannel_id schid)
+{
+    register struct subchannel_id reg1 asm("1") = schid;
+    int ccode;
+
+    asm volatile(
+        "    csch\n"
+        "    ipm    %0\n"
+        "    srl    %0,28"
+        : "=d" (ccode)
+        : "d" (reg1)
+        : "cc");
+    return ccode;
+}
+
+static inline int tpi(struct tpi_info *addr)
+{
+    int ccode;
+
+    asm volatile(
+        "    tpi    0(%2)\n"
+        "    ipm    %0\n"
+        "    srl    %0,28"
+        : "=d" (ccode), "=m" (*addr)
+        : "a" (addr)
+        : "cc");
+    return ccode;
+}
+
+static inline int chsc(void *chsc_area)
+{
+    typedef struct { char _[4096]; } addr_type;
+    int cc;
+
+    asm volatile(
+        "    .insn    rre,0xb25f0000,%2,0\n"
+        "    ipm    %0\n"
+        "    srl    %0,28\n"
+        : "=d" (cc), "=m" (*(addr_type *) chsc_area)
+        : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
+        : "cc");
+    return cc;
+}
+
+#endif /* CIO_H */
diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
new file mode 100644
index 0000000..79e2941
--- /dev/null
+++ b/pc-bios/s390-ccw/virtio.c
@@ -0,0 +1,274 @@
+/*
+ * Virtio driver bits
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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.
+ */
+
+#include "s390-ccw.h"
+#include "virtio.h"
+
+struct vring block;
+
+static long kvm_hypercall(unsigned long nr, unsigned long param1,
+                          unsigned long param2)
+{
+	register ulong r_nr asm("1") = nr;
+	register ulong r_param1 asm("2") = param1;
+	register ulong r_param2 asm("3") = param2;
+	register long retval asm("2");
+
+	asm volatile ("diag 2,4,0x500"
+		      : "=d" (retval)
+		      : "d" (r_nr), "0" (r_param1), "r"(r_param2)
+		      : "memory", "cc");
+
+	return retval;
+}
+
+static void virtio_notify(struct subchannel_id schid)
+{
+    kvm_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY, *(u32*)&schid, 0);
+}
+
+/***********************************************
+ *             Virtio functions                *
+ ***********************************************/
+
+static void drain_irqs(struct subchannel_id schid)
+{
+    struct irb irb = {};
+    while (1) {
+        if (tsch(schid, &irb)) {
+            return;
+        }
+    }
+}
+
+static int run_ccw(struct subchannel_id schid, int cmd, void *ptr, int len)
+{
+    struct ccw1 ccw = {};
+    struct cmd_orb orb = {};
+    struct schib schib;
+    int r;
+
+    /* start command processing */
+    stsch_err(schid, &schib);
+    schib.scsw.ctrl = SCSW_FCTL_START_FUNC;
+    msch(schid, &schib);
+
+    /* start subchannel command */
+    orb.fmt = 1;
+    orb.cpa = (u32)(long)&ccw;
+    orb.lpm = 0x80;
+
+    ccw.cmd_code = cmd;
+    ccw.cda = (long)ptr;
+    ccw.count = len;
+
+    r = ssch(schid, &orb);
+    /*
+     * XXX Wait until device is done processing the CCW. For now we can
+     *     assume that a simple tsch will have finished the CCW processing,
+     *     but the architecture allows for asynchronous operation
+     */
+    drain_irqs(schid);
+    return r;
+}
+
+static void virtio_set_status(struct subchannel_id schid,
+                              unsigned long dev_addr)
+{
+    unsigned char status = dev_addr;
+    run_ccw(schid, CCW_CMD_WRITE_STATUS, &status, sizeof(status));
+}
+
+static void virtio_reset(struct subchannel_id schid)
+{
+    run_ccw(schid, CCW_CMD_VDEV_RESET, NULL, 0);
+}
+
+static void vring_init(struct vring *vr, unsigned int num, void *p,
+                       unsigned long align)
+{
+    debug_print_addr("init p", p);
+    vr->num = num;
+    vr->desc = p;
+    vr->avail = p + num*sizeof(struct vring_desc);
+    vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
+                & ~(align - 1));
+
+    /* We're running with interrupts off anyways, so don't bother */
+    vr->used->flags = VRING_USED_F_NO_NOTIFY;
+
+    debug_print_addr("init vr", vr);
+}
+
+static void vring_notify(struct subchannel_id schid)
+{
+    virtio_notify(schid);
+}
+
+static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
+{
+    /* For follow-up chains we need to keep the first entry point */
+    if (!(flags & VRING_HIDDEN_IS_CHAIN)) {
+        vr->avail->ring[vr->avail->idx % vr->num] = vr->next_idx;
+    }
+
+    vr->desc[vr->next_idx].addr = (ulong)p;
+    vr->desc[vr->next_idx].len = len;
+    vr->desc[vr->next_idx].flags = flags & ~VRING_HIDDEN_IS_CHAIN;
+    vr->desc[vr->next_idx].next = ++vr->next_idx;
+
+    /* Chains only have a single ID */
+    if (!(flags & VRING_DESC_F_NEXT)) {
+        vr->avail->idx++;
+    }
+
+    vr->used->idx = vr->next_idx;
+}
+
+static u64 get_clock(void)
+{
+    u64 r;
+
+    asm volatile("stck %0" : "=Q" (r) : : "cc");
+    return r;
+}
+
+static ulong get_second(void)
+{
+    return (get_clock() >> 12) / 1000000;
+}
+
+/*
+ * Wait for the host to reply.
+ *
+ * timeout is in seconds if > 0.
+ *
+ * Returns 0 on success, 1 on timeout.
+ */
+static int vring_wait_reply(struct vring *vr, int timeout)
+{
+    ulong target_second = get_second() + timeout;
+    struct subchannel_id schid = vr->schid;
+    int r = 0;
+
+    while (vr->used->idx == vr->next_idx) {
+        vring_notify(schid);
+        if (timeout && (get_second() >= target_second)) {
+            r = 1;
+            break;
+        }
+        yield();
+    }
+
+    vr->next_idx = 0;
+    vr->desc[0].len = 0;
+    vr->desc[0].flags = 0;
+
+    return r;
+}
+
+/***********************************************
+ *               Virtio block                  *
+ ***********************************************/
+
+static int virtio_read_many(ulong sector, void *load_addr, int sec_num)
+{
+    struct virtio_blk_outhdr out_hdr;
+    u8 status;
+
+    /* Tell the host we want to read */
+    out_hdr.type = VIRTIO_BLK_T_IN;
+    out_hdr.ioprio = 99;
+    out_hdr.sector = sector;
+
+    vring_send_buf(&block, &out_hdr, sizeof(out_hdr), VRING_DESC_F_NEXT);
+
+    /* This is where we want to receive data */
+    vring_send_buf(&block, load_addr, SECTOR_SIZE * sec_num,
+                   VRING_DESC_F_WRITE | VRING_HIDDEN_IS_CHAIN |
+                   VRING_DESC_F_NEXT);
+
+    /* status field */
+    vring_send_buf(&block, &status, sizeof(u8), VRING_DESC_F_WRITE |
+                   VRING_HIDDEN_IS_CHAIN);
+
+    /* Now we can tell the host to read */
+    vring_wait_reply(&block, 0);
+
+    drain_irqs(block.schid);
+
+    return status;
+}
+
+unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
+				 ulong subchan_id, void *load_addr)
+{
+    u8 status;
+    int sec = rec_list1;
+    int sec_num = (((rec_list2 >> 32)+ 1) & 0xffff);
+    int sec_len = rec_list2 >> 48;
+    ulong addr = (ulong)load_addr;
+
+    if (sec_len != SECTOR_SIZE) {
+        return -1;
+    }
+
+    sclp_print(".");
+    status = virtio_read_many(sec, (void*)addr, sec_num);
+    if (status) {
+        virtio_panic("I/O Error");
+    }
+    addr += sec_num * SECTOR_SIZE;
+
+    return addr;
+}
+
+int virtio_read(ulong sector, void *load_addr)
+{
+    return virtio_read_many(sector, load_addr, 1);
+}
+
+void virtio_setup_block(struct subchannel_id schid)
+{
+    struct vq_info_block info;
+
+    virtio_reset(schid);
+
+    /* XXX need to fetch the 128 from host */
+    vring_init(&block, 128, (void*)(100 * 1024 * 1024),
+               KVM_S390_VIRTIO_RING_ALIGN);
+
+    info.queue = (100ULL * 1024ULL* 1024ULL);
+    info.align = KVM_S390_VIRTIO_RING_ALIGN;
+    info.index = 0;
+    info.num = 128;
+    block.schid = schid;
+
+    run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info));
+    virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);
+}
+
+bool virtio_is_blk(struct subchannel_id schid)
+{
+    int r;
+    struct senseid senseid = {};
+
+    /* run sense id command */
+    r = run_ccw(schid, CCW_CMD_SENSE_ID, &senseid, sizeof(senseid));
+    if (r) {
+        return false;
+    }
+    if ((senseid.cu_type != 0x3832) || (senseid.cu_model != VIRTIO_ID_BLOCK)) {
+        return false;
+    }
+
+    return true;
+}
+
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
new file mode 100644
index 0000000..a33199d
--- /dev/null
+++ b/pc-bios/s390-ccw/virtio.h
@@ -0,0 +1,158 @@
+/*
+ * Virtio driver bits
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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 VIRTIO_H
+#define VIRTIO_H
+
+#include "s390-ccw.h"
+
+/* Status byte for guest to report progress, and synchronize features. */
+/* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */
+#define VIRTIO_CONFIG_S_ACKNOWLEDGE     1
+/* We have found a driver for the device. */
+#define VIRTIO_CONFIG_S_DRIVER          2
+/* Driver has used its parts of the config, and is happy */
+#define VIRTIO_CONFIG_S_DRIVER_OK       4
+/* We've given up on this device. */
+#define VIRTIO_CONFIG_S_FAILED          0x80
+
+enum virtio_dev_type {
+    VIRTIO_ID_NET = 1,
+    VIRTIO_ID_BLOCK = 2,
+    VIRTIO_ID_CONSOLE = 3,
+    VIRTIO_ID_BALLOON = 5,
+};
+
+struct virtio_dev_header {
+    enum virtio_dev_type type : 8;
+    u8  num_vq;
+    u8  feature_len;
+    u8  config_len;
+    u8  status;
+    u8  vqconfig[];
+} __attribute__((packed));
+
+struct virtio_vqconfig {
+    u64 token;
+    u64 address;
+    u16 num;
+    u8  pad[6];
+} __attribute__((packed));
+
+struct vq_info_block {
+    u64 queue;
+    u32 align;
+    u16 index;
+    u16 num;
+} __attribute__((packed));
+
+struct virtio_dev {
+    struct virtio_dev_header *header;
+    struct virtio_vqconfig *vqconfig;
+    char *host_features;
+    char *guest_features;
+    char *config;
+};
+
+#define KVM_S390_VIRTIO_RING_ALIGN	4096
+
+#define VRING_USED_F_NO_NOTIFY  1
+
+/* This marks a buffer as continuing via the next field. */
+#define VRING_DESC_F_NEXT       1
+/* This marks a buffer as write-only (otherwise read-only). */
+#define VRING_DESC_F_WRITE      2
+/* This means the buffer contains a list of buffer descriptors. */
+#define VRING_DESC_F_INDIRECT   4
+
+/* Internal flag to mark follow-up segments as such */
+#define VRING_HIDDEN_IS_CHAIN   256
+
+/* Virtio ring descriptors: 16 bytes.  These can chain together via "next". */
+struct vring_desc {
+    /* Address (guest-physical). */
+    u64 addr;
+    /* Length. */
+    u32 len;
+    /* The flags as indicated above. */
+    u16 flags;
+    /* We chain unused descriptors via this, too */
+    u16 next;
+} __attribute__((packed));
+
+struct vring_avail {
+    u16 flags;
+    u16 idx;
+    u16 ring[];
+} __attribute__((packed));
+
+/* u32 is used here for ids for padding reasons. */
+struct vring_used_elem {
+    /* Index of start of used descriptor chain. */
+    u32 id;
+    /* Total length of the descriptor chain which was used (written to) */
+    u32 len;
+} __attribute__((packed));
+
+struct vring_used {
+    u16 flags;
+    u16 idx;
+    struct vring_used_elem ring[];
+} __attribute__((packed));
+
+struct vring {
+    unsigned int num;
+    int next_idx;
+    struct vring_desc *desc;
+    struct vring_avail *avail;
+    struct vring_used *used;
+    struct subchannel_id schid;
+};
+
+
+/***********************************************
+ *               Virtio block                  *
+ ***********************************************/
+
+/*
+ * Command types
+ *
+ * Usage is a bit tricky as some bits are used as flags and some are not.
+ *
+ * Rules:
+ *   VIRTIO_BLK_T_OUT may be combined with VIRTIO_BLK_T_SCSI_CMD or
+ *   VIRTIO_BLK_T_BARRIER.  VIRTIO_BLK_T_FLUSH is a command of its own
+ *   and may not be combined with any of the other flags.
+ */
+
+/* These two define direction. */
+#define VIRTIO_BLK_T_IN         0
+#define VIRTIO_BLK_T_OUT        1
+
+/* This bit says it's a scsi command, not an actual read or write. */
+#define VIRTIO_BLK_T_SCSI_CMD   2
+
+/* Cache flush command */
+#define VIRTIO_BLK_T_FLUSH      4
+
+/* Barrier before this op. */
+#define VIRTIO_BLK_T_BARRIER    0x80000000
+
+/* This is the first element of the read scatter-gather list. */
+struct virtio_blk_outhdr {
+        /* VIRTIO_BLK_T* */
+        u32 type;
+        /* io priority. */
+        u32 ioprio;
+        /* Sector (ie. 512 byte offset) */
+        u64 sector;
+};
+
+#endif /* VIRTIO_H */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 08/24] S390: ccw firmware: Add glue header
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (6 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 07/24] S390: ccw firmware: Add virtio device drivers Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 09/24] S390: ccw firmware: Add bootmap interpreter Alexander Graf
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

Like all great programs, we have to call between different functions in
different object files. And all of them need a common ground of defines.

Provide a file that provides these defines.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/s390-ccw.h |  131 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/s390-ccw.h

diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
new file mode 100644
index 0000000..a03dbaf
--- /dev/null
+++ b/pc-bios/s390-ccw/s390-ccw.h
@@ -0,0 +1,131 @@
+/*
+ * S390 CCW boot loader
+ *
+ * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ *
+ * 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 S390_CCW_H
+#define S390_CCW_H
+
+/* #define DEBUG */
+
+typedef unsigned char      u8;
+typedef unsigned short     u16;
+typedef unsigned int       u32;
+typedef unsigned long long u64;
+typedef unsigned long      ulong;
+typedef long               size_t;
+typedef int                bool;
+typedef unsigned char      uint8_t;
+typedef unsigned short     uint16_t;
+typedef unsigned int       uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned char      __u8;
+typedef unsigned short     __u16;
+typedef unsigned int       __u32;
+typedef unsigned long long __u64;
+
+#define true 1
+#define false 0
+#define PAGE_SIZE 4096
+
+#ifndef EIO
+#define EIO	1
+#endif
+#ifndef EBUSY
+#define EBUSY	2
+#endif
+#ifndef NULL
+#define NULL    0
+#endif
+
+#include "cio.h"
+
+/* main.c */
+void virtio_panic(const char *string);
+
+/* sclp-ascii.c */
+void sclp_print(const char *string);
+void sclp_setup(void);
+
+/* virtio.c */
+unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2,
+				 ulong subchan_id, void *load_addr);
+bool virtio_is_blk(struct subchannel_id schid);
+void virtio_setup_block(struct subchannel_id schid);
+int virtio_read(ulong sector, void *load_addr);
+
+/* bootmap.c */
+int zipl_load(void);
+
+static inline void *memset(void *s, int c, size_t n)
+{
+    int i;
+    unsigned char *p = s;
+
+    for (i = 0; i < n; i++) {
+        p[i] = c;
+    }
+
+    return s;
+}
+
+static inline void fill_hex(char *out, unsigned char val)
+{
+    const char hex[] = "0123456789abcdef";
+
+    out[0] = hex[(val >> 4) & 0xf];
+    out[1] = hex[val & 0xf];
+}
+
+static inline void print_int(const char *desc, u64 addr)
+{
+    unsigned char *addr_c = (unsigned char*)&addr;
+    char out[] = ": 0xffffffffffffffff\n";
+    unsigned int i;
+
+    for (i = 0; i < sizeof(addr); i++) {
+        fill_hex(&out[4 + (i*2)], addr_c[i]);
+    }
+
+    sclp_print(desc);
+    sclp_print(out);
+}
+
+static inline void debug_print_int(const char *desc, u64 addr)
+{
+#ifdef DEBUG
+    print_int(desc, addr);
+#endif
+}
+
+static inline void debug_print_addr(const char *desc, void *p)
+{
+#ifdef DEBUG
+    debug_print_int(desc, (unsigned int)(unsigned long)p);
+#endif
+}
+
+/***********************************************
+ *           Hypercall functions               *
+ ***********************************************/
+
+#define KVM_S390_VIRTIO_NOTIFY		0
+#define KVM_S390_VIRTIO_RESET		1
+#define KVM_S390_VIRTIO_SET_STATUS	2
+#define KVM_S390_VIRTIO_CCW_NOTIFY      3
+
+static inline void yield(void)
+{
+	asm volatile ("diag 0,0,0x44"
+                      : :
+		      : "memory", "cc");
+}
+
+#define SECTOR_SIZE 512
+
+#endif /* S390_CCW_H */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 09/24] S390: ccw firmware: Add bootmap interpreter
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (7 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 08/24] S390: ccw firmware: Add glue header Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 10/24] S390: ccw firmware: Add Makefile Alexander Graf
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

On s390, there is an architected boot map format that we can read to
boot a certain entry off the disk. Implement a simple reader for this
that always boots the first (default) entry.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/bootmap.c |  235 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 235 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/bootmap.c

diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
new file mode 100644
index 0000000..53a460d
--- /dev/null
+++ b/pc-bios/s390-ccw/bootmap.c
@@ -0,0 +1,235 @@
+/*
+ * QEMU S390 bootmap interpreter
+ *
+ * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
+ *
+ * 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.
+ */
+
+#include "s390-ccw.h"
+
+// #define DEBUG_FALLBACK
+
+#ifdef DEBUG_FALLBACK
+#define dputs(txt) \
+    do { sclp_print("zipl: " txt); } while (0)
+#else
+#define dputs(fmt, ...) \
+    do { } while (0)
+#endif
+
+struct scsi_blockptr {
+    uint64_t blockno;
+    uint16_t size;
+    uint16_t blockct;
+    uint8_t reserved[4];
+} __attribute__ ((packed));
+
+struct component_entry {
+    struct scsi_blockptr data;
+    uint8_t pad[7];
+    uint8_t component_type;
+    uint64_t load_address;
+} __attribute((packed));
+
+struct component_header {
+    uint8_t magic[4];
+    uint8_t type;
+    uint8_t reserved[27];
+} __attribute((packed));
+
+struct mbr {
+    uint8_t magic[4];
+    uint32_t version_id;
+    uint8_t reserved[8];
+    struct scsi_blockptr blockptr;
+} __attribute__ ((packed));
+
+#define ZIPL_MAGIC			"zIPL"
+
+#define ZIPL_COMP_HEADER_IPL		0x00
+#define ZIPL_COMP_HEADER_DUMP		0x01
+
+#define ZIPL_COMP_ENTRY_LOAD		0x02
+#define ZIPL_COMP_ENTRY_EXEC		0x01
+
+/* Scratch space */
+static uint8_t sec[SECTOR_SIZE] __attribute__((__aligned__(SECTOR_SIZE)));
+
+/* Check for ZIPL magic. Returns 0 if not matched. */
+static int zipl_magic(uint8_t *ptr)
+{
+    uint32_t *p = (void*)ptr;
+    uint32_t *z = (void*)ZIPL_MAGIC;
+
+    if (*p != *z) {
+        debug_print_int("invalid magic", *p);
+        virtio_panic("invalid magic");
+    }
+
+    return 1;
+}
+
+static int zipl_load_segment(struct component_entry *entry)
+{
+    const int max_entries = (SECTOR_SIZE / sizeof(struct scsi_blockptr));
+    struct scsi_blockptr *bprs = (void*)sec;
+    uint64_t blockno;
+    long address;
+    int i;
+
+    blockno = entry->data.blockno;
+    address = entry->load_address;
+
+    debug_print_int("loading segment at block", blockno);
+    debug_print_int("addr", address);
+
+    do {
+        if (virtio_read(blockno, (uint8_t *)bprs)) {
+            debug_print_int("failed reading bprs at", blockno);
+            goto fail;
+        }
+
+        for (i = 0;; i++) {
+            u64 *cur_desc = (void*)&bprs[i];
+
+            blockno = bprs[i].blockno;
+            if (!blockno)
+                break;
+
+            /* we need the updated blockno for the next indirect entry in the
+               chain, but don't want to advance address */
+            if (i == (max_entries - 1))
+                break;
+
+            address = virtio_load_direct(cur_desc[0], cur_desc[1], 0,
+                                         (void*)address);
+            if (address == -1)
+                goto fail;
+        }
+    } while (blockno);
+
+    return 0;
+
+fail:
+    sclp_print("failed loading segment\n");
+    return -1;
+}
+
+/* Run a zipl program */
+static int zipl_run(struct scsi_blockptr *pte)
+{
+    struct component_header *header;
+    struct component_entry *entry;
+    void (*ipl)(void);
+    uint8_t tmp_sec[SECTOR_SIZE];
+
+    virtio_read(pte->blockno, tmp_sec);
+    header = (struct component_header *)tmp_sec;
+
+    if (!zipl_magic(tmp_sec)) {
+        goto fail;
+    }
+
+    if (header->type != ZIPL_COMP_HEADER_IPL) {
+        goto fail;
+    }
+
+    dputs("start loading images\n");
+
+    /* Load image(s) into RAM */
+    entry = (struct component_entry *)(&header[1]);
+    while (entry->component_type == ZIPL_COMP_ENTRY_LOAD) {
+        if (zipl_load_segment(entry) < 0) {
+            goto fail;
+        }
+
+        entry++;
+
+        if ((uint8_t*)(&entry[1]) > (tmp_sec + SECTOR_SIZE)) {
+            goto fail;
+        }
+    }
+
+    if (entry->component_type != ZIPL_COMP_ENTRY_EXEC) {
+        goto fail;
+    }
+
+    /* Ensure the guest output starts fresh */
+    sclp_print("\n");
+
+    /* And run the OS! */
+    ipl = (void*)(entry->load_address & 0x7fffffff);
+    debug_print_addr("set IPL addr to", ipl);
+    /* should not return */
+    ipl();
+
+    return 0;
+
+fail:
+    sclp_print("failed running zipl\n");
+    return -1;
+}
+
+int zipl_load(void)
+{
+    struct mbr *mbr = (void*)sec;
+    uint8_t *ns, *ns_end;
+    int program_table_entries = 0;
+    int pte_len = sizeof(struct scsi_blockptr);
+    struct scsi_blockptr *prog_table_entry;
+    const char *error = "";
+
+    /* Grab the MBR */
+    virtio_read(0, (void*)mbr);
+
+    dputs("checking magic\n");
+
+    if (!zipl_magic(mbr->magic)) {
+        error = "zipl_magic 1";
+        goto fail;
+    }
+
+    debug_print_int("program table", mbr->blockptr.blockno);
+
+    /* Parse the program table */
+    if (virtio_read(mbr->blockptr.blockno, sec)) {
+        error = "virtio_read";
+        goto fail;
+    }
+
+    if (!zipl_magic(sec)) {
+        error = "zipl_magic 2";
+        goto fail;
+    }
+
+    ns_end = sec + SECTOR_SIZE;
+    for (ns = (sec + pte_len); (ns + pte_len) < ns_end; ns++) {
+        prog_table_entry = (struct scsi_blockptr *)ns;
+        if (!prog_table_entry->blockno) {
+            break;
+        }
+
+        program_table_entries++;
+    }
+
+    debug_print_int("program table entries", program_table_entries);
+
+    if (!program_table_entries) {
+        goto fail;
+    }
+
+    /* Run the default entry */
+
+    prog_table_entry = (struct scsi_blockptr *)(sec + pte_len);
+
+    return zipl_run(prog_table_entry);
+
+fail:
+    sclp_print("failed loading zipl: ");
+    sclp_print(error);
+    sclp_print("\n");
+    return -1;
+}
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 10/24] S390: ccw firmware: Add Makefile
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (8 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 09/24] S390: ccw firmware: Add bootmap interpreter Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 11/24] s390-ccw.img: replace while loop with a disabled wait on s390 bios Alexander Graf
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

This patch adds a makefile, so we can build our ccw firmware. Also
add the resulting binaries to .gitignore, so that nobody is annoyed
they might be in the tree.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 .gitignore                |    2 ++
 pc-bios/s390-ccw/Makefile |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw/Makefile

diff --git a/.gitignore b/.gitignore
index 487813a..64e9466 100644
--- a/.gitignore
+++ b/.gitignore
@@ -100,6 +100,8 @@ pc-bios/optionrom/kvmvapic.asm
 pc-bios/optionrom/kvmvapic.bin
 pc-bios/optionrom/kvmvapic.raw
 pc-bios/optionrom/kvmvapic.img
+pc-bios/s390-ccw/s390-ccw.elf
+pc-bios/s390-ccw/s390-ccw.img
 .stgit-*
 cscope.*
 tags
diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
new file mode 100644
index 0000000..c126194
--- /dev/null
+++ b/pc-bios/s390-ccw/Makefile
@@ -0,0 +1,26 @@
+all: build-all
+# Dummy command so that make thinks it has done something
+	@true
+
+include ../../config-host.mak
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw)
+
+.PHONY : all clean build-all
+
+OBJECTS=main.o bootmap.o sclp-ascii.o virtio.o start.o
+CFLAGS += -fno-stack-protector
+# XXX find a more clever to locate the bootloader
+LDFLAGS += -Wl,-Ttext,0x7e00000,-Tbss,0x7f00000 -nostdlib
+
+build-all: s390-ccw.img
+
+s390-ccw.elf: $(OBJECTS)
+	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"  Building $(TARGET_DIR)$@")
+
+s390-ccw.img: s390-ccw.elf
+	$(call quiet-command,strip $@,"  Stripping $(TARGET_DIR)$@")
+
+clean:
+	rm -f *.o *.d *.img *~
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 11/24] s390-ccw.img: replace while loop with a disabled wait on s390 bios
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (9 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 10/24] S390: ccw firmware: Add Makefile Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 12/24] s390-ccw.img: build s390-ccw rom on s3900 system by default Alexander Graf
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Christian Borntraeger, qemu-devel, Aurelien Jarno

From: Christian Borntraeger <borntraeger@de.ibm.com>

dont waste cpu power on an error condition. Lets stop the guest
with a disabled wait.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/main.c     |    2 ++
 pc-bios/s390-ccw/s390-ccw.h |    3 +++
 pc-bios/s390-ccw/start.S    |   15 +++++++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 0913aac..67f4987 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -16,6 +16,7 @@ char stack[PAGE_SIZE * 8] __attribute__((__aligned__(PAGE_SIZE)));
 void virtio_panic(const char *string)
 {
     sclp_print(string);
+    disabled_wait();
     while (1) { }
 }
 
@@ -52,5 +53,6 @@ int main(void)
     virtio_setup();
     if (zipl_load() < 0)
         sclp_print("Failed to load OS from hard disk\n");
+    disabled_wait();
     while (1) { }
 }
diff --git a/pc-bios/s390-ccw/s390-ccw.h b/pc-bios/s390-ccw/s390-ccw.h
index a03dbaf..8241b0a 100644
--- a/pc-bios/s390-ccw/s390-ccw.h
+++ b/pc-bios/s390-ccw/s390-ccw.h
@@ -45,6 +45,9 @@ typedef unsigned long long __u64;
 
 #include "cio.h"
 
+/* start.s */
+void disabled_wait(void);
+
 /* main.c */
 void virtio_panic(const char *string);
 
diff --git a/pc-bios/s390-ccw/start.S b/pc-bios/s390-ccw/start.S
index c2b9a19..09deee7 100644
--- a/pc-bios/s390-ccw/start.S
+++ b/pc-bios/s390-ccw/start.S
@@ -3,6 +3,7 @@
  * into the pc-bios directory of qemu.
  *
  * Copyright (c) 2013 Alexander Graf <agraf@suse.de>
+ * Copyright 2013 IBM Corp.
  *
  * 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
@@ -14,3 +15,17 @@ _start:
 
 larl	%r15, stack + 0x8000    /* Set up stack */
 j	main                    /* And call C */
+
+/*
+ * void disabled_wait(void)
+ *
+ * stops the current guest cpu.
+ */
+	.globl disabled_wait
+disabled_wait:
+        larl %r1,disabled_wait_psw
+        lpswe   0(%r1)
+
+        .align  8
+disabled_wait_psw:
+        .quad   0x0002000180000000,0x0000000000000000
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 12/24] s390-ccw.img: build s390-ccw rom on s3900 system by default
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (10 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 11/24] s390-ccw.img: replace while loop with a disabled wait on s390 bios Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 13/24] s390-ccw.img: Take care of the elf->img transition Alexander Graf
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Christian Borntraeger, qemu-devel, Aurelien Jarno

From: Christian Borntraeger <borntraeger@de.ibm.com>

Lets build the s390-ccw rom if on s390. Also fix the separate build
folder case.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 configure |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 8188a7c..a07abc4 100755
--- a/configure
+++ b/configure
@@ -3460,6 +3460,10 @@ if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
   roms="$roms spapr-rtas"
 fi
 
+if test "$cpu" = "s390x" ; then
+  roms="$roms s390-ccw"
+fi
+
 # add pixman flags after all config tests are done
 QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
 libs_softmmu="$libs_softmmu $pixman_libs"
@@ -4511,7 +4515,7 @@ fi
 
 # build tree in object directory in case the source is not in the current directory
 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos"
-DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
+DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw"
 DIRS="$DIRS roms/seabios roms/vgabios"
 DIRS="$DIRS qapi-generated"
 FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
@@ -4519,6 +4523,7 @@ FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit"
 FILES="$FILES tests/tcg/lm32/Makefile po/Makefile"
 FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
 FILES="$FILES pc-bios/spapr-rtas/Makefile"
+FILES="$FILES pc-bios/s390-ccw/Makefile"
 FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile"
 FILES="$FILES pc-bios/qemu-icon.bmp"
 for bios_file in \
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 13/24] s390-ccw.img: Take care of the elf->img transition
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (11 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 12/24] s390-ccw.img: build s390-ccw rom on s3900 system by default Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 14/24] s390-ccw.img: Fix compile warning in s390 ccw virtio code Alexander Graf
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Christian Borntraeger, qemu-devel, Aurelien Jarno

From: Christian Borntraeger <borntraeger@de.ibm.com>

We have to call strip with s390-ccw.elf as input and
s390-ccw.img as output

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pc-bios/s390-ccw/Makefile b/pc-bios/s390-ccw/Makefile
index c126194..ad55a14 100644
--- a/pc-bios/s390-ccw/Makefile
+++ b/pc-bios/s390-ccw/Makefile
@@ -20,7 +20,7 @@ s390-ccw.elf: $(OBJECTS)
 	$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"  Building $(TARGET_DIR)$@")
 
 s390-ccw.img: s390-ccw.elf
-	$(call quiet-command,strip $@,"  Stripping $(TARGET_DIR)$@")
+	$(call quiet-command,strip $< -o $@,"  Stripping $(TARGET_DIR)$@")
 
 clean:
-	rm -f *.o *.d *.img *~
+	rm -f *.o *.d *.img *.elf *~
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 14/24] s390-ccw.img: Fix compile warning in s390 ccw virtio code
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (12 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 13/24] s390-ccw.img: Take care of the elf->img transition Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 15/24] s390-ccw.img: Detect devices with stsch Alexander Graf
                   ` (10 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Christian Borntraeger, qemu-devel, Aurelien Jarno

From: Christian Borntraeger <borntraeger@de.ibm.com>

Lets fix this gcc warning:

virtio.c: In function ‘vring_send_buf’:
virtio.c:125:35: error: operation on ‘vr->next_idx’ may be undefined
[-Werror=sequence-point]

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/virtio.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 79e2941..1968fc6 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -122,7 +122,9 @@ static void vring_send_buf(struct vring *vr, void *p, int len, int flags)
     vr->desc[vr->next_idx].addr = (ulong)p;
     vr->desc[vr->next_idx].len = len;
     vr->desc[vr->next_idx].flags = flags & ~VRING_HIDDEN_IS_CHAIN;
-    vr->desc[vr->next_idx].next = ++vr->next_idx;
+    vr->desc[vr->next_idx].next = vr->next_idx;
+    vr->desc[vr->next_idx].next++;
+    vr->next_idx++;
 
     /* Chains only have a single ID */
     if (!(flags & VRING_DESC_F_NEXT)) {
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 15/24] s390-ccw.img: Detect devices with stsch.
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (13 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 14/24] s390-ccw.img: Fix compile warning in s390 ccw virtio code Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 16/24] s390-ccw.img: Enhance drain_irqs() Alexander Graf
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Cornelia Huck, qemu-devel, Aurelien Jarno

From: Cornelia Huck <cornelia.huck@de.ibm.com>

stsch is the canonical way to detect devices. As a bonus, we can
abort the loop if we get cc 3, and we need to check only the valid
devices (dnv set).

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/main.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
index 67f4987..fd40fa5 100644
--- a/pc-bios/s390-ccw/main.c
+++ b/pc-bios/s390-ccw/main.c
@@ -22,7 +22,7 @@ void virtio_panic(const char *string)
 
 static void virtio_setup(void)
 {
-    struct irb irb;
+    struct schib schib;
     int i;
     int r;
     bool found = false;
@@ -31,8 +31,11 @@ static void virtio_setup(void)
 
     for (i = 0; i < 0x10000; i++) {
         blk_schid.sch_no = i;
-        r = tsch(blk_schid, &irb);
-        if (r != 3) {
+        r = stsch_err(blk_schid, &schib);
+        if (r == 3) {
+            break;
+        }
+        if (schib.pmcw.dnv) {
             if (virtio_is_blk(blk_schid)) {
                 found = true;
                 break;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 16/24] s390-ccw.img: Enhance drain_irqs().
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (14 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 15/24] s390-ccw.img: Detect devices with stsch Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 17/24] s390-ccw.img: Rudimentary error checking Alexander Graf
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Cornelia Huck, qemu-devel, Aurelien Jarno

From: Cornelia Huck <cornelia.huck@de.ibm.com>

- Use tpi + tsch to get interrupts.
- Return an error if the irb indicates problems.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/virtio.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 1968fc6..1bd17d4 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -38,12 +38,21 @@ static void virtio_notify(struct subchannel_id schid)
  *             Virtio functions                *
  ***********************************************/
 
-static void drain_irqs(struct subchannel_id schid)
+static int drain_irqs(struct subchannel_id schid)
 {
     struct irb irb = {};
+    int r = 0;
+
     while (1) {
+        /* FIXME: make use of TPI, for that enable subchannel and isc */
         if (tsch(schid, &irb)) {
-            return;
+            /* Might want to differentiate error codes later on. */
+            if (irb.scsw.cstat) {
+                r = -EIO;
+            } else if (irb.scsw.dstat != 0xc) {
+                r = -EIO;
+            }
+            return r;
         }
     }
 }
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 17/24] s390-ccw.img: Rudimentary error checking.
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (15 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 16/24] s390-ccw.img: Enhance drain_irqs() Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 18/24] s390-ccw.img: Get queue config from host Alexander Graf
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Cornelia Huck, qemu-devel, Aurelien Jarno

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Try to handle at least some of the errors that may happen.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/virtio.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index 1bd17d4..e0cede5 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -84,7 +84,9 @@ static int run_ccw(struct subchannel_id schid, int cmd, void *ptr, int len)
      *     assume that a simple tsch will have finished the CCW processing,
      *     but the architecture allows for asynchronous operation
      */
-    drain_irqs(schid);
+    if (!r) {
+        r = drain_irqs(schid);
+    }
     return r;
 }
 
@@ -92,7 +94,9 @@ static void virtio_set_status(struct subchannel_id schid,
                               unsigned long dev_addr)
 {
     unsigned char status = dev_addr;
-    run_ccw(schid, CCW_CMD_WRITE_STATUS, &status, sizeof(status));
+    if (run_ccw(schid, CCW_CMD_WRITE_STATUS, &status, sizeof(status))) {
+        virtio_panic("Could not write status to host!\n");
+    }
 }
 
 static void virtio_reset(struct subchannel_id schid)
@@ -193,6 +197,7 @@ static int virtio_read_many(ulong sector, void *load_addr, int sec_num)
 {
     struct virtio_blk_outhdr out_hdr;
     u8 status;
+    int r;
 
     /* Tell the host we want to read */
     out_hdr.type = VIRTIO_BLK_T_IN;
@@ -213,8 +218,11 @@ static int virtio_read_many(ulong sector, void *load_addr, int sec_num)
     /* Now we can tell the host to read */
     vring_wait_reply(&block, 0);
 
-    drain_irqs(block.schid);
-
+    r = drain_irqs(block.schid);
+    if (r) {
+        /* Well, whatever status is supposed to contain... */
+        status = 1;
+    }
     return status;
 }
 
@@ -262,8 +270,9 @@ void virtio_setup_block(struct subchannel_id schid)
     info.num = 128;
     block.schid = schid;
 
-    run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info));
-    virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);
+    if (!run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info))) {
+        virtio_set_status(schid, VIRTIO_CONFIG_S_DRIVER_OK);
+    }
 }
 
 bool virtio_is_blk(struct subchannel_id schid)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 18/24] s390-ccw.img: Get queue config from host.
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (16 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 17/24] s390-ccw.img: Rudimentary error checking Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 19/24] S390: ccw firmware: Add compiled blob Alexander Graf
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Cornelia Huck, qemu-devel, Aurelien Jarno

From: Cornelia Huck <cornelia.huck@de.ibm.com>

Ask the host about the configuration instead of guessing it.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 pc-bios/s390-ccw/virtio.c |   10 +++++++---
 pc-bios/s390-ccw/virtio.h |    5 +++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/pc-bios/s390-ccw/virtio.c b/pc-bios/s390-ccw/virtio.c
index e0cede5..5b9e1dc 100644
--- a/pc-bios/s390-ccw/virtio.c
+++ b/pc-bios/s390-ccw/virtio.c
@@ -257,17 +257,21 @@ int virtio_read(ulong sector, void *load_addr)
 void virtio_setup_block(struct subchannel_id schid)
 {
     struct vq_info_block info;
+    struct vq_config_block config = {};
 
     virtio_reset(schid);
 
-    /* XXX need to fetch the 128 from host */
-    vring_init(&block, 128, (void*)(100 * 1024 * 1024),
+    config.index = 0;
+    if (run_ccw(schid, CCW_CMD_READ_VQ_CONF, &config, sizeof(config))) {
+        virtio_panic("Could not get block device configuration\n");
+    }
+    vring_init(&block, config.num, (void*)(100 * 1024 * 1024),
                KVM_S390_VIRTIO_RING_ALIGN);
 
     info.queue = (100ULL * 1024ULL* 1024ULL);
     info.align = KVM_S390_VIRTIO_RING_ALIGN;
     info.index = 0;
-    info.num = 128;
+    info.num = config.num;
     block.schid = schid;
 
     if (!run_ccw(schid, CCW_CMD_SET_VQ, &info, sizeof(info))) {
diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h
index a33199d..86fdd57 100644
--- a/pc-bios/s390-ccw/virtio.h
+++ b/pc-bios/s390-ccw/virtio.h
@@ -53,6 +53,11 @@ struct vq_info_block {
     u16 num;
 } __attribute__((packed));
 
+struct vq_config_block {
+    u16 index;
+    u16 num;
+} __attribute__((packed));
+
 struct virtio_dev {
     struct virtio_dev_header *header;
     struct virtio_vqconfig *vqconfig;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 19/24] S390: ccw firmware: Add compiled blob
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (17 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 18/24] s390-ccw.img: Get queue config from host Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 20/24] S390: CCW: Use new, working firmware by default Alexander Graf
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

Now that we have all the source code ready, add a compiled blob into
the QEMU source tree, so that people without access to an s390 compiler
can run the s390-ccw firmware.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 Makefile             |    1 +
 pc-bios/s390-ccw.img |  Bin 0 -> 9432 bytes
 2 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 pc-bios/s390-ccw.img

diff --git a/Makefile b/Makefile
index e652764..8aca92f 100644
--- a/Makefile
+++ b/Makefile
@@ -295,6 +295,7 @@ qemu-icon.bmp \
 bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
 multiboot.bin linuxboot.bin kvmvapic.bin \
 s390-zipl.rom \
+s390-ccw.img \
 spapr-rtas.bin slof.bin \
 palcode-clipper
 else
diff --git a/pc-bios/s390-ccw.img b/pc-bios/s390-ccw.img
new file mode 100644
index 0000000000000000000000000000000000000000..149cf70140e9e690960b49337b4e5f419c452a86
GIT binary patch
literal 9432
zcmeHNeQaCR6+h2${M>x;8lu+Fh~7jIq|h3-Nw+ps<GCMcszt4VqNW4Z=BtTE8VB3y
zx(ba*bRw{onu?-{{^JR<#{^TeFhnyI^{r#<0~pyy2h%iR^r%2GXwMKtRv>S`bD!-d
z-9Jp)fAf{zJNKS@zV7dybFbt0fo+}b9*;uB=AmWiONN?RGM?w_E^X|RRHqH(Bb_Q}
z3C1j2?#^qHs2O)uphVSqI|VA`SkLE53Q1Jk9TliM;&(da_KSL6cifO-I!4MO3RaUl
zU!YQtb^c2|^7bV!MlS1JJI8j_OvNG!R+9N>1<HE2VXR8-mw)-cyl6?Xgg^;_5&|Uz
zN(ht?C?QZnpoBmPff52G1WE{ec?7cmv`47PvYq|Teda~{F@K)lUelN*%06IkkaNwL
zOOt=s2U6m=afav#C9Q;0_S5DV_!;A{<4pX46n!%73Ea@7rD>`)MN^F=#s$?IK`Jwj
zQpID6{SzaJ@h?a*UU9OffTt(Ti;m-*>k?^V>t&Dgn|@u}Xl$jWGL|D8OP3gP=XYb~
zsFN{fo%f~w!!o7;jI-I}woXmv46OdjvcJHJEWs|qrk$Sl(k5v?XyVHN?*kXg?6gLR
z$}g=Pkx|@#l1wim+!Icj0xMIU1lFxOBbJt0PATI$@?dtaB~mb9O{M|>Duns{(z1fc
zlGJiRouM(dya$$5=XT?FL|8$cwHgk+(;h<nw8MCnG~*4$=Cw$<uZ33&vO>ZS886-C
zMsDmNch!b*v*Un2Wh9+{$cUTSC%G5~W&fhl>^PSGF?*?_#_aKrGUQcf5w!xX52cnz
zO3q+C^|ZYD9iy3JbKVQ5QX;H<l%5v!7-Sy-?}Dmk&)HphJXg9IVyr?uSn>RO<|N+l
zvNg~5OcVR|*9&EnWEK%E`y(Sd|7W1B&d*4l*DawTHmP&3#Oj-Qoh04Ha?V*xn+Z^Z
z@iMKJdS`(pRDf5L6`BDu#wsO)9zmvwwi-83C1W@L3?iL_<ymABS=z0(<27y}1z0Zy
zzP53L^C?#JfsAv6aVYz-#Gw<2u9m&+lADnIu%+h^r?JX$T)XP5oE?-a`W7rbD=mE&
zy}tty1@?b~{#i2u%TFS5zi$tat=9!&ZzeBj1*jeoS^!TKo;o~Qmx$1mpa#@QXgoyq
z>b$C2Gxng1dD(YPlHj%9f+%alnx+KSu2^@HU^D4lGIe-qGTNvHUj4r7^^i_Rn==RM
z2fcKHbWd%|iEH%=^eTa9m2nNx7DdozB|^puMEw=#QkOQv5!4kbReJZT^K8BR6C*%1
zhM#=8rsK;#-Oo0Q7H1vH%@50-KjYkI_#KBm1f~L}rR7kEf!a4KbFI17u*l&w5PTY#
z<0h*Ax3FdAuA5pXdGdtV9LnjC>xk&Nt;UVcTtwtHJu#Nss7G>}!EZe=mTQ}8k@AGE
z66<S$0WE)XpPjbTVPU5OE2h@VS#4ayEbsc<Ny2G!l&U#0?C2R;6(V~sm*%QCS!F*1
zsZV6wvraDioE@Pi<2HqW_IW(d<9QlSIXnd{4O{88bfnHQt^q5gdFZj}hp1_K88vo<
zOkcJU--A}`>ol(=OfRZEWFlX|^-^^pGO=ggv8F=!UeeMQ%r52G$d5w)ypDERN55UG
z>e5ZF<hrbsb1mxOP>n0?+D6|`{tivl7}w(b1?_?d?njs^T>DfBDZ~#cPhQG{IB<G(
zn5IuRHIH09_8m2UnsLCMX0WFLVl<w@^RlrQmUfV4iJYIB!l4{Rv>c%>{GAse*ZZ(Z
zOTa;OqXzGWMjImUl=Byiy-JznN96c*Xs?7V1$>-Gkl#90p3^wzI?q``M_gT`3t$e6
z_i8$y$UDOkI~^fAjT|epP&e3zjYJPNmD7VnTP=;XaK5mHfW}cL3m%^sIN>7Tpx*qv
z9@qyLI8}8CUAP$(sGVAmN^GPnvnNSDH&4iWLdmT}7NyurZY8C%r*k8mM;sSw|5aX(
zJb!wC;oF58R!#v)+(U@<U96VgbY#Zrc3Pe#J@OQ+?Lr1mTu;s(F+<3HXI#+A?Asq9
zPCm!gd0xZ9vAain&nYpS%N<;OIL9|q3*Q&mDO4e_dS3bn@u~wi>6-mKB-Vv>(7h!0
zX}(eVkKvB<cX}*gzkr-xM&~DLe0sK?b2IxIXLUrRX(H&;ElOkWr~TAmiL}PKj1c_r
ztpsj@?W<w?DcIJ+OW$xNmfJXq(*bJIabmGWi|nVUsYA10KrBDwh$E9}VFWZ}lKres
z_Gymyi?<NdQCb45n^8Zfk!?Wvgx7vi`dAAeFLEwQ+4C%ma~);rX4q$^7VGg0y~DDf
zJ&IjAR><${)fA$t{GE24hqHVN&jdVI!UAeVp8lt8o4rF?P?c*d@Jr+OdGBi`UO|1-
z(M`o{hoAW#qk$Y`>{VP5t}V>pI31wX*f(iUT6#%FwFOaqsG^xR`M<u&nEh-!DwRl`
zn!<&MMjleez$mnxF>xpwPex;FdWP;5ef@``z5U`qY;?G<p@OKrJ37?gCz3HS6zlF2
zyY3JN;<1Bbushx-`l5+@E9l6MNGDNr_)zyyv`-xD9*FkR0auGvqQe6s(LZpoe>hoD
z;KxUYhnasQIx++wuKRuQ{_ehlL_w1!+C(ALB2{gV?5j346q)E?Ea-6le@BP%bi+DV
z81p`zyjx<ULw#a6mJ|d1NzpSD>n*OjH#U4AIxrgV1{%W^bXoG-@o2JNB$D09(F9{L
z7)vA>ognSFd6(E0kH_MqtSGw$E|Pev9p@8dBc(u_K+k~w1@wK#`4nR%;5c);L3Pj{
zf_6F1zqW$nGw&trm6Aqwp~e)`aXycL+Msvia}n;H&(DH}kkxab`(cw?9lvleAFipo
zDy{IqZS1?AyJ`k6x7D{FFMrh6USk$PAzF<o_?L209^FYPcTD|(|NBcGsd%_@yy~Iq
z_L@1V#qzvPQZw`#Q+VI`AM%|wrq7+^IG*ONn(^fAE1?DQkd$_L9nzkfDeGi;w9R-}
z=UpCvpJIykT>G)&zrtW&@iJ4*csDUcdu@UJ_L}$0m<Kxw$4+Xdoc9M!@wK}v<N@Xs
z=~vD8xMt9l4GZi%QUTngC3h0>D))0&&8QtN3;)5yoecitJO+O^Q?&hgJ6Nj>m3i#%
zEO#LHbEX)#E%Mh{^VZ^hQa)fQHRHFLqCI|v{K9>8B}(rS0wo0gpAp~#2WJ(PZQpq(
zWp@7Qo^5}7Y5kKwJ=OZw;V-_ieC*VQ?OV3AiRL@*yknc_j1G?;UL{(CEx}fC*FbOY
zn$~?SYkK0{!@Ywdj!y>(+>K)G`gI$>+Hw!=N{sB;j(adMm`KKx-8~dc_8(4CuqTnA
zAnw@y;K1-`uxB(n)VC(uN5OckuRGaI!T!O02jbla`}Ym@#V?O2*c&^@pA?FnAjcHk
z71^EmU+iBcj1;a%c{Qn-g4z6WPfI2XoIK6n6LPc^@4{GK1Ngj=Zz50Ap#sOH1-o*@
zzk?}UTJl&Q%m2;<Uq7Vsdbm3lwc=#~F8)p|#xM2pdzwjC`kFjd3inXKNFiPxuf<bX
ze_r4H-3gKVI~2?(S#UvH=>Jymuh6d?ab;KJsRy517PW=`@wY@#KeR}S8uIra;cu`-
st>BO8?RW~~EA>CjYvn(36m1mbnewyX`Yy_#)9`VA)W496enFr94f-tkLjV8(

literal 0
HcmV?d00001

-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 20/24] S390: CCW: Use new, working firmware by default
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (18 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 19/24] S390: ccw firmware: Add compiled blob Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 21/24] Common: Add quick access to first boot device Alexander Graf
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno

Since we now have working firmware for s390-ccw in the tree, we can
default to it on our s390-ccw machine, rendering it more useful.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/s390x/s390-virtio-ccw.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 8ea193e..eb774d9 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -83,7 +83,7 @@ static void ccw_init(QEMUMachineInitArgs *args)
     css_bus = virtual_css_bus_init();
     s390_sclp_init();
     s390_init_ipl_dev(args->kernel_filename, args->kernel_cmdline,
-                      args->initrd_filename, "s390-zipl.rom");
+                      args->initrd_filename, "s390-ccw.img");
 
     /* register hypercalls */
     virtio_ccw_register_hcalls();
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 21/24] Common: Add quick access to first boot device
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (19 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 20/24] S390: CCW: Use new, working firmware by default Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 22/24] Allow selective runtime register synchronization Alexander Graf
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, Dominik Dingel, qemu-devel, Aurelien Jarno

From: Dominik Dingel <dingel@linux.vnet.ibm.com>

Instead of manually parsing the boot_list as character stream,
we can access the nth boot device, specified by the position in the
boot order.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/sysemu/sysemu.h |    2 ++
 vl.c                    |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 6578782..43b961c 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -181,6 +181,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix);
 char *get_boot_devices_list(size_t *size);
 
+DeviceState *get_boot_device(uint32_t position);
+
 bool usb_enabled(bool default_usb);
 
 extern QemuOptsList qemu_drive_opts;
diff --git a/vl.c b/vl.c
index 2e0d1a7..322ea80 100644
--- a/vl.c
+++ b/vl.c
@@ -1222,6 +1222,24 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
 }
 
+DeviceState *get_boot_device(uint32_t position)
+{
+    uint32_t counter = 0;
+    FWBootEntry *i = NULL;
+    DeviceState *res = NULL;
+
+    if (!QTAILQ_EMPTY(&fw_boot_order)) {
+        QTAILQ_FOREACH(i, &fw_boot_order, link) {
+            if (counter == position) {
+                res = i->dev;
+                break;
+            }
+            counter++;
+        }
+    }
+    return res;
+}
+
 /*
  * This function returns null terminated string that consist of new line
  * separated device paths.
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 22/24] Allow selective runtime register synchronization
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (20 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 21/24] Common: Add quick access to first boot device Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 23/24] Utilize selective runtime reg sync for hot code paths Alexander Graf
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno, Jason J. Herne

From: Jason J. Herne <jjherne@us.ibm.com>

We want to avoid expensive register synchronization IOCTL's on the hot path so
a new kvm_s390_get_registers_partial() is introduced as a compliment to
kvm_arch_get_registers().  The new function is called on the hot path, and
kvm_arch_get_registers() is called when we need the complete runtime register
state.

kvm_arch_put_registers() is updated to only sync the partial runtime set when
we've only dirtied the partial runtime set.  This is to avoid sending bad data
back to KVM if we've only partially synced the runtime register set.

Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-s390x/cpu.h |   17 +++++++++++++
 target-s390x/kvm.c |   67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index e351005..0ce82cf 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -78,6 +78,11 @@ typedef struct MchkQueue {
     uint16_t type;
 } MchkQueue;
 
+/* Defined values for CPUS390XState.runtime_reg_dirty_mask */
+#define KVM_S390_RUNTIME_DIRTY_NONE     0
+#define KVM_S390_RUNTIME_DIRTY_PARTIAL  1
+#define KVM_S390_RUNTIME_DIRTY_FULL     2
+
 typedef struct CPUS390XState {
     uint64_t regs[16];     /* GP registers */
     CPU_DoubleU fregs[16]; /* FP registers */
@@ -121,6 +126,13 @@ typedef struct CPUS390XState {
     uint64_t cputm;
     uint32_t todpr;
 
+    /* on S390 the runtime register set has two dirty states:
+     * a partial dirty state in which only the registers that
+     * are needed all the time are fetched. And a fully dirty
+     * state in which all runtime registers are fetched.
+     */
+    uint32_t runtime_reg_dirty_mask;
+
     CPU_COMMON
 
     /* reset does memset(0) up to here */
@@ -1068,6 +1080,7 @@ void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t subchannel_id,
                            uint32_t io_int_word);
 void kvm_s390_crw_mchk(S390CPU *cpu);
 void kvm_s390_enable_css_support(S390CPU *cpu);
+int kvm_s390_get_registers_partial(CPUState *cpu);
 #else
 static inline void kvm_s390_io_interrupt(S390CPU *cpu,
                                         uint16_t subchannel_id,
@@ -1082,6 +1095,10 @@ static inline void kvm_s390_crw_mchk(S390CPU *cpu)
 static inline void kvm_s390_enable_css_support(S390CPU *cpu)
 {
 }
+static inline int kvm_s390_get_registers_partial(CPUState *cpu)
+{
+    return -ENOSYS;
+}
 #endif
 
 static inline void s390_io_interrupt(S390CPU *cpu,
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 644f484..02b2e39 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -123,6 +123,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 {
     S390CPU *cpu = S390_CPU(cs);
     CPUS390XState *env = &cpu->env;
+    struct kvm_one_reg reg;
     struct kvm_sregs sregs;
     struct kvm_regs regs;
     int ret;
@@ -147,6 +148,30 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         }
     }
 
+    if (env->runtime_reg_dirty_mask == KVM_S390_RUNTIME_DIRTY_FULL) {
+        reg.id = KVM_REG_S390_CPU_TIMER;
+        reg.addr = (__u64)&(env->cputm);
+        ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
+        if (ret < 0) {
+            return ret;
+        }
+
+        reg.id = KVM_REG_S390_CLOCK_COMP;
+        reg.addr = (__u64)&(env->ckc);
+        ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
+        if (ret < 0) {
+            return ret;
+        }
+
+        reg.id = KVM_REG_S390_TODPR;
+        reg.addr = (__u64)&(env->todpr);
+        ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
+        if (ret < 0) {
+            return ret;
+        }
+    }
+    env->runtime_reg_dirty_mask = KVM_S390_RUNTIME_DIRTY_NONE;
+
     /* Do we need to save more than that? */
     if (level == KVM_PUT_RUNTIME_STATE) {
         return 0;
@@ -186,11 +211,52 @@ int kvm_arch_get_registers(CPUState *cs)
 {
     S390CPU *cpu = S390_CPU(cs);
     CPUS390XState *env = &cpu->env;
+    struct kvm_one_reg reg;
+    int r;
+
+    r = kvm_s390_get_registers_partial(cs);
+    if (r < 0) {
+        return r;
+    }
+
+    reg.id = KVM_REG_S390_CPU_TIMER;
+    reg.addr = (__u64)&(env->cputm);
+    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
+    if (r < 0) {
+        return r;
+    }
+
+    reg.id = KVM_REG_S390_CLOCK_COMP;
+    reg.addr = (__u64)&(env->ckc);
+    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
+    if (r < 0) {
+        return r;
+    }
+
+    reg.id = KVM_REG_S390_TODPR;
+    reg.addr = (__u64)&(env->todpr);
+    r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
+    if (r < 0) {
+        return r;
+    }
+
+    env->runtime_reg_dirty_mask = KVM_S390_RUNTIME_DIRTY_FULL;
+    return 0;
+}
+
+int kvm_s390_get_registers_partial(CPUState *cs)
+{
+    S390CPU *cpu = S390_CPU(cs);
+    CPUS390XState *env = &cpu->env;
     struct kvm_sregs sregs;
     struct kvm_regs regs;
     int ret;
     int i;
 
+    if (env->runtime_reg_dirty_mask) {
+        return 0;
+    }
+
     /* get the PSW */
     env->psw.addr = cs->kvm_run->psw_addr;
     env->psw.mask = cs->kvm_run->psw_mask;
@@ -236,6 +302,7 @@ int kvm_arch_get_registers(CPUState *cs)
         /* no prefix without sync regs */
     }
 
+    env->runtime_reg_dirty_mask = KVM_S390_RUNTIME_DIRTY_PARTIAL;
     return 0;
 }
 
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 23/24] Utilize selective runtime reg sync for hot code paths
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (21 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 22/24] Allow selective runtime register synchronization Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 24/24] virtio-rng-s390: add properties Alexander Graf
  2013-04-26 20:14 ` [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Blue Swirl
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno, Jason J. Herne

From: Jason J. Herne <jjherne@us.ibm.com>

Make use of new kvm_s390_get_registers_partial() for kvm_handle_css_inst() and
handle_hypercall() since they only need registers from the partial set and they
are called quite frequently.

Signed-off-by: Jason J. Herne <jjherne@us.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-s390x/kvm.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 02b2e39..fb006ee 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -467,12 +467,16 @@ static int kvm_handle_css_inst(S390CPU *cpu, struct kvm_run *run,
     int r = 0;
     int no_cc = 0;
     CPUS390XState *env = &cpu->env;
+    CPUState *cs = ENV_GET_CPU(env);
 
     if (ipa0 != 0xb2) {
         /* Not handled for now. */
         return -1;
     }
-    cpu_synchronize_state(env);
+
+    kvm_s390_get_registers_partial(cs);
+    cs->kvm_vcpu_dirty = true;
+
     switch (ipa1) {
     case PRIV_XSCH:
         r = ioinst_handle_xsch(env, env->regs[1]);
@@ -603,7 +607,10 @@ static int handle_priv(S390CPU *cpu, struct kvm_run *run,
 
 static int handle_hypercall(CPUS390XState *env, struct kvm_run *run)
 {
-    cpu_synchronize_state(env);
+    CPUState *cs = ENV_GET_CPU(env);
+
+    kvm_s390_get_registers_partial(cs);
+    cs->kvm_vcpu_dirty = true;
     env->regs[2] = s390_virtio_hypercall(env);
 
     return 0;
@@ -808,7 +815,9 @@ static int handle_tsch(S390CPU *cpu)
     struct kvm_run *run = cs->kvm_run;
     int ret;
 
-    cpu_synchronize_state(env);
+    kvm_s390_get_registers_partial(cs);
+    cs->kvm_vcpu_dirty = true;
+
     ret = ioinst_handle_tsch(env, env->regs[1], run->s390_tsch.ipb);
     if (ret >= 0) {
         /* Success; set condition code. */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 24/24] virtio-rng-s390: add properties.
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (22 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 23/24] Utilize selective runtime reg sync for hot code paths Alexander Graf
@ 2013-04-26 18:19 ` Alexander Graf
  2013-04-26 20:14 ` [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Blue Swirl
  24 siblings, 0 replies; 26+ messages in thread
From: Alexander Graf @ 2013-04-26 18:19 UTC (permalink / raw)
  To: qemu-ppc; +Cc: Blue Swirl, qemu-devel, Aurelien Jarno, KONRAD Frederic

From: KONRAD Frederic <fred.konrad@greensocs.com>

I don't see any reason why these properties are missing.

Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>

Note: Need to apply virtio-rng-refactoring first!
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/s390x/s390-virtio-bus.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index a7e81d1..2cff6b7 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -531,11 +531,19 @@ static const TypeInfo s390_virtio_serial = {
     .class_init    = s390_virtio_serial_class_init,
 };
 
+static Property s390_virtio_rng_properties[] = {
+    DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
+    DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNGS390, vdev.conf),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
 {
+    DeviceClass *dc = DEVICE_CLASS(klass);
     VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
 
     k->init = s390_virtio_rng_init;
+    dc->props = s390_virtio_rng_properties;
 }
 
 static const TypeInfo s390_virtio_rng = {
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26
  2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
                   ` (23 preceding siblings ...)
  2013-04-26 18:19 ` [Qemu-devel] [PATCH 24/24] virtio-rng-s390: add properties Alexander Graf
@ 2013-04-26 20:14 ` Blue Swirl
  24 siblings, 0 replies; 26+ messages in thread
From: Blue Swirl @ 2013-04-26 20:14 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-ppc, qemu-devel, Aurelien Jarno

On Fri, Apr 26, 2013 at 6:19 PM, Alexander Graf <agraf@suse.de> wrote:
> Hi Blue / Aurelien,
>
> This is my current patch queue for s390.  Please pull.

Thanks, pulled.

>
> Alex
>
>
> The following changes since commit bf9b255f484fd61cbaa91faeff254140a0ecd18c:
>   Anthony Liguori (1):
>         gtk: refactor menu creation
>
> are available in the git repository at:
>
>   git://github.com/agraf/qemu.git s390-for-upstream
>
> Alexander Graf (12):
>       S390: Make IPL reset address dynamic
>       S390: IPL: Support ELF firmware
>       S390: IPL: Use different firmware for different machines
>       S390: ccw firmware: Add start assembly
>       S390: ccw firmware: Add main program
>       S390: ccw firmware: Add sclp output
>       S390: ccw firmware: Add virtio device drivers
>       S390: ccw firmware: Add glue header
>       S390: ccw firmware: Add bootmap interpreter
>       S390: ccw firmware: Add Makefile
>       S390: ccw firmware: Add compiled blob
>       S390: CCW: Use new, working firmware by default
>
> Christian Borntraeger (4):
>       s390-ccw.img: replace while loop with a disabled wait on s390 bios
>       s390-ccw.img: build s390-ccw rom on s3900 system by default
>       s390-ccw.img: Take care of the elf->img transition
>       s390-ccw.img: Fix compile warning in s390 ccw virtio code
>
> Cornelia Huck (4):
>       s390-ccw.img: Detect devices with stsch.
>       s390-ccw.img: Enhance drain_irqs().
>       s390-ccw.img: Rudimentary error checking.
>       s390-ccw.img: Get queue config from host.
>
> Dominik Dingel (1):
>       Common: Add quick access to first boot device
>
> Jason J. Herne (2):
>       Allow selective runtime register synchronization
>       Utilize selective runtime reg sync for hot code paths
>
> KONRAD Frederic (1):
>       virtio-rng-s390: add properties.
>
>  .gitignore                    |    2 +
>  Makefile                      |    1 +
>  configure                     |    7 +-
>  hw/s390x/ipl.c                |   41 +++---
>  hw/s390x/s390-virtio-bus.c    |    8 +
>  hw/s390x/s390-virtio-ccw.c    |    2 +-
>  hw/s390x/s390-virtio.c        |    7 +-
>  hw/s390x/s390-virtio.h        |    3 +-
>  include/sysemu/sysemu.h       |    2 +
>  pc-bios/s390-ccw.img          |  Bin 0 -> 9432 bytes
>  pc-bios/s390-ccw/Makefile     |   26 ++++
>  pc-bios/s390-ccw/bootmap.c    |  235 ++++++++++++++++++++++++++++++
>  pc-bios/s390-ccw/cio.h        |  322 +++++++++++++++++++++++++++++++++++++++++
>  pc-bios/s390-ccw/main.c       |   61 ++++++++
>  pc-bios/s390-ccw/s390-ccw.h   |  134 +++++++++++++++++
>  pc-bios/s390-ccw/sclp-ascii.c |   81 ++++++++++
>  pc-bios/s390-ccw/sclp.h       |  107 ++++++++++++++
>  pc-bios/s390-ccw/start.S      |   31 ++++
>  pc-bios/s390-ccw/virtio.c     |  298 ++++++++++++++++++++++++++++++++++++++
>  pc-bios/s390-ccw/virtio.h     |  163 +++++++++++++++++++++
>  target-s390x/cpu.h            |   17 ++
>  target-s390x/kvm.c            |   82 ++++++++++-
>  vl.c                          |   18 +++
>  23 files changed, 1622 insertions(+), 26 deletions(-)
>  create mode 100644 pc-bios/s390-ccw.img
>  create mode 100644 pc-bios/s390-ccw/Makefile
>  create mode 100644 pc-bios/s390-ccw/bootmap.c
>  create mode 100644 pc-bios/s390-ccw/cio.h
>  create mode 100644 pc-bios/s390-ccw/main.c
>  create mode 100644 pc-bios/s390-ccw/s390-ccw.h
>  create mode 100644 pc-bios/s390-ccw/sclp-ascii.c
>  create mode 100644 pc-bios/s390-ccw/sclp.h
>  create mode 100644 pc-bios/s390-ccw/start.S
>  create mode 100644 pc-bios/s390-ccw/virtio.c
>  create mode 100644 pc-bios/s390-ccw/virtio.h

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-04-26 20:15 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-26 18:19 [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 01/24] S390: Make IPL reset address dynamic Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 02/24] S390: IPL: Support ELF firmware Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 03/24] S390: IPL: Use different firmware for different machines Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 04/24] S390: ccw firmware: Add start assembly Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 05/24] S390: ccw firmware: Add main program Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 06/24] S390: ccw firmware: Add sclp output Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 07/24] S390: ccw firmware: Add virtio device drivers Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 08/24] S390: ccw firmware: Add glue header Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 09/24] S390: ccw firmware: Add bootmap interpreter Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 10/24] S390: ccw firmware: Add Makefile Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 11/24] s390-ccw.img: replace while loop with a disabled wait on s390 bios Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 12/24] s390-ccw.img: build s390-ccw rom on s3900 system by default Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 13/24] s390-ccw.img: Take care of the elf->img transition Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 14/24] s390-ccw.img: Fix compile warning in s390 ccw virtio code Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 15/24] s390-ccw.img: Detect devices with stsch Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 16/24] s390-ccw.img: Enhance drain_irqs() Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 17/24] s390-ccw.img: Rudimentary error checking Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 18/24] s390-ccw.img: Get queue config from host Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 19/24] S390: ccw firmware: Add compiled blob Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 20/24] S390: CCW: Use new, working firmware by default Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 21/24] Common: Add quick access to first boot device Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 22/24] Allow selective runtime register synchronization Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 23/24] Utilize selective runtime reg sync for hot code paths Alexander Graf
2013-04-26 18:19 ` [Qemu-devel] [PATCH 24/24] virtio-rng-s390: add properties Alexander Graf
2013-04-26 20:14 ` [Qemu-devel] [PULL 00/24] s390 patch queue 2013-04-26 Blue Swirl

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).