* [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18
@ 2013-01-18 18:12 Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 1/8] s390: new contributions GPLv2 or later Alexander Graf
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Aurélien Jarno
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]
Hi Blue / Aurelien,
This is my current patch queue for s390. Please pull.
Alex
The following changes since commit ddc01bf16e9f04b3e72c1b946b0b8efeb7a545d2:
Anthony Liguori (1):
Merge remote-tracking branch 'luiz/queue/qmp' into staging
are available in the git repository at:
git://repo.or.cz/qemu/agraf.git s390-for-upstream
Alexander Graf (1):
s390x: fix indentation
Andreas Färber (1):
target-s390x: Unregister reset callback on finalization
Christian Borntraeger (2):
s390: new contributions GPLv2 or later
s390: Move IPL code into a separate device
Cornelia Huck (1):
s390: Add a hypercall registration interface.
Jens Freimann (1):
s390: Add CPU reset handler
Stefan Weil (1):
s390x: Remove inline function ebcdic_put and related data from cpu.h
Viktor Mihajlovski (1):
S390: Enable -cpu help and QMP query-cpu-definitions
hw/s390-virtio.c | 194 ++++++++++++++----------------------------
hw/s390-virtio.h | 22 +++++
hw/s390x/Makefile.objs | 2 +
hw/s390x/ipl.c | 174 +++++++++++++++++++++++++++++++++++++
hw/s390x/s390-virtio-hcall.c | 36 ++++++++
target-s390x/cpu.c | 71 +++++++++++++++-
target-s390x/cpu.h | 91 ++------------------
target-s390x/kvm.c | 17 +++-
target-s390x/misc_helper.c | 83 ++++++++++++++++++-
9 files changed, 470 insertions(+), 220 deletions(-)
create mode 100644 hw/s390-virtio.h
create mode 100644 hw/s390x/ipl.c
create mode 100644 hw/s390x/s390-virtio-hcall.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 1/8] s390: new contributions GPLv2 or later
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device Alexander Graf
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Christian Borntraeger, Aurélien Jarno
From: Christian Borntraeger <borntraeger@de.ibm.com>
IBMs s390 contributions were meant to to be gplv2 or later (since
we were contributing to qemu). Several of the s390 specific files
link to gpl code anyway, so lets clarify the licence statement for
new contributions for those files that we have touched multiple
times or will likely touch again.
This patch does not touch files that mostly deal with tcg.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-s390x/cpu.h | 5 ++++-
target-s390x/kvm.c | 6 +++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index bc3fab2..1fa3ad3 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -13,7 +13,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
+ * Contributions after 2012-10-29 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CPU_S390X_H
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 6ec5e6d..5785f7d 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -2,6 +2,7 @@
* QEMU S390x KVM implementation
*
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
+ * Copyright IBM Corp. 2012
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,7 +14,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
+ * Contributions after 2012-10-29 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 1/8] s390: new contributions GPLv2 or later Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:37 ` Andreas Färber
2013-01-18 18:12 ` [Qemu-devel] [PATCH 3/8] S390: Enable -cpu help and QMP query-cpu-definitions Alexander Graf
` (6 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Blue Swirl, Christian Borntraeger, Jens Freimann,
Aurélien Jarno
From: Christian Borntraeger <borntraeger@de.ibm.com>
Lets move the code to setup IPL for external kernel
or via the zipl rom into a separate file. This allows to
- define a reboot handler, setting up the PSW appropriately
- enhance the boot code to IPL disks that contain a bootmap that
was created with zipl under LPAR or z/VM (future patch)
- reuse that code for several machines (e.g. virtio-ccw and virtio-s390)
- allow different machines to provide different defaults
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
[agraf: symbolify initial psw, adjust header file location, fix for QOM]
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/s390-virtio.c | 98 +++------------------------
hw/s390x/Makefile.objs | 1 +
hw/s390x/ipl.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 185 insertions(+), 88 deletions(-)
create mode 100644 hw/s390x/ipl.c
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 0e93cc3..13f93fb 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -25,7 +25,6 @@
#include "boards.h"
#include "monitor/monitor.h"
#include "loader.h"
-#include "elf.h"
#include "hw/virtio.h"
#include "hw/sysbus.h"
#include "sysemu/kvm.h"
@@ -48,17 +47,6 @@
#define KVM_S390_VIRTIO_RESET 1
#define KVM_S390_VIRTIO_SET_STATUS 2
-#define KERN_IMAGE_START 0x010000UL
-#define KERN_PARM_AREA 0x010480UL
-#define INITRD_START 0x800000UL
-#define INITRD_PARM_START 0x010408UL
-#define INITRD_PARM_SIZE 0x010410UL
-#define PARMFILE_START 0x001000UL
-
-#define ZIPL_START 0x009000UL
-#define ZIPL_LOAD_ADDR 0x009000UL
-#define ZIPL_FILENAME "s390-zipl.rom"
-
#define MAX_BLK_DEVS 10
static VirtIOS390Bus *s390_bus;
@@ -156,15 +144,10 @@ static void s390_init(QEMUMachineInitArgs *args)
{
ram_addr_t my_ram_size = args->ram_size;
const char *cpu_model = args->cpu_model;
- const char *kernel_filename = args->kernel_filename;
- const char *kernel_cmdline = args->kernel_cmdline;
- const char *initrd_filename = args->initrd_filename;
CPUS390XState *env = NULL;
+ DeviceState *dev;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
- ram_addr_t kernel_size = 0;
- ram_addr_t initrd_offset;
- ram_addr_t initrd_size = 0;
int shift = 0;
uint8_t *storage_keys;
void *virtio_region;
@@ -185,6 +168,15 @@ static void s390_init(QEMUMachineInitArgs *args)
/* get a BUS */
s390_bus = s390_virtio_bus_init(&my_ram_size);
s390_sclp_init();
+ dev = qdev_create(NULL, "s390-ipl");
+ if (args->kernel_filename) {
+ qdev_prop_set_string(dev, "kernel", args->kernel_filename);
+ }
+ if (args->initrd_filename) {
+ qdev_prop_set_string(dev, "initrd", args->initrd_filename);
+ }
+ qdev_prop_set_string(dev, "cmdline", args->kernel_cmdline);
+ qdev_init_nofail(dev);
/* allocate RAM */
memory_region_init_ram(ram, "s390.ram", my_ram_size);
@@ -225,76 +217,6 @@ static void s390_init(QEMUMachineInitArgs *args)
tmp_env->storage_keys = storage_keys;
}
- /* One CPU has to run */
- s390_add_running_cpu(env);
-
- if (kernel_filename) {
-
- kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, NULL,
- NULL, 1, ELF_MACHINE, 0);
- if (kernel_size == -1UL) {
- kernel_size = load_image_targphys(kernel_filename, 0, ram_size);
- }
- if (kernel_size == -1UL) {
- fprintf(stderr, "qemu: could not load kernel '%s'\n",
- kernel_filename);
- exit(1);
- }
- /*
- * 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.
- */
- env->psw.addr = KERN_IMAGE_START;
- env->psw.mask = 0x0000000180000000ULL;
- } else {
- ram_addr_t bios_size = 0;
- char *bios_filename;
-
- /* Load zipl bootloader */
- if (bios_name == NULL) {
- bios_name = ZIPL_FILENAME;
- }
-
- bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
- bios_size = load_image_targphys(bios_filename, ZIPL_LOAD_ADDR, 4096);
- 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");
- }
-
- env->psw.addr = ZIPL_START;
- env->psw.mask = 0x0000000180000000ULL;
- }
-
- if (initrd_filename) {
- initrd_offset = INITRD_START;
- while (kernel_size + 0x100000 > initrd_offset) {
- initrd_offset += 0x100000;
- }
- initrd_size = load_image_targphys(initrd_filename, initrd_offset,
- ram_size - initrd_offset);
- if (initrd_size == -1UL) {
- fprintf(stderr, "qemu: could not load initrd '%s'\n",
- initrd_filename);
- exit(1);
- }
-
- /* we have to overwrite values in the kernel image, which are "rom" */
- stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
- stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
- }
-
- if (rom_ptr(KERN_PARM_AREA)) {
- /* we have to overwrite values in the kernel image, which are "rom" */
- memcpy(rom_ptr(KERN_PARM_AREA), kernel_cmdline,
- strlen(kernel_cmdline) + 1);
- }
/* Create VirtIO network adapters */
for(i = 0; i < nb_nics; i++) {
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
index 096dfcd..4a5a5d8 100644
--- a/hw/s390x/Makefile.objs
+++ b/hw/s390x/Makefile.objs
@@ -4,3 +4,4 @@ obj-y := $(addprefix ../,$(obj-y))
obj-y += sclp.o
obj-y += event-facility.o
obj-y += sclpquiesce.o sclpconsole.o
+obj-y += ipl.o
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
new file mode 100644
index 0000000..7cbbf99
--- /dev/null
+++ b/hw/s390x/ipl.c
@@ -0,0 +1,174 @@
+/*
+ * bootloader support
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ * Christian Borntraeger <borntraeger@de.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version. See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "sysemu/sysemu.h"
+#include "cpu.h"
+#include "elf.h"
+#include "hw/loader.h"
+#include "hw/sysbus.h"
+
+#define KERN_IMAGE_START 0x010000UL
+#define KERN_PARM_AREA 0x010480UL
+#define INITRD_START 0x800000UL
+#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)
+
+#define TYPE_S390_IPL "s390-ipl"
+#define S390_IPL(obj) \
+ OBJECT_CHECK(S390IPLState, (obj), TYPE_S390_IPL)
+#if 0
+#define S390_IPL_CLASS(klass) \
+ OBJECT_CLASS_CHECK(S390IPLState, (klass), TYPE_S390_IPL)
+#define S390_IPL_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(S390IPLState, (obj), TYPE_S390_IPL)
+#endif
+
+typedef struct S390IPLClass {
+ /*< private >*/
+ SysBusDeviceClass parent_class;
+ /*< public >*/
+
+ void (*parent_reset) (SysBusDevice *dev);
+} S390IPLClass;
+
+typedef struct S390IPLState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ char *kernel;
+ char *initrd;
+ char *cmdline;
+} S390IPLState;
+
+
+static void s390_ipl_cpu(uint64_t pswaddr)
+{
+ CPUS390XState *env = &S390_CPU(qemu_get_cpu(0))->env;
+ env->psw.addr = pswaddr;
+ env->psw.mask = IPL_PSW_MASK;
+ s390_add_running_cpu(env);
+}
+
+static int s390_ipl_init(SysBusDevice *dev)
+{
+ S390IPLState *ipl = S390_IPL(dev);
+ ram_addr_t kernel_size = 0;
+
+ if (!ipl->kernel) {
+ ram_addr_t bios_size = 0;
+ char *bios_filename;
+
+ /* Load zipl bootloader */
+ if (bios_name == NULL) {
+ bios_name = ZIPL_FILENAME;
+ }
+
+ bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+ bios_size = load_image_targphys(bios_filename, ZIPL_IMAGE_START, 4096);
+ 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,
+ NULL, 1, ELF_MACHINE, 0);
+ if (kernel_size == -1UL) {
+ kernel_size = load_image_targphys(ipl->kernel, 0, ram_size);
+ }
+ if (kernel_size == -1UL) {
+ fprintf(stderr, "could not load kernel '%s'\n", ipl->kernel);
+ return -1;
+ }
+ /* we have to overwrite values in the kernel image, which are "rom" */
+ strcpy(rom_ptr(KERN_PARM_AREA), ipl->cmdline);
+ }
+ if (ipl->initrd) {
+ ram_addr_t initrd_offset, initrd_size;
+
+ initrd_offset = INITRD_START;
+ while (kernel_size + 0x100000 > initrd_offset) {
+ initrd_offset += 0x100000;
+ }
+ initrd_size = load_image_targphys(ipl->initrd, initrd_offset,
+ ram_size - initrd_offset);
+ if (initrd_size == -1UL) {
+ fprintf(stderr, "qemu: could not load initrd '%s'\n", ipl->initrd);
+ exit(1);
+ }
+
+ /* we have to overwrite values in the kernel image, which are "rom" */
+ stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
+ stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
+ }
+
+ return 0;
+}
+
+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_END_OF_LIST(),
+};
+
+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);
+ }
+}
+
+static void s390_ipl_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+
+ k->init = s390_ipl_init;
+ dc->props = s390_ipl_properties;
+ dc->reset = s390_ipl_reset;
+ dc->no_user = 1;
+}
+
+static TypeInfo s390_ipl_info = {
+ .class_init = s390_ipl_class_init,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .name = "s390-ipl",
+ .instance_size = sizeof(S390IPLState),
+};
+
+static void s390_ipl_register_types(void)
+{
+ type_register_static(&s390_ipl_info);
+}
+
+type_init(s390_ipl_register_types)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 3/8] S390: Enable -cpu help and QMP query-cpu-definitions
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 1/8] s390: new contributions GPLv2 or later Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 4/8] s390x: Remove inline function ebcdic_put and related data from cpu.h Alexander Graf
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel
Cc: Blue Swirl, Jens Freimann, Aurélien Jarno,
Viktor Mihajlovski
From: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
This enables qemu -cpu help to return a list of supported CPU models
on s390 and also to query for cpu definitions in the monitor.
Initially only cpu model = host is returned. This needs to be reworked
into a full-fledged CPU model handling later on.
This change is needed to allow libvirt exploiters (like OpenStack)
to specify a CPU model.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
[agraf: fix s390x-linux-user, adjust header locations]
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/s390-virtio.c | 6 +++++-
target-s390x/cpu.c | 26 ++++++++++++++++++++++++++
target-s390x/cpu.h | 3 +++
3 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 13f93fb..3cfb97e 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -2,6 +2,7 @@
* QEMU S390 virtio target
*
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
+ * Copyright IBM Corp 2012
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -13,7 +14,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Lesser General Public
+ * Contributions after 2012-10-29 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU (Lesser) General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 2ed2312..420b21b 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -23,7 +23,33 @@
#include "cpu.h"
#include "qemu-common.h"
#include "qemu/timer.h"
+#ifndef CONFIG_USER_ONLY
+#include "sysemu/arch_init.h"
+#endif
+
+/* generate CPU information for cpu -? */
+void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
+{
+#ifdef CONFIG_KVM
+ (*cpu_fprintf)(f, "s390 %16s\n", "host");
+#endif
+}
+#ifndef CONFIG_USER_ONLY
+CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
+{
+ CpuDefinitionInfoList *entry;
+ CpuDefinitionInfo *info;
+
+ info = g_malloc0(sizeof(*info));
+ info->name = g_strdup("host");
+
+ entry = g_malloc0(sizeof(*entry));
+ entry->value = info;
+
+ return entry;
+}
+#endif
/* CPUClass::reset() */
static void s390_cpu_reset(CPUState *s)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 1fa3ad3..d503b9e 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -362,6 +362,9 @@ static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls)
#define cpu_gen_code cpu_s390x_gen_code
#define cpu_signal_handler cpu_s390x_signal_handler
+void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf);
+#define cpu_list s390_cpu_list
+
#include "exec/exec-all.h"
#define EXCP_EXT 1 /* external interrupt */
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 4/8] s390x: Remove inline function ebcdic_put and related data from cpu.h
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (2 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 3/8] S390: Enable -cpu help and QMP query-cpu-definitions Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 5/8] s390: Add CPU reset handler Alexander Graf
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Stefan Weil, Aurélien Jarno
From: Stefan Weil <sw@weilnetz.de>
The function is only used in misc_helper.c, so move it to that file.
This reduces the size of debug executables (compiled without optimization)
because they get unused code and data for each compilation which includes
cpu.h.
Executables with optimization don't change their size.
ebcdic2ascii is currently unused and could be removed (not done here).
The array ascii2ebcdic must be accessed with an unsigned index, therefore
(int)ascii[i] was replaced by (uint8_t)ascii[i]. The old code would have
failed for a signed char less than 0. The current code only converts
"QEMU" and spaces to EBCDIC, so there is no problem today.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-s390x/cpu.h | 81 --------------------------------------------
target-s390x/misc_helper.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index d503b9e..23d8b44 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -775,87 +775,6 @@ struct sysib_322 {
#define SK_F (0x1 << 3)
#define SK_ACC_MASK (0xf << 4)
-
-/* EBCDIC handling */
-static const uint8_t ebcdic2ascii[] = {
- 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
- 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
- 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
- 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
- 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
- 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
- 0x87, 0xA4, 0x5B, 0x2E, 0x3C, 0x28, 0x2B, 0x21,
- 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
- 0x8D, 0xE1, 0x5D, 0x24, 0x2A, 0x29, 0x3B, 0x5E,
- 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
- 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
- 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
- 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
- 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0xAE, 0xAF, 0x07, 0x07, 0x07, 0xF1,
- 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
- 0x71, 0x72, 0xA6, 0xA7, 0x91, 0x07, 0x92, 0x07,
- 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7A, 0xAD, 0xAB, 0x07, 0x07, 0x07, 0x07,
- 0x9B, 0x9C, 0x9D, 0xFA, 0x07, 0x07, 0x07, 0xAC,
- 0xAB, 0x07, 0xAA, 0x7C, 0x07, 0x07, 0x07, 0x07,
- 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0x07, 0x93, 0x94, 0x95, 0xA2, 0x07,
- 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
- 0x51, 0x52, 0x07, 0x96, 0x81, 0x97, 0xA3, 0x98,
- 0x5C, 0xF6, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5A, 0xFD, 0x07, 0x99, 0x07, 0x07, 0x07,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x07, 0x07, 0x9A, 0x07, 0x07, 0x07,
-};
-
-static const uint8_t ascii2ebcdic [] = {
- 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F,
- 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
- 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26,
- 0x18, 0x19, 0x3F, 0x27, 0x22, 0x1D, 0x1E, 0x1F,
- 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D,
- 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,
- 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
- 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
- 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6,
- 0xE7, 0xE8, 0xE9, 0xBA, 0xE0, 0xBB, 0xB0, 0x6D,
- 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 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
-
#define SIGP_SENSE 0x01
#define SIGP_EXTERNAL_CALL 0x02
#define SIGP_EMERGENCY 0x03
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 3015bfe..78d2c0e 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -70,6 +70,87 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp)
}
#ifndef CONFIG_USER_ONLY
+
+/* EBCDIC handling */
+static const uint8_t ebcdic2ascii[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x07, 0x09, 0x07, 0x7F,
+ 0x07, 0x07, 0x07, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x07, 0x0A, 0x08, 0x07,
+ 0x18, 0x19, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x1C, 0x07, 0x07, 0x0A, 0x17, 0x1B,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07,
+ 0x07, 0x07, 0x16, 0x07, 0x07, 0x07, 0x07, 0x04,
+ 0x07, 0x07, 0x07, 0x07, 0x14, 0x15, 0x07, 0x1A,
+ 0x20, 0xFF, 0x83, 0x84, 0x85, 0xA0, 0x07, 0x86,
+ 0x87, 0xA4, 0x5B, 0x2E, 0x3C, 0x28, 0x2B, 0x21,
+ 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x07,
+ 0x8D, 0xE1, 0x5D, 0x24, 0x2A, 0x29, 0x3B, 0x5E,
+ 0x2D, 0x2F, 0x07, 0x8E, 0x07, 0x07, 0x07, 0x8F,
+ 0x80, 0xA5, 0x07, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
+ 0x07, 0x90, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x70, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
+ 0x07, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+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 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x3F, 0x59, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
+ 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF
+};
+
+static inline void ebcdic_put(uint8_t *p, const char *ascii, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ p[i] = ascii2ebcdic[(uint8_t)ascii[i]];
+ }
+}
+
void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
{
qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n",
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 5/8] s390: Add CPU reset handler
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (3 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 4/8] s390x: Remove inline function ebcdic_put and related data from cpu.h Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 6/8] s390x: fix indentation Alexander Graf
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Jens Freimann, Aurélien Jarno
From: Jens Freimann <jfrei@linux.vnet.ibm.com>
Add a CPU reset handler to have all CPUs in a PoP compliant
state.
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
[agraf: move hw/hw.h into existing ifdef]
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-s390x/cpu.c | 35 +++++++++++++++++++++++++++++++++--
target-s390x/kvm.c | 9 ++++++++-
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 420b21b..6810246 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -4,6 +4,7 @@
* Copyright (c) 2009 Ulrich Hecht
* Copyright (c) 2011 Alexander Graf
* Copyright (c) 2012 SUSE LINUX Products GmbH
+ * Copyright (c) 2012 IBM Corp.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,15 +19,21 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>
+ * Contributions after 2012-12-11 are licensed under the terms of the
+ * GNU GPL, version 2 or (at your option) any later version.
*/
#include "cpu.h"
#include "qemu-common.h"
#include "qemu/timer.h"
#ifndef CONFIG_USER_ONLY
+#include "hw/hw.h"
#include "sysemu/arch_init.h"
#endif
+#define CR0_RESET 0xE0UL
+#define CR14_RESET 0xC2000000UL;
+
/* generate CPU information for cpu -? */
void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf)
{
@@ -63,14 +70,33 @@ static void s390_cpu_reset(CPUState *s)
log_cpu_state(env, 0);
}
+ s390_del_running_cpu(env);
+
scc->parent_reset(s);
memset(env, 0, offsetof(CPUS390XState, breakpoints));
- /* FIXME: reset vector? */
+
+ /* architectured initial values for CR 0 and 14 */
+ env->cregs[0] = CR0_RESET;
+ env->cregs[14] = CR14_RESET;
+ /* set halted to 1 to make sure we can add the cpu in
+ * s390_ipl_cpu code, where env->halted is set back to 0
+ * after incrementing the cpu counter */
+#if !defined(CONFIG_USER_ONLY)
+ env->halted = 1;
+#endif
tlb_flush(env, 1);
- s390_add_running_cpu(env);
}
+#if !defined(CONFIG_USER_ONLY)
+static void s390_cpu_machine_reset_cb(void *opaque)
+{
+ S390CPU *cpu = opaque;
+
+ cpu_reset(CPU(cpu));
+}
+#endif
+
static void s390_cpu_initfn(Object *obj)
{
S390CPU *cpu = S390_CPU(obj);
@@ -82,12 +108,17 @@ static void s390_cpu_initfn(Object *obj)
cpu_exec_init(env);
#if !defined(CONFIG_USER_ONLY)
+ qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
qemu_get_timedate(&tm, 0);
env->tod_offset = TOD_UNIX_EPOCH +
(time2tod(mktimegm(&tm)) * 1000000000ULL);
env->tod_basetime = 0;
env->tod_timer = qemu_new_timer_ns(vm_clock, s390x_tod_timer, cpu);
env->cpu_timer = qemu_new_timer_ns(vm_clock, s390x_cpu_timer, cpu);
+ /* set env->halted state to 1 to avoid decrementing the running
+ * cpu counter in s390_cpu_reset to a negative number at
+ * initial ipl */
+ env->halted = 1;
#endif
env->cpu_num = cpu_num++;
env->ext_index = -1;
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 5785f7d..8bd3080 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -89,7 +89,14 @@ int kvm_arch_init_vcpu(CPUState *cpu)
void kvm_arch_reset_vcpu(CPUState *cpu)
{
- /* FIXME: add code to reset vcpu. */
+ /* The initial reset call is needed here to reset in-kernel
+ * vcpu data that we can't access directly from QEMU
+ * (i.e. with older kernels which don't support sync_regs/ONE_REG).
+ * Before this ioctl cpu_synchronize_state() is called in common kvm
+ * code (kvm-all) */
+ if (kvm_vcpu_ioctl(cpu, KVM_S390_INITIAL_RESET, NULL)) {
+ perror("Can't reset vcpu\n");
+ }
}
int kvm_arch_put_registers(CPUState *cs, int level)
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 6/8] s390x: fix indentation
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (4 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 5/8] s390: Add CPU reset handler Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 7/8] target-s390x: Unregister reset callback on finalization Alexander Graf
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Aurélien Jarno
In one of the last commits we accidently got 3-space indentation into
the tree. Fix it up so it's 4 spaces wide.
Reported-by: Andreas Faerber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-s390x/kvm.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 8bd3080..a63ee46 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -89,11 +89,11 @@ int kvm_arch_init_vcpu(CPUState *cpu)
void kvm_arch_reset_vcpu(CPUState *cpu)
{
- /* The initial reset call is needed here to reset in-kernel
- * vcpu data that we can't access directly from QEMU
- * (i.e. with older kernels which don't support sync_regs/ONE_REG).
- * Before this ioctl cpu_synchronize_state() is called in common kvm
- * code (kvm-all) */
+ /* The initial reset call is needed here to reset in-kernel
+ * vcpu data that we can't access directly from QEMU
+ * (i.e. with older kernels which don't support sync_regs/ONE_REG).
+ * Before this ioctl cpu_synchronize_state() is called in common kvm
+ * code (kvm-all) */
if (kvm_vcpu_ioctl(cpu, KVM_S390_INITIAL_RESET, NULL)) {
perror("Can't reset vcpu\n");
}
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 7/8] target-s390x: Unregister reset callback on finalization
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (5 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 6/8] s390x: fix indentation Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface Alexander Graf
2013-01-19 13:57 ` [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Blue Swirl
8 siblings, 0 replies; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Andreas Färber, Aurélien Jarno
From: Andreas Färber <afaerber@suse.de>
Since commit "s390: Add CPU reset handler" the CPU's instance_init
registers a reset callback. Unregister that on instance_finalize.
Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
target-s390x/cpu.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 6810246..0b68db8 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -126,6 +126,15 @@ static void s390_cpu_initfn(Object *obj)
cpu_reset(CPU(cpu));
}
+static void s390_cpu_finalize(Object *obj)
+{
+#if !defined(CONFIG_USER_ONLY)
+ S390CPU *cpu = S390_CPU(obj);
+
+ qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
+#endif
+}
+
static void s390_cpu_class_init(ObjectClass *oc, void *data)
{
S390CPUClass *scc = S390_CPU_CLASS(oc);
@@ -140,6 +149,7 @@ static const TypeInfo s390_cpu_type_info = {
.parent = TYPE_CPU,
.instance_size = sizeof(S390CPU),
.instance_init = s390_cpu_initfn,
+ .instance_finalize = s390_cpu_finalize,
.abstract = false,
.class_size = sizeof(S390CPUClass),
.class_init = s390_cpu_class_init,
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface.
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (6 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 7/8] target-s390x: Unregister reset callback on finalization Alexander Graf
@ 2013-01-18 18:12 ` Alexander Graf
2013-01-18 18:44 ` Andreas Färber
2013-01-19 13:57 ` [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Blue Swirl
8 siblings, 1 reply; 12+ messages in thread
From: Alexander Graf @ 2013-01-18 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, Cornelia Huck, Aurélien Jarno
From: Cornelia Huck <cornelia.huck@de.ibm.com>
Allow virtio machines to register for different diag500 function
codes and convert s390-virtio to use it.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/s390-virtio.c | 90 ++++++++++++++++++++++-------------------
hw/s390-virtio.h | 22 ++++++++++
hw/s390x/Makefile.objs | 1 +
hw/s390x/s390-virtio-hcall.c | 36 +++++++++++++++++
target-s390x/cpu.h | 2 +-
target-s390x/kvm.c | 2 +-
target-s390x/misc_helper.c | 2 +-
7 files changed, 110 insertions(+), 45 deletions(-)
create mode 100644 hw/s390-virtio.h
create mode 100644 hw/s390x/s390-virtio-hcall.c
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 3cfb97e..5edaabb 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -36,6 +36,7 @@
#include "hw/s390-virtio-bus.h"
#include "hw/s390x/sclp.h"
+#include "hw/s390-virtio.h"
//#define DEBUG_S390
@@ -47,10 +48,6 @@
do { } while (0)
#endif
-#define KVM_S390_VIRTIO_NOTIFY 0
-#define KVM_S390_VIRTIO_RESET 1
-#define KVM_S390_VIRTIO_SET_STATUS 2
-
#define MAX_BLK_DEVS 10
static VirtIOS390Bus *s390_bus;
@@ -65,56 +62,63 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
return ipi_states[cpu_addr];
}
-int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall)
+static int s390_virtio_hcall_notify(const uint64_t *args)
{
+ uint64_t mem = args[0];
int r = 0, i;
- dprintf("KVM hypercall: %ld\n", hypercall);
- switch (hypercall) {
- case KVM_S390_VIRTIO_NOTIFY:
- if (mem > ram_size) {
- VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus,
- mem, &i);
- if (dev) {
- virtio_queue_notify(dev->vdev, i);
- } else {
- r = -EINVAL;
- }
- } else {
- /* Early printk */
- }
- break;
- case KVM_S390_VIRTIO_RESET:
- {
- VirtIOS390Device *dev;
-
- dev = s390_virtio_bus_find_mem(s390_bus, mem);
- virtio_reset(dev->vdev);
- stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0);
- s390_virtio_device_sync(dev);
- s390_virtio_reset_idx(dev);
- break;
- }
- case KVM_S390_VIRTIO_SET_STATUS:
- {
- VirtIOS390Device *dev;
-
- dev = s390_virtio_bus_find_mem(s390_bus, mem);
+ if (mem > ram_size) {
+ VirtIOS390Device *dev = s390_virtio_bus_find_vring(s390_bus, mem, &i);
if (dev) {
- s390_virtio_device_update_status(dev);
+ virtio_queue_notify(dev->vdev, i);
} else {
r = -EINVAL;
}
- break;
+ } else {
+ /* Early printk */
}
- default:
+ return r;
+}
+
+static int s390_virtio_hcall_reset(const uint64_t *args)
+{
+ uint64_t mem = args[0];
+ VirtIOS390Device *dev;
+
+ dev = s390_virtio_bus_find_mem(s390_bus, mem);
+ virtio_reset(dev->vdev);
+ stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS, 0);
+ s390_virtio_device_sync(dev);
+ s390_virtio_reset_idx(dev);
+
+ return 0;
+}
+
+static int s390_virtio_hcall_set_status(const uint64_t *args)
+{
+ uint64_t mem = args[0];
+ int r = 0;
+ VirtIOS390Device *dev;
+
+ dev = s390_virtio_bus_find_mem(s390_bus, mem);
+ if (dev) {
+ s390_virtio_device_update_status(dev);
+ } else {
r = -EINVAL;
- break;
}
-
return r;
}
+static void s390_virtio_register_hcalls(void)
+{
+ s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY,
+ s390_virtio_hcall_notify);
+ s390_register_virtio_hypercall(KVM_S390_VIRTIO_RESET,
+ s390_virtio_hcall_reset);
+ s390_register_virtio_hypercall(KVM_S390_VIRTIO_SET_STATUS,
+ s390_virtio_hcall_set_status);
+}
+
/*
* The number of running CPUs. On s390 a shutdown is the state of all CPUs
* being either stopped or disabled (for interrupts) waiting. We have to
@@ -182,6 +186,9 @@ static void s390_init(QEMUMachineInitArgs *args)
qdev_prop_set_string(dev, "cmdline", args->kernel_cmdline);
qdev_init_nofail(dev);
+ /* register hypercalls */
+ s390_virtio_register_hcalls();
+
/* allocate RAM */
memory_region_init_ram(ram, "s390.ram", my_ram_size);
vmstate_register_ram_global(ram);
@@ -265,4 +272,3 @@ static void s390_machine_init(void)
}
machine_init(s390_machine_init);
-
diff --git a/hw/s390-virtio.h b/hw/s390-virtio.h
new file mode 100644
index 0000000..25bb610
--- /dev/null
+++ b/hw/s390-virtio.h
@@ -0,0 +1,22 @@
+/*
+ * Virtio interfaces for s390
+ *
+ * Copyright 2012 IBM Corp.
+ * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef HW_S390_VIRTIO_H
+#define HW_S390_VIRTIO_H 1
+
+#define KVM_S390_VIRTIO_NOTIFY 0
+#define KVM_S390_VIRTIO_RESET 1
+#define KVM_S390_VIRTIO_SET_STATUS 2
+
+typedef int (*s390_virtio_fn)(const uint64_t *args);
+void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
+
+#endif
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
index 4a5a5d8..1b40c2e 100644
--- a/hw/s390x/Makefile.objs
+++ b/hw/s390x/Makefile.objs
@@ -1,6 +1,7 @@
obj-y = s390-virtio-bus.o s390-virtio.o
obj-y := $(addprefix ../,$(obj-y))
+obj-y += s390-virtio-hcall.o
obj-y += sclp.o
obj-y += event-facility.o
obj-y += sclpquiesce.o sclpconsole.o
diff --git a/hw/s390x/s390-virtio-hcall.c b/hw/s390x/s390-virtio-hcall.c
new file mode 100644
index 0000000..d7938c0
--- /dev/null
+++ b/hw/s390x/s390-virtio-hcall.c
@@ -0,0 +1,36 @@
+/*
+ * Support for virtio hypercalls on s390
+ *
+ * Copyright 2012 IBM Corp.
+ * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#include "cpu.h"
+#include "hw/s390-virtio.h"
+
+#define MAX_DIAG_SUBCODES 255
+
+static s390_virtio_fn s390_diag500_table[MAX_DIAG_SUBCODES];
+
+void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn)
+{
+ assert(code < MAX_DIAG_SUBCODES);
+ assert(!s390_diag500_table[code]);
+
+ s390_diag500_table[code] = fn;
+}
+
+int s390_virtio_hypercall(CPUS390XState *env)
+{
+ s390_virtio_fn fn = s390_diag500_table[env->regs[1]];
+
+ if (!fn) {
+ return -EINVAL;
+ }
+
+ return fn(&env->regs[2]);
+}
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 23d8b44..1f2d942 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -305,7 +305,7 @@ int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw
void s390x_tod_timer(void *opaque);
void s390x_cpu_timer(void *opaque);
-int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall);
+int s390_virtio_hypercall(CPUS390XState *env);
#ifdef CONFIG_KVM
void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index a63ee46..add6a58 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -397,7 +397,7 @@ static int handle_priv(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
static int handle_hypercall(CPUS390XState *env, struct kvm_run *run)
{
cpu_synchronize_state(env);
- env->regs[2] = s390_virtio_hypercall(env, env->regs[2], env->regs[1]);
+ env->regs[2] = s390_virtio_hypercall(env);
return 0;
}
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 78d2c0e..09301d0 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -188,7 +188,7 @@ uint64_t HELPER(diag)(CPUS390XState *env, uint32_t num, uint64_t mem,
switch (num) {
case 0x500:
/* KVM hypercall */
- r = s390_virtio_hypercall(env, mem, code);
+ r = s390_virtio_hypercall(env);
break;
case 0x44:
/* yield */
--
1.6.0.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device
2013-01-18 18:12 ` [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device Alexander Graf
@ 2013-01-18 18:37 ` Andreas Färber
0 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2013-01-18 18:37 UTC (permalink / raw)
To: Alexander Graf
Cc: Blue Swirl, Christian Borntraeger, Jens Freimann, qemu-devel,
Aurélien Jarno
Am 18.01.2013 19:12, schrieb Alexander Graf:
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> new file mode 100644
> index 0000000..7cbbf99
> --- /dev/null
> +++ b/hw/s390x/ipl.c
[...]
> +static TypeInfo s390_ipl_info = {
This should probably be static const - my tree-wide cleanup didn't catch
s390-next obviously. Please follow-up with a fix to avoid this being copied.
Similar issue could exist for ppc-next, please check.
Andreas
> + .class_init = s390_ipl_class_init,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .name = "s390-ipl",
> + .instance_size = sizeof(S390IPLState),
> +};
> +
> +static void s390_ipl_register_types(void)
> +{
> + type_register_static(&s390_ipl_info);
> +}
> +
> +type_init(s390_ipl_register_types)
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface.
2013-01-18 18:12 ` [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface Alexander Graf
@ 2013-01-18 18:44 ` Andreas Färber
0 siblings, 0 replies; 12+ messages in thread
From: Andreas Färber @ 2013-01-18 18:44 UTC (permalink / raw)
To: Alexander Graf; +Cc: Blue Swirl, Cornelia Huck, qemu-devel, Aurélien Jarno
Am 18.01.2013 19:12, schrieb Alexander Graf:
> diff --git a/hw/s390-virtio.h b/hw/s390-virtio.h
> new file mode 100644
> index 0000000..25bb610
> --- /dev/null
> +++ b/hw/s390-virtio.h
> @@ -0,0 +1,22 @@
> +/*
> + * Virtio interfaces for s390
> + *
> + * Copyright 2012 IBM Corp.
> + * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or (at
> + * your option) any later version. See the COPYING file in the top-level
> + * directory.
> + */
> +
> +#ifndef HW_S390_VIRTIO_H
> +#define HW_S390_VIRTIO_H 1
> +
> +#define KVM_S390_VIRTIO_NOTIFY 0
> +#define KVM_S390_VIRTIO_RESET 1
> +#define KVM_S390_VIRTIO_SET_STATUS 2
> +
> +typedef int (*s390_virtio_fn)(const uint64_t *args);
CamelCase?
Andreas
> +void s390_register_virtio_hypercall(uint64_t code, s390_virtio_fn fn);
> +
> +#endif
[snip]
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
` (7 preceding siblings ...)
2013-01-18 18:12 ` [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface Alexander Graf
@ 2013-01-19 13:57 ` Blue Swirl
8 siblings, 0 replies; 12+ messages in thread
From: Blue Swirl @ 2013-01-19 13:57 UTC (permalink / raw)
To: Alexander Graf; +Cc: qemu-devel, Aurélien Jarno
Thanks, pulled.
On Fri, Jan 18, 2013 at 6:12 PM, Alexander Graf <agraf@suse.de> wrote:
> Hi Blue / Aurelien,
>
> This is my current patch queue for s390. Please pull.
>
> Alex
>
>
> The following changes since commit ddc01bf16e9f04b3e72c1b946b0b8efeb7a545d2:
> Anthony Liguori (1):
> Merge remote-tracking branch 'luiz/queue/qmp' into staging
>
> are available in the git repository at:
>
> git://repo.or.cz/qemu/agraf.git s390-for-upstream
>
> Alexander Graf (1):
> s390x: fix indentation
>
> Andreas Färber (1):
> target-s390x: Unregister reset callback on finalization
>
> Christian Borntraeger (2):
> s390: new contributions GPLv2 or later
> s390: Move IPL code into a separate device
>
> Cornelia Huck (1):
> s390: Add a hypercall registration interface.
>
> Jens Freimann (1):
> s390: Add CPU reset handler
>
> Stefan Weil (1):
> s390x: Remove inline function ebcdic_put and related data from cpu.h
>
> Viktor Mihajlovski (1):
> S390: Enable -cpu help and QMP query-cpu-definitions
>
> hw/s390-virtio.c | 194 ++++++++++++++----------------------------
> hw/s390-virtio.h | 22 +++++
> hw/s390x/Makefile.objs | 2 +
> hw/s390x/ipl.c | 174 +++++++++++++++++++++++++++++++++++++
> hw/s390x/s390-virtio-hcall.c | 36 ++++++++
> target-s390x/cpu.c | 71 +++++++++++++++-
> target-s390x/cpu.h | 91 ++------------------
> target-s390x/kvm.c | 17 +++-
> target-s390x/misc_helper.c | 83 ++++++++++++++++++-
> 9 files changed, 470 insertions(+), 220 deletions(-)
> create mode 100644 hw/s390-virtio.h
> create mode 100644 hw/s390x/ipl.c
> create mode 100644 hw/s390x/s390-virtio-hcall.c
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-01-19 13:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18 18:12 [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 1/8] s390: new contributions GPLv2 or later Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 2/8] s390: Move IPL code into a separate device Alexander Graf
2013-01-18 18:37 ` Andreas Färber
2013-01-18 18:12 ` [Qemu-devel] [PATCH 3/8] S390: Enable -cpu help and QMP query-cpu-definitions Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 4/8] s390x: Remove inline function ebcdic_put and related data from cpu.h Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 5/8] s390: Add CPU reset handler Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 6/8] s390x: fix indentation Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 7/8] target-s390x: Unregister reset callback on finalization Alexander Graf
2013-01-18 18:12 ` [Qemu-devel] [PATCH 8/8] s390: Add a hypercall registration interface Alexander Graf
2013-01-18 18:44 ` Andreas Färber
2013-01-19 13:57 ` [Qemu-devel] [PULL 0/8] s390 patch queue 2013-01-18 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).