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