|
|
1359fb |
From eb4b0282363c6149a05d6b00b0b7d40535715598 Mon Sep 17 00:00:00 2001
|
|
|
1359fb |
From: David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
Date: Fri, 21 Dec 2018 15:39:48 +0100
|
|
|
1359fb |
Subject: [PATCH 04/14] s390x/tod: factor out TOD into separate device
|
|
|
1359fb |
|
|
|
1359fb |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
Message-id: <20181221153957.28183-4-david@redhat.com>
|
|
|
1359fb |
Patchwork-id: 83761
|
|
|
1359fb |
O-Subject: [RHEL-7.6.z qemu-kvm-ma PATCH 03/12] s390x/tod: factor out TOD into separate device
|
|
|
1359fb |
Bugzilla: 1672920
|
|
|
1359fb |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
1359fb |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
1359fb |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
1359fb |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1359fb |
|
|
|
1359fb |
Conflicts:
|
|
|
1359fb |
hw/s390x/s390-virtio-ccw.c: contextual conflict (console init
|
|
|
1359fb |
rework)
|
|
|
1359fb |
|
|
|
1359fb |
Let's treat this like a separate device. TCG will have to store the
|
|
|
1359fb |
actual state/time later on.
|
|
|
1359fb |
|
|
|
1359fb |
Include cpu-qom.h in kvm_s390x.h (due to S390CPU) to compile tod-kvm.c.
|
|
|
1359fb |
|
|
|
1359fb |
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
|
1359fb |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
Message-Id: <20180627134410.4901-4-david@redhat.com>
|
|
|
1359fb |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
1359fb |
(cherry picked from commit 8046f374a64b81fdf4f71f7a433bf4035d501521)
|
|
|
1359fb |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
---
|
|
|
1359fb |
hw/s390x/Makefile.objs | 3 ++
|
|
|
1359fb |
hw/s390x/s390-virtio-ccw.c | 57 ++--------------------
|
|
|
1359fb |
hw/s390x/tod-kvm.c | 64 ++++++++++++++++++++++++
|
|
|
1359fb |
hw/s390x/tod-qemu.c | 49 +++++++++++++++++++
|
|
|
1359fb |
hw/s390x/tod.c | 119 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
1359fb |
include/hw/s390x/tod.h | 46 ++++++++++++++++++
|
|
|
1359fb |
target/s390x/cpu.c | 32 ------------
|
|
|
1359fb |
target/s390x/cpu.h | 2 -
|
|
|
1359fb |
target/s390x/kvm_s390x.h | 2 +
|
|
|
1359fb |
9 files changed, 286 insertions(+), 88 deletions(-)
|
|
|
1359fb |
create mode 100644 hw/s390x/tod-kvm.c
|
|
|
1359fb |
create mode 100644 hw/s390x/tod-qemu.c
|
|
|
1359fb |
create mode 100644 hw/s390x/tod.c
|
|
|
1359fb |
create mode 100644 include/hw/s390x/tod.h
|
|
|
1359fb |
|
|
|
1359fb |
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
|
|
|
1359fb |
index dc704b5..93282f7 100644
|
|
|
1359fb |
--- a/hw/s390x/Makefile.objs
|
|
|
1359fb |
+++ b/hw/s390x/Makefile.objs
|
|
|
1359fb |
@@ -14,6 +14,9 @@ obj-$(CONFIG_PCI) += s390-pci-bus.o s390-pci-inst.o
|
|
|
1359fb |
obj-$(call lnot,$(CONFIG_PCI)) += s390-pci-stub.o
|
|
|
1359fb |
obj-y += s390-skeys.o
|
|
|
1359fb |
obj-y += s390-stattrib.o
|
|
|
1359fb |
+obj-y += tod.o
|
|
|
1359fb |
+obj-$(CONFIG_KVM) += tod-kvm.o
|
|
|
1359fb |
+obj-$(CONFIG_TCG) += tod-qemu.o
|
|
|
1359fb |
obj-$(CONFIG_KVM) += s390-skeys-kvm.o
|
|
|
1359fb |
obj-$(CONFIG_KVM) += s390-stattrib-kvm.o
|
|
|
1359fb |
obj-y += s390-ccw.o
|
|
|
1359fb |
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
|
|
|
1359fb |
index bf039a1..3429e55 100644
|
|
|
1359fb |
--- a/hw/s390x/s390-virtio-ccw.c
|
|
|
1359fb |
+++ b/hw/s390x/s390-virtio-ccw.c
|
|
|
1359fb |
@@ -35,6 +35,7 @@
|
|
|
1359fb |
#include "migration/register.h"
|
|
|
1359fb |
#include "cpu_models.h"
|
|
|
1359fb |
#include "hw/nmi.h"
|
|
|
1359fb |
+#include "hw/s390x/tod.h"
|
|
|
1359fb |
|
|
|
1359fb |
S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
|
|
|
1359fb |
{
|
|
|
1359fb |
@@ -187,58 +188,6 @@ static void s390_memory_init(ram_addr_t mem_size)
|
|
|
1359fb |
s390_stattrib_init();
|
|
|
1359fb |
}
|
|
|
1359fb |
|
|
|
1359fb |
-#define S390_TOD_CLOCK_VALUE_MISSING 0x00
|
|
|
1359fb |
-#define S390_TOD_CLOCK_VALUE_PRESENT 0x01
|
|
|
1359fb |
-
|
|
|
1359fb |
-static void gtod_save(QEMUFile *f, void *opaque)
|
|
|
1359fb |
-{
|
|
|
1359fb |
- uint64_t tod_low;
|
|
|
1359fb |
- uint8_t tod_high;
|
|
|
1359fb |
- int r;
|
|
|
1359fb |
-
|
|
|
1359fb |
- r = s390_get_clock(&tod_high, &tod_low);
|
|
|
1359fb |
- if (r) {
|
|
|
1359fb |
- warn_report("Unable to get guest clock for migration: %s",
|
|
|
1359fb |
- strerror(-r));
|
|
|
1359fb |
- error_printf("Guest clock will not be migrated "
|
|
|
1359fb |
- "which could cause the guest to hang.");
|
|
|
1359fb |
- qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING);
|
|
|
1359fb |
- return;
|
|
|
1359fb |
- }
|
|
|
1359fb |
-
|
|
|
1359fb |
- qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT);
|
|
|
1359fb |
- qemu_put_byte(f, tod_high);
|
|
|
1359fb |
- qemu_put_be64(f, tod_low);
|
|
|
1359fb |
-}
|
|
|
1359fb |
-
|
|
|
1359fb |
-static int gtod_load(QEMUFile *f, void *opaque, int version_id)
|
|
|
1359fb |
-{
|
|
|
1359fb |
- uint64_t tod_low;
|
|
|
1359fb |
- uint8_t tod_high;
|
|
|
1359fb |
- int r;
|
|
|
1359fb |
-
|
|
|
1359fb |
- if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) {
|
|
|
1359fb |
- warn_report("Guest clock was not migrated. This could "
|
|
|
1359fb |
- "cause the guest to hang.");
|
|
|
1359fb |
- return 0;
|
|
|
1359fb |
- }
|
|
|
1359fb |
-
|
|
|
1359fb |
- tod_high = qemu_get_byte(f);
|
|
|
1359fb |
- tod_low = qemu_get_be64(f);
|
|
|
1359fb |
-
|
|
|
1359fb |
- r = s390_set_clock(&tod_high, &tod_low);
|
|
|
1359fb |
- if (r) {
|
|
|
1359fb |
- error_report("Unable to set KVM guest TOD clock: %s", strerror(-r));
|
|
|
1359fb |
- }
|
|
|
1359fb |
-
|
|
|
1359fb |
- return r;
|
|
|
1359fb |
-}
|
|
|
1359fb |
-
|
|
|
1359fb |
-static SaveVMHandlers savevm_gtod = {
|
|
|
1359fb |
- .save_state = gtod_save,
|
|
|
1359fb |
- .load_state = gtod_load,
|
|
|
1359fb |
-};
|
|
|
1359fb |
-
|
|
|
1359fb |
static void s390_init_ipl_dev(const char *kernel_filename,
|
|
|
1359fb |
const char *kernel_cmdline,
|
|
|
1359fb |
const char *initrd_filename, const char *firmware,
|
|
|
1359fb |
@@ -346,8 +295,8 @@ static void ccw_init(MachineState *machine)
|
|
|
1359fb |
/* Create VirtIO network adapters */
|
|
|
1359fb |
s390_create_virtio_net(BUS(css_bus), "virtio-net-ccw");
|
|
|
1359fb |
|
|
|
1359fb |
- /* Register savevm handler for guest TOD clock */
|
|
|
1359fb |
- register_savevm_live(NULL, "todclock", 0, 1, &savevm_gtod, NULL);
|
|
|
1359fb |
+ /* init the TOD clock */
|
|
|
1359fb |
+ s390_init_tod();
|
|
|
1359fb |
}
|
|
|
1359fb |
|
|
|
1359fb |
static void s390_cpu_plug(HotplugHandler *hotplug_dev,
|
|
|
1359fb |
diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c
|
|
|
1359fb |
new file mode 100644
|
|
|
1359fb |
index 0000000..df564ab
|
|
|
1359fb |
--- /dev/null
|
|
|
1359fb |
+++ b/hw/s390x/tod-kvm.c
|
|
|
1359fb |
@@ -0,0 +1,64 @@
|
|
|
1359fb |
+/*
|
|
|
1359fb |
+ * TOD (Time Of Day) clock - KVM implementation
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * Copyright 2018 Red Hat, Inc.
|
|
|
1359fb |
+ * Author(s): David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
1359fb |
+ * See the COPYING file in the top-level directory.
|
|
|
1359fb |
+ */
|
|
|
1359fb |
+
|
|
|
1359fb |
+#include "qemu/osdep.h"
|
|
|
1359fb |
+#include "qapi/error.h"
|
|
|
1359fb |
+#include "hw/s390x/tod.h"
|
|
|
1359fb |
+#include "kvm_s390x.h"
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void kvm_s390_tod_get(const S390TODState *td, S390TOD *tod, Error **errp)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ int r;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ r = kvm_s390_get_clock_ext(&tod->high, &tod->low);
|
|
|
1359fb |
+ if (r == -ENXIO) {
|
|
|
1359fb |
+ r = kvm_s390_get_clock(&tod->high, &tod->low);
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+ if (r) {
|
|
|
1359fb |
+ error_setg(errp, "Unable to get KVM guest TOD clock: %s",
|
|
|
1359fb |
+ strerror(-r));
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error **errp)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ int r;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ r = kvm_s390_set_clock_ext(tod->high, tod->low);
|
|
|
1359fb |
+ if (r == -ENXIO) {
|
|
|
1359fb |
+ r = kvm_s390_set_clock(tod->high, tod->low);
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+ if (r) {
|
|
|
1359fb |
+ error_setg(errp, "Unable to set KVM guest TOD clock: %s",
|
|
|
1359fb |
+ strerror(-r));
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void kvm_s390_tod_class_init(ObjectClass *oc, void *data)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ S390TODClass *tdc = S390_TOD_CLASS(oc);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ tdc->get = kvm_s390_tod_get;
|
|
|
1359fb |
+ tdc->set = kvm_s390_tod_set;
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static TypeInfo kvm_s390_tod_info = {
|
|
|
1359fb |
+ .name = TYPE_KVM_S390_TOD,
|
|
|
1359fb |
+ .parent = TYPE_S390_TOD,
|
|
|
1359fb |
+ .instance_size = sizeof(S390TODState),
|
|
|
1359fb |
+ .class_init = kvm_s390_tod_class_init,
|
|
|
1359fb |
+ .class_size = sizeof(S390TODClass),
|
|
|
1359fb |
+};
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void register_types(void)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ type_register_static(&kvm_s390_tod_info);
|
|
|
1359fb |
+}
|
|
|
1359fb |
+type_init(register_types);
|
|
|
1359fb |
diff --git a/hw/s390x/tod-qemu.c b/hw/s390x/tod-qemu.c
|
|
|
1359fb |
new file mode 100644
|
|
|
1359fb |
index 0000000..03ea1ce
|
|
|
1359fb |
--- /dev/null
|
|
|
1359fb |
+++ b/hw/s390x/tod-qemu.c
|
|
|
1359fb |
@@ -0,0 +1,49 @@
|
|
|
1359fb |
+/*
|
|
|
1359fb |
+ * TOD (Time Of Day) clock - QEMU implementation
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * Copyright 2018 Red Hat, Inc.
|
|
|
1359fb |
+ * Author(s): David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
1359fb |
+ * See the COPYING file in the top-level directory.
|
|
|
1359fb |
+ */
|
|
|
1359fb |
+
|
|
|
1359fb |
+#include "qemu/osdep.h"
|
|
|
1359fb |
+#include "qapi/error.h"
|
|
|
1359fb |
+#include "hw/s390x/tod.h"
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void qemu_s390_tod_get(const S390TODState *td, S390TOD *tod,
|
|
|
1359fb |
+ Error **errp)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ /* FIXME */
|
|
|
1359fb |
+ tod->high = 0;
|
|
|
1359fb |
+ tod->low = 0;
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void qemu_s390_tod_set(S390TODState *td, const S390TOD *tod,
|
|
|
1359fb |
+ Error **errp)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ /* FIXME */
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void qemu_s390_tod_class_init(ObjectClass *oc, void *data)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ S390TODClass *tdc = S390_TOD_CLASS(oc);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ tdc->get = qemu_s390_tod_get;
|
|
|
1359fb |
+ tdc->set = qemu_s390_tod_set;
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static TypeInfo qemu_s390_tod_info = {
|
|
|
1359fb |
+ .name = TYPE_QEMU_S390_TOD,
|
|
|
1359fb |
+ .parent = TYPE_S390_TOD,
|
|
|
1359fb |
+ .instance_size = sizeof(S390TODState),
|
|
|
1359fb |
+ .class_init = qemu_s390_tod_class_init,
|
|
|
1359fb |
+ .class_size = sizeof(S390TODClass),
|
|
|
1359fb |
+};
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void register_types(void)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ type_register_static(&qemu_s390_tod_info);
|
|
|
1359fb |
+}
|
|
|
1359fb |
+type_init(register_types);
|
|
|
1359fb |
diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c
|
|
|
1359fb |
new file mode 100644
|
|
|
1359fb |
index 0000000..0501aff
|
|
|
1359fb |
--- /dev/null
|
|
|
1359fb |
+++ b/hw/s390x/tod.c
|
|
|
1359fb |
@@ -0,0 +1,119 @@
|
|
|
1359fb |
+/*
|
|
|
1359fb |
+ * TOD (Time Of Day) clock
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * Copyright 2018 Red Hat, Inc.
|
|
|
1359fb |
+ * Author(s): David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
1359fb |
+ * See the COPYING file in the top-level directory.
|
|
|
1359fb |
+ */
|
|
|
1359fb |
+
|
|
|
1359fb |
+#include "qemu/osdep.h"
|
|
|
1359fb |
+#include "hw/s390x/tod.h"
|
|
|
1359fb |
+#include "qapi/error.h"
|
|
|
1359fb |
+#include "qemu/error-report.h"
|
|
|
1359fb |
+#include "sysemu/kvm.h"
|
|
|
1359fb |
+#include "migration/register.h"
|
|
|
1359fb |
+
|
|
|
1359fb |
+void s390_init_tod(void)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ Object *obj;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ if (kvm_enabled()) {
|
|
|
1359fb |
+ obj = object_new(TYPE_KVM_S390_TOD);
|
|
|
1359fb |
+ } else {
|
|
|
1359fb |
+ obj = object_new(TYPE_QEMU_S390_TOD);
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+ object_property_add_child(qdev_get_machine(), TYPE_S390_TOD, obj, NULL);
|
|
|
1359fb |
+ object_unref(obj);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ qdev_init_nofail(DEVICE(obj));
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+#define S390_TOD_CLOCK_VALUE_MISSING 0x00
|
|
|
1359fb |
+#define S390_TOD_CLOCK_VALUE_PRESENT 0x01
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void s390_tod_save(QEMUFile *f, void *opaque)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ S390TODState *td = opaque;
|
|
|
1359fb |
+ S390TODClass *tdc = S390_TOD_GET_CLASS(td);
|
|
|
1359fb |
+ Error *err = NULL;
|
|
|
1359fb |
+ S390TOD tod;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ tdc->get(td, &tod, &err;;
|
|
|
1359fb |
+ if (err) {
|
|
|
1359fb |
+ warn_report_err(err);
|
|
|
1359fb |
+ error_printf("Guest clock will not be migrated "
|
|
|
1359fb |
+ "which could cause the guest to hang.");
|
|
|
1359fb |
+ qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING);
|
|
|
1359fb |
+ return;
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+
|
|
|
1359fb |
+ qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT);
|
|
|
1359fb |
+ qemu_put_byte(f, tod.high);
|
|
|
1359fb |
+ qemu_put_be64(f, tod.low);
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static int s390_tod_load(QEMUFile *f, void *opaque, int version_id)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ S390TODState *td = opaque;
|
|
|
1359fb |
+ S390TODClass *tdc = S390_TOD_GET_CLASS(td);
|
|
|
1359fb |
+ Error *err = NULL;
|
|
|
1359fb |
+ S390TOD tod;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) {
|
|
|
1359fb |
+ warn_report("Guest clock was not migrated. This could "
|
|
|
1359fb |
+ "cause the guest to hang.");
|
|
|
1359fb |
+ return 0;
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+
|
|
|
1359fb |
+ tod.high = qemu_get_byte(f);
|
|
|
1359fb |
+ tod.low = qemu_get_be64(f);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ tdc->set(td, &tod, &err;;
|
|
|
1359fb |
+ if (err) {
|
|
|
1359fb |
+ error_report_err(err);
|
|
|
1359fb |
+ return -1;
|
|
|
1359fb |
+ }
|
|
|
1359fb |
+ return 0;
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static SaveVMHandlers savevm_tod = {
|
|
|
1359fb |
+ .save_state = s390_tod_save,
|
|
|
1359fb |
+ .load_state = s390_tod_load,
|
|
|
1359fb |
+};
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void s390_tod_realize(DeviceState *dev, Error **errp)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ S390TODState *td = S390_TOD(dev);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ /* Legacy migration interface */
|
|
|
1359fb |
+ register_savevm_live(NULL, "todclock", 0, 1, &savevm_tod, td);
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void s390_tod_class_init(ObjectClass *oc, void *data)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ dc->desc = "TOD (Time Of Day) Clock";
|
|
|
1359fb |
+ dc->realize = s390_tod_realize;
|
|
|
1359fb |
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
|
|
1359fb |
+
|
|
|
1359fb |
+ /* We only have one TOD clock in the system attached to the machine */
|
|
|
1359fb |
+ dc->user_creatable = false;
|
|
|
1359fb |
+}
|
|
|
1359fb |
+
|
|
|
1359fb |
+static TypeInfo s390_tod_info = {
|
|
|
1359fb |
+ .name = TYPE_S390_TOD,
|
|
|
1359fb |
+ .parent = TYPE_DEVICE,
|
|
|
1359fb |
+ .instance_size = sizeof(S390TODState),
|
|
|
1359fb |
+ .class_init = s390_tod_class_init,
|
|
|
1359fb |
+ .class_size = sizeof(S390TODClass),
|
|
|
1359fb |
+ .abstract = true,
|
|
|
1359fb |
+};
|
|
|
1359fb |
+
|
|
|
1359fb |
+static void register_types(void)
|
|
|
1359fb |
+{
|
|
|
1359fb |
+ type_register_static(&s390_tod_info);
|
|
|
1359fb |
+}
|
|
|
1359fb |
+type_init(register_types);
|
|
|
1359fb |
diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h
|
|
|
1359fb |
new file mode 100644
|
|
|
1359fb |
index 0000000..7096b57
|
|
|
1359fb |
--- /dev/null
|
|
|
1359fb |
+++ b/include/hw/s390x/tod.h
|
|
|
1359fb |
@@ -0,0 +1,46 @@
|
|
|
1359fb |
+/*
|
|
|
1359fb |
+ * TOD (Time Of Day) clock
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * Copyright 2018 Red Hat, Inc.
|
|
|
1359fb |
+ * Author(s): David Hildenbrand <david@redhat.com>
|
|
|
1359fb |
+ *
|
|
|
1359fb |
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
1359fb |
+ * See the COPYING file in the top-level directory.
|
|
|
1359fb |
+ */
|
|
|
1359fb |
+
|
|
|
1359fb |
+#ifndef HW_S390_TOD_H
|
|
|
1359fb |
+#define HW_S390_TOD_H
|
|
|
1359fb |
+
|
|
|
1359fb |
+#include "hw/qdev.h"
|
|
|
1359fb |
+
|
|
|
1359fb |
+typedef struct S390TOD {
|
|
|
1359fb |
+ uint8_t high;
|
|
|
1359fb |
+ uint64_t low;
|
|
|
1359fb |
+} S390TOD;
|
|
|
1359fb |
+
|
|
|
1359fb |
+#define TYPE_S390_TOD "s390-tod"
|
|
|
1359fb |
+#define S390_TOD(obj) OBJECT_CHECK(S390TODState, (obj), TYPE_S390_TOD)
|
|
|
1359fb |
+#define S390_TOD_CLASS(oc) OBJECT_CLASS_CHECK(S390TODClass, (oc), \
|
|
|
1359fb |
+ TYPE_S390_TOD)
|
|
|
1359fb |
+#define S390_TOD_GET_CLASS(obj) OBJECT_GET_CLASS(S390TODClass, (obj), \
|
|
|
1359fb |
+ TYPE_S390_TOD)
|
|
|
1359fb |
+#define TYPE_KVM_S390_TOD TYPE_S390_TOD "-kvm"
|
|
|
1359fb |
+#define TYPE_QEMU_S390_TOD TYPE_S390_TOD "-qemu"
|
|
|
1359fb |
+
|
|
|
1359fb |
+typedef struct S390TODState {
|
|
|
1359fb |
+ /* private */
|
|
|
1359fb |
+ DeviceState parent_obj;
|
|
|
1359fb |
+} S390TODState;
|
|
|
1359fb |
+
|
|
|
1359fb |
+typedef struct S390TODClass {
|
|
|
1359fb |
+ /* private */
|
|
|
1359fb |
+ DeviceClass parent_class;
|
|
|
1359fb |
+
|
|
|
1359fb |
+ /* public */
|
|
|
1359fb |
+ void (*get)(const S390TODState *td, S390TOD *tod, Error **errp);
|
|
|
1359fb |
+ void (*set)(S390TODState *td, const S390TOD *tod, Error **errp);
|
|
|
1359fb |
+} S390TODClass;
|
|
|
1359fb |
+
|
|
|
1359fb |
+void s390_init_tod(void);
|
|
|
1359fb |
+
|
|
|
1359fb |
+#endif
|
|
|
1359fb |
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
|
|
|
1359fb |
index 1f590d1..167d089 100644
|
|
|
1359fb |
--- a/target/s390x/cpu.c
|
|
|
1359fb |
+++ b/target/s390x/cpu.c
|
|
|
1359fb |
@@ -391,38 +391,6 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
|
|
|
1359fb |
return s390_count_running_cpus();
|
|
|
1359fb |
}
|
|
|
1359fb |
|
|
|
1359fb |
-int s390_get_clock(uint8_t *tod_high, uint64_t *tod_low)
|
|
|
1359fb |
-{
|
|
|
1359fb |
- int r = 0;
|
|
|
1359fb |
-
|
|
|
1359fb |
- if (kvm_enabled()) {
|
|
|
1359fb |
- r = kvm_s390_get_clock_ext(tod_high, tod_low);
|
|
|
1359fb |
- if (r == -ENXIO) {
|
|
|
1359fb |
- return kvm_s390_get_clock(tod_high, tod_low);
|
|
|
1359fb |
- }
|
|
|
1359fb |
- } else {
|
|
|
1359fb |
- /* Fixme TCG */
|
|
|
1359fb |
- *tod_high = 0;
|
|
|
1359fb |
- *tod_low = 0;
|
|
|
1359fb |
- }
|
|
|
1359fb |
-
|
|
|
1359fb |
- return r;
|
|
|
1359fb |
-}
|
|
|
1359fb |
-
|
|
|
1359fb |
-int s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
|
|
|
1359fb |
-{
|
|
|
1359fb |
- int r = 0;
|
|
|
1359fb |
-
|
|
|
1359fb |
- if (kvm_enabled()) {
|
|
|
1359fb |
- r = kvm_s390_set_clock_ext(*tod_high, *tod_low);
|
|
|
1359fb |
- if (r == -ENXIO) {
|
|
|
1359fb |
- return kvm_s390_set_clock(*tod_high, *tod_low);
|
|
|
1359fb |
- }
|
|
|
1359fb |
- }
|
|
|
1359fb |
- /* Fixme TCG */
|
|
|
1359fb |
- return r;
|
|
|
1359fb |
-}
|
|
|
1359fb |
-
|
|
|
1359fb |
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
|
|
|
1359fb |
{
|
|
|
1359fb |
if (kvm_enabled()) {
|
|
|
1359fb |
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
|
|
|
1359fb |
index 86d08fa..67118c8 100644
|
|
|
1359fb |
--- a/target/s390x/cpu.h
|
|
|
1359fb |
+++ b/target/s390x/cpu.h
|
|
|
1359fb |
@@ -691,8 +691,6 @@ static inline uint64_t s390_build_validity_mcic(void)
|
|
|
1359fb |
|
|
|
1359fb |
|
|
|
1359fb |
/* cpu.c */
|
|
|
1359fb |
-int s390_get_clock(uint8_t *tod_high, uint64_t *tod_low);
|
|
|
1359fb |
-int s390_set_clock(uint8_t *tod_high, uint64_t *tod_low);
|
|
|
1359fb |
void s390_crypto_reset(void);
|
|
|
1359fb |
bool s390_get_squash_mcss(void);
|
|
|
1359fb |
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit);
|
|
|
1359fb |
diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h
|
|
|
1359fb |
index 36eb34b..6e52287 100644
|
|
|
1359fb |
--- a/target/s390x/kvm_s390x.h
|
|
|
1359fb |
+++ b/target/s390x/kvm_s390x.h
|
|
|
1359fb |
@@ -10,6 +10,8 @@
|
|
|
1359fb |
#ifndef KVM_S390X_H
|
|
|
1359fb |
#define KVM_S390X_H
|
|
|
1359fb |
|
|
|
1359fb |
+#include "cpu-qom.h"
|
|
|
1359fb |
+
|
|
|
1359fb |
struct kvm_s390_irq;
|
|
|
1359fb |
|
|
|
1359fb |
void kvm_s390_floating_interrupt_legacy(struct kvm_s390_irq *irq);
|
|
|
1359fb |
--
|
|
|
1359fb |
1.8.3.1
|
|
|
1359fb |
|