97168e
From 90fcfe4b07afc5299c5ee69fa663ca46b597fd4b Mon Sep 17 00:00:00 2001
97168e
From: Nico Boehr <nrb@linux.ibm.com>
97168e
Date: Wed, 12 Oct 2022 14:32:29 +0200
97168e
Subject: [PATCH] s390x/tod-kvm: don't save/restore the TOD in PV guests
97168e
MIME-Version: 1.0
97168e
Content-Type: text/plain; charset=UTF-8
97168e
Content-Transfer-Encoding: 8bit
97168e
97168e
RH-Author: Cédric Le Goater <clg@redhat.com>
97168e
RH-MergeRequest: 244: s390x/tod-kvm: don't save/restore the TOD in PV guests
97168e
RH-Bugzilla: 2155448
97168e
RH-Acked-by: David Hildenbrand <david@redhat.com>
97168e
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
97168e
RH-Acked-by: Thomas Huth <thuth@redhat.com>
97168e
RH-Commit: [1/1] 3cb3154dd7c1549c54cf8c0483b5f23b235f6db3
97168e
97168e
Under PV, the guest's TOD clock is under control of the ultravisor and the
97168e
hypervisor cannot change it.
97168e
97168e
With upcoming kernel changes[1], the Linux kernel will reject QEMU's
97168e
request to adjust the guest's clock in this case, so don't attempt to set
97168e
the clock.
97168e
97168e
This avoids the following warning message on save/restore of a PV guest:
97168e
97168e
warning: Unable to set KVM guest TOD clock: Operation not supported
97168e
97168e
[1] https://lore.kernel.org/all/20221011160712.928239-2-nrb@linux.ibm.com/
97168e
97168e
Fixes: c3347ed0d2ee ("s390x: protvirt: Support unpack facility")
97168e
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
97168e
Message-Id: <20221012123229.1196007-1-nrb@linux.ibm.com>
97168e
[thuth: Add curly braces]
97168e
Signed-off-by: Thomas Huth <thuth@redhat.com>
97168e
(cherry picked from commit 38621181ae3cbec62e3490fbc14f6ac01642d07a)
97168e
Signed-off-by: Cédric Le Goater <clg@redhat.com>
97168e
---
97168e
 hw/s390x/tod-kvm.c | 9 +++++++++
97168e
 1 file changed, 9 insertions(+)
97168e
97168e
diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c
97168e
index ec855811ae..c804c979b5 100644
97168e
--- a/hw/s390x/tod-kvm.c
97168e
+++ b/hw/s390x/tod-kvm.c
97168e
@@ -13,6 +13,7 @@
97168e
 #include "qemu/module.h"
97168e
 #include "sysemu/runstate.h"
97168e
 #include "hw/s390x/tod.h"
97168e
+#include "hw/s390x/pv.h"
97168e
 #include "kvm/kvm_s390x.h"
97168e
 
97168e
 static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp)
97168e
@@ -84,6 +85,14 @@ static void kvm_s390_tod_vm_state_change(void *opaque, bool running,
97168e
     S390TODState *td = opaque;
97168e
     Error *local_err = NULL;
97168e
 
97168e
+    /*
97168e
+     * Under PV, the clock is under ultravisor control, hence we cannot restore
97168e
+     * it on resume.
97168e
+     */
97168e
+    if (s390_is_pv()) {
97168e
+        return;
97168e
+    }
97168e
+
97168e
     if (running && td->stopped) {
97168e
         /* Set the old TOD when running the VM - start the TOD clock. */
97168e
         kvm_s390_set_tod_raw(&td->base, &local_err);
97168e
-- 
97168e
2.37.3
97168e