From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544608659168946.7247099966846; Wed, 12 Dec 2018 01:57:39 -0800 (PST) Received: from localhost ([::1]:43578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Gr-0007W8-HD for importer@patchew.org; Wed, 12 Dec 2018 04:57:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Ep-000661-Ap for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1En-0006Uw-9j for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17285) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1El-0006Jh-Ki; Wed, 12 Dec 2018 04:55:28 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CD2E1CA369; Wed, 12 Dec 2018 09:55:26 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53DBD60C5C; Wed, 12 Dec 2018 09:55:24 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:14 +0100 Message-Id: <20181212095519.6390-2-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Dec 2018 09:55:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/6] s390x/zpci: drop msix.available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand I fail to see why this is useful as we require MSIX always and completely fail adding a device. Signed-off-by: David Hildenbrand Message-Id: <20181105110313.29312-2-david@redhat.com> Fixes: 4f6482bfe3da1e6b51ad4722a0c22f22f0d54a3b Reviewed-by: Thomas Huth Reviewed-by: Collin Walling Signed-off-by: Cornelia Huck --- hw/s390x/s390-pci-bus.c | 2 -- hw/s390x/s390-pci-bus.h | 1 - 2 files changed, 3 deletions(-) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 060ff062bc..99d0368868 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -745,7 +745,6 @@ static int s390_pci_msix_init(S390PCIBusDevice *pbdev) =20 pos =3D pci_find_capability(pbdev->pdev, PCI_CAP_ID_MSIX); if (!pos) { - pbdev->msix.available =3D false; return -1; } =20 @@ -761,7 +760,6 @@ static int s390_pci_msix_init(S390PCIBusDevice *pbdev) pbdev->msix.pba_bar =3D pba & PCI_MSIX_FLAGS_BIRMASK; pbdev->msix.pba_offset =3D pba & ~PCI_MSIX_FLAGS_BIRMASK; pbdev->msix.entries =3D (ctrl & PCI_MSIX_FLAGS_QSIZE) + 1; - pbdev->msix.available =3D true; =20 name =3D g_strdup_printf("msix-s390-%04x", pbdev->uid); memory_region_init_io(&pbdev->msix_notify_mr, OBJECT(pbdev), diff --git a/hw/s390x/s390-pci-bus.h b/hw/s390x/s390-pci-bus.h index 1f7f9b5814..f47a0f2da5 100644 --- a/hw/s390x/s390-pci-bus.h +++ b/hw/s390x/s390-pci-bus.h @@ -252,7 +252,6 @@ typedef struct ChscSeiNt2Res { } QEMU_PACKED ChscSeiNt2Res; =20 typedef struct S390MsixInfo { - bool available; uint8_t table_bar; uint8_t pba_bar; uint16_t entries; --=20 2.17.2 From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544608743552764.047063163892; Wed, 12 Dec 2018 01:59:03 -0800 (PST) Received: from localhost ([::1]:43584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1I8-0000cg-Bz for importer@patchew.org; Wed, 12 Dec 2018 04:58:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43546) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Er-000684-EH for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1Ep-0006Xv-DN for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41968) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1Ep-0006Um-5n; Wed, 12 Dec 2018 04:55:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5400E1F05; Wed, 12 Dec 2018 09:55:28 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4F261600C9; Wed, 12 Dec 2018 09:55:28 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:15 +0100 Message-Id: <20181212095519.6390-3-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Dec 2018 09:55:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/6] s390x: introduce 4.0 compat machine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/s390x/s390-virtio-ccw.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index a0615a8b35..fd9d0b0542 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -651,6 +651,9 @@ bool css_migration_enabled(void) } = \ type_init(ccw_machine_register_##suffix) =20 +#define CCW_COMPAT_3_1 \ + HW_COMPAT_3_1 + #define CCW_COMPAT_3_0 \ HW_COMPAT_3_0 =20 @@ -742,14 +745,26 @@ bool css_migration_enabled(void) .value =3D "0",\ }, =20 +static void ccw_machine_4_0_instance_options(MachineState *machine) +{ +} + +static void ccw_machine_4_0_class_options(MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(4_0, "4.0", true); + static void ccw_machine_3_1_instance_options(MachineState *machine) { + ccw_machine_4_0_instance_options(machine); } =20 static void ccw_machine_3_1_class_options(MachineClass *mc) { + ccw_machine_4_0_class_options(mc); + SET_MACHINE_COMPAT(mc, CCW_COMPAT_3_1); } -DEFINE_CCW_MACHINE(3_1, "3.1", true); +DEFINE_CCW_MACHINE(3_1, "3.1", false); =20 static void ccw_machine_3_0_instance_options(MachineState *machine) { --=20 2.17.2 From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544608815884568.4569137215079; Wed, 12 Dec 2018 02:00:15 -0800 (PST) Received: from localhost ([::1]:43593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1JO-0001q1-Om for importer@patchew.org; Wed, 12 Dec 2018 05:00:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Eu-0006An-L4 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1Er-0006ZE-B0 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57144) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1Ep-0006XF-Dz; Wed, 12 Dec 2018 04:55:32 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B163A307CDF4; Wed, 12 Dec 2018 09:55:30 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 248F219940; Wed, 12 Dec 2018 09:55:29 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:16 +0100 Message-Id: <20181212095519.6390-4-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 12 Dec 2018 09:55:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/6] s390/MAINTAINERS: Add Halil as kvm and machine maintainer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Christian Borntraeger Halil does more work in this area than I do right now. Lets add Halil. Signed-off-by: Christian Borntraeger Message-Id: <20181204133802.100998-1-borntraeger@de.ibm.com> Acked-by: Halil Pasic Signed-off-by: Cornelia Huck --- MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 63effdc473..76fbf1331a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -365,8 +365,9 @@ S: Maintained F: target/ppc/kvm.c =20 S390 -M: Christian Borntraeger +M: Halil Pasic M: Cornelia Huck +M: Christian Borntraeger S: Maintained F: target/s390x/kvm.c F: target/s390x/kvm_s390x.h @@ -1057,6 +1058,7 @@ S390 Machines ------------- S390 Virtio-ccw M: Cornelia Huck +M: Halil Pasic M: Christian Borntraeger S: Supported F: hw/char/sclp*.[hc] --=20 2.17.2 From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544608838986603.5033872722605; Wed, 12 Dec 2018 02:00:38 -0800 (PST) Received: from localhost ([::1]:43596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Jl-00028n-M1 for importer@patchew.org; Wed, 12 Dec 2018 05:00:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Eu-0006Aq-MK for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1Er-0006bx-QS for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55444) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1Er-0006Yg-HN; Wed, 12 Dec 2018 04:55:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B6D7330820D8; Wed, 12 Dec 2018 09:55:32 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 329EF60C46; Wed, 12 Dec 2018 09:55:32 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:17 +0100 Message-Id: <20181212095519.6390-5-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Dec 2018 09:55:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/6] s390x/tod: Properly stop the KVM TOD while the guest is not running X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Just like on other architectures, we should stop the clock while the guest is not running. This is already properly done for TCG. Right now, doing an offline migration (stop, migrate, cont) can easily trigger stalls in the guest. Even doing a (hmp) stop ... wait 2 minutes ... (hmp) cont will already trigger stalls. So whenever the guest stops, backup the KVM TOD. When continuing to run the guest, restore the KVM TOD. One special case is starting a simple VM: Reading the TOD from KVM to stop it right away until the guest is actually started means that the time of any simple VM will already differ to the host time. We can simply leave the TOD running and the guest won't be able to recognize it. For migration, we actually want to keep the TOD stopped until really starting the guest. To be able to catch most errors, we should however try to set the TOD in addition to simply storing it. So we can still catch basic migration problems. If anything goes wrong while backing up/restoring the TOD, we have to ignore it (but print a warning). This is then basically a fallback to old behavior (TOD remains running). I tested this very basically with an initrd: 1. Start a simple VM. Observed that the TOD is kept running. Old behavior. 2. Ordinary live migration. Observed that the TOD is temporarily stopped on the destination when setting the new value and correctly started when finally starting the guest. 3. Offline live migration. (stop, migrate, cont). Observed that the TOD will be stopped on the source with the "stop" command. On the destination, the TOD is temporarily stopped when setting the new value and correctly started when finally starting the guest via "cont". 4. Simple stop/cont correctly stops/starts the TOD. (multiple stops or conts in a row have no effect, so works as expected) In the future, we might want to send the guest a special kind of time sync interrupt under some conditions, so it can synchronize its tod to the host tod. This is interesting for migration scenarios but also when we get time sync interrupts ourselves. This however will most probably have to be handled in KVM (e.g. when the tods differ too much) and is not desired e.g. when debugging the guest (single stepping should not result in permanent time syncs). I consider something like that an add-on on top of this basic "don't break the guest" handling. Signed-off-by: David Hildenbrand Message-Id: <20181130094957.4121-1-david@redhat.com> Acked-by: Christian Borntraeger Reviewed-by: Thomas Huth Signed-off-by: Cornelia Huck --- hw/s390x/tod-kvm.c | 102 ++++++++++++++++++++++++++++++++++++++++- include/hw/s390x/tod.h | 8 +++- 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c index df564ab89c..2456bf7b24 100644 --- a/hw/s390x/tod-kvm.c +++ b/hw/s390x/tod-kvm.c @@ -10,10 +10,11 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "sysemu/sysemu.h" #include "hw/s390x/tod.h" #include "kvm_s390x.h" =20 -static void kvm_s390_tod_get(const S390TODState *td, S390TOD *tod, Error *= *errp) +static void kvm_s390_get_tod_raw(S390TOD *tod, Error **errp) { int r; =20 @@ -27,7 +28,17 @@ static void kvm_s390_tod_get(const S390TODState *td, S39= 0TOD *tod, Error **errp) } } =20 -static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error *= *errp) +static void kvm_s390_tod_get(const S390TODState *td, S390TOD *tod, Error *= *errp) +{ + if (td->stopped) { + *tod =3D td->base; + return; + } + + kvm_s390_get_tod_raw(tod, errp); +} + +static void kvm_s390_set_tod_raw(const S390TOD *tod, Error **errp) { int r; =20 @@ -41,18 +52,105 @@ static void kvm_s390_tod_set(S390TODState *td, const S= 390TOD *tod, Error **errp) } } =20 +static void kvm_s390_tod_set(S390TODState *td, const S390TOD *tod, Error *= *errp) +{ + Error *local_err =3D NULL; + + /* + * Somebody (e.g. migration) set the TOD. We'll store it into KVM to + * properly detect errors now but take a look at the runstate to decide + * whether really to keep the tod running. E.g. during migration, this + * is the point where we want to stop the initially running TOD to fire + * it back up when actually starting the migrated guest. + */ + kvm_s390_set_tod_raw(tod, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (runstate_is_running()) { + td->stopped =3D false; + } else { + td->stopped =3D true; + td->base =3D *tod; + } +} + +static void kvm_s390_tod_vm_state_change(void *opaque, int running, + RunState state) +{ + S390TODState *td =3D opaque; + Error *local_err =3D NULL; + + if (running && td->stopped) { + /* Set the old TOD when running the VM - start the TOD clock. */ + kvm_s390_set_tod_raw(&td->base, &local_err); + if (local_err) { + warn_report_err(local_err); + } + /* Treat errors like the TOD was running all the time. */ + td->stopped =3D false; + } else if (!running && !td->stopped) { + /* Store the TOD when stopping the VM - stop the TOD clock. */ + kvm_s390_get_tod_raw(&td->base, &local_err); + if (local_err) { + /* Keep the TOD running in case we could not back it up. */ + warn_report_err(local_err); + } else { + td->stopped =3D true; + } + } +} + +static void kvm_s390_tod_realize(DeviceState *dev, Error **errp) +{ + S390TODState *td =3D S390_TOD(dev); + S390TODClass *tdc =3D S390_TOD_GET_CLASS(td); + Error *local_err =3D NULL; + + tdc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + /* + * We need to know when the VM gets started/stopped to start/stop the = TOD. + * As we can never have more than one TOD instance (and that will neve= r be + * removed), registering here and never unregistering is good enough. + */ + qemu_add_vm_change_state_handler(kvm_s390_tod_vm_state_change, td); +} + static void kvm_s390_tod_class_init(ObjectClass *oc, void *data) { S390TODClass *tdc =3D S390_TOD_CLASS(oc); =20 + device_class_set_parent_realize(DEVICE_CLASS(oc), kvm_s390_tod_realize, + &tdc->parent_realize); tdc->get =3D kvm_s390_tod_get; tdc->set =3D kvm_s390_tod_set; } =20 +static void kvm_s390_tod_init(Object *obj) +{ + S390TODState *td =3D S390_TOD(obj); + + /* + * The TOD is initially running (value stored in KVM). Avoid needless + * loading/storing of the TOD when starting a simple VM, so let it + * run although the (never started) VM is stopped. For migration, we + * will properly set the TOD later. + */ + td->stopped =3D false; +} + static TypeInfo kvm_s390_tod_info =3D { .name =3D TYPE_KVM_S390_TOD, .parent =3D TYPE_S390_TOD, .instance_size =3D sizeof(S390TODState), + .instance_init =3D kvm_s390_tod_init, .class_init =3D kvm_s390_tod_class_init, .class_size =3D sizeof(S390TODClass), }; diff --git a/include/hw/s390x/tod.h b/include/hw/s390x/tod.h index 413c0d7c02..cbd7552e7a 100644 --- a/include/hw/s390x/tod.h +++ b/include/hw/s390x/tod.h @@ -31,13 +31,19 @@ typedef struct S390TODState { /* private */ DeviceState parent_obj; =20 - /* unused by KVM implementation */ + /* + * Used by TCG to remember the time base. Used by KVM to backup the TOD + * while the TOD is stopped. + */ S390TOD base; + /* Used by KVM to remember if the TOD is stopped and base is valid. */ + bool stopped; } S390TODState; =20 typedef struct S390TODClass { /* private */ DeviceClass parent_class; + void (*parent_realize)(DeviceState *dev, Error **errp); =20 /* public */ void (*get)(const S390TODState *td, S390TOD *tod, Error **errp); --=20 2.17.2 From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544608986078759.9999049101976; Wed, 12 Dec 2018 02:03:06 -0800 (PST) Received: from localhost ([::1]:43620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1M4-0003uO-3A for importer@patchew.org; Wed, 12 Dec 2018 05:03:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Ev-0006Ba-89 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1Et-0006oq-N5 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39124) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1Et-0006jE-F4; Wed, 12 Dec 2018 04:55:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92543FECB; Wed, 12 Dec 2018 09:55:34 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3BB1A1054FCC; Wed, 12 Dec 2018 09:55:34 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:18 +0100 Message-Id: <20181212095519.6390-6-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 12 Dec 2018 09:55:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/6] vfio-ap: flag as compatible with balloon X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" vfio-ap devices do not pin any pages in the host. Therefore, they are compatible with memory ballooning. Flag them as compatible, so both vfio-ap and a balloon can be used simultaneously. Cc: qemu-stable@nongnu.org Acked-by: Christian Borntraeger Tested-by: Tony Krowiak Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck --- hw/vfio/ap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 65de952f44..0a25f5e096 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -104,6 +104,14 @@ static void vfio_ap_realize(DeviceState *dev, Error **= errp) vapdev->vdev.name =3D g_strdup_printf("%s", mdevid); vapdev->vdev.dev =3D dev; =20 + /* + * vfio-ap devices operate in a way compatible with + * memory ballooning, as no pages are pinned in the host. + * This needs to be set before vfio_get_device() for vfio common to + * handle the balloon inhibitor. + */ + vapdev->vdev.balloon_allowed =3D true; + ret =3D vfio_get_device(vfio_group, mdevid, &vapdev->vdev, &local_err); if (ret) { goto out_get_dev_err; --=20 2.17.2 From nobody Mon May 6 00:45:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544609014324921.7030273999002; Wed, 12 Dec 2018 02:03:34 -0800 (PST) Received: from localhost ([::1]:43621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1MW-0004Qe-VE for importer@patchew.org; Wed, 12 Dec 2018 05:03:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX1Ex-0006EH-Kr for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX1Ev-0006qJ-SZ for qemu-devel@nongnu.org; Wed, 12 Dec 2018 04:55:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX1Ev-0006pg-Hf; Wed, 12 Dec 2018 04:55:37 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 727FE5F78F; Wed, 12 Dec 2018 09:55:36 +0000 (UTC) Received: from localhost (dhcp-192-187.str.redhat.com [10.33.192.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17C84600C9; Wed, 12 Dec 2018 09:55:35 +0000 (UTC) From: Cornelia Huck To: Peter Maydell Date: Wed, 12 Dec 2018 10:55:19 +0100 Message-Id: <20181212095519.6390-7-cohuck@redhat.com> In-Reply-To: <20181212095519.6390-1-cohuck@redhat.com> References: <20181212095519.6390-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 12 Dec 2018 09:55:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/6] hw/s390x/virtio-ccw.c: Don't take address of fields in packed structs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Peter Maydell Taking the address of a field in a packed struct is a bad idea, because it might not be actually aligned enough for that pointer type (and thus cause a crash on dereference on some host architectures). Newer versions of clang warn about this. Avoid the bug by not using the "modify in place" byte swapping functions. Patch produced with scripts/coccinelle/inplace-byteswaps.cocci (with a couple of long lines manually wrapped). Signed-off-by: Peter Maydell Message-Id: <20181210120436.30522-1-peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 212b3d3dea..c2b78c8e9b 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -287,18 +287,18 @@ static int virtio_ccw_handle_set_vq(SubchDev *sch, CC= W1 ccw, bool check_len, } if (is_legacy) { ccw_dstream_read(&sch->cds, linfo); - be64_to_cpus(&linfo.queue); - be32_to_cpus(&linfo.align); - be16_to_cpus(&linfo.index); - be16_to_cpus(&linfo.num); + linfo.queue =3D be64_to_cpu(linfo.queue); + linfo.align =3D be32_to_cpu(linfo.align); + linfo.index =3D be16_to_cpu(linfo.index); + linfo.num =3D be16_to_cpu(linfo.num); ret =3D virtio_ccw_set_vqs(sch, NULL, &linfo); } else { ccw_dstream_read(&sch->cds, info); - be64_to_cpus(&info.desc); - be16_to_cpus(&info.index); - be16_to_cpus(&info.num); - be64_to_cpus(&info.avail); - be64_to_cpus(&info.used); + info.desc =3D be64_to_cpu(info.desc); + info.index =3D be16_to_cpu(info.index); + info.num =3D be16_to_cpu(info.num); + info.avail =3D be64_to_cpu(info.avail); + info.used =3D be64_to_cpu(info.used); ret =3D virtio_ccw_set_vqs(sch, &info, NULL); } sch->curr_status.scsw.count =3D 0; @@ -382,7 +382,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) features.features =3D 0; } ccw_dstream_rewind(&sch->cds); - cpu_to_le32s(&features.features); + features.features =3D cpu_to_le32(features.features); ccw_dstream_write(&sch->cds, features.features); sch->curr_status.scsw.count =3D ccw.count - sizeof(features); ret =3D 0; @@ -403,7 +403,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret =3D -EFAULT; } else { ccw_dstream_read(&sch->cds, features); - le32_to_cpus(&features.features); + features.features =3D le32_to_cpu(features.features); if (features.index =3D=3D 0) { virtio_set_features(vdev, (vdev->guest_features & 0xffffffff0000= 0000ULL) | @@ -546,7 +546,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret =3D -EFAULT; } else { ccw_dstream_read(&sch->cds, indicators); - be64_to_cpus(&indicators); + indicators =3D be64_to_cpu(indicators); dev->indicators =3D get_indicator(indicators, sizeof(uint64_t)= ); sch->curr_status.scsw.count =3D ccw.count - sizeof(indicators); ret =3D 0; @@ -567,7 +567,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret =3D -EFAULT; } else { ccw_dstream_read(&sch->cds, indicators); - be64_to_cpus(&indicators); + indicators =3D be64_to_cpu(indicators); dev->indicators2 =3D get_indicator(indicators, sizeof(uint64_t= )); sch->curr_status.scsw.count =3D ccw.count - sizeof(indicators); ret =3D 0; @@ -588,14 +588,14 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret =3D -EFAULT; } else { ccw_dstream_read(&sch->cds, vq_config.index); - be16_to_cpus(&vq_config.index); + vq_config.index =3D be16_to_cpu(vq_config.index); if (vq_config.index >=3D VIRTIO_QUEUE_MAX) { ret =3D -EINVAL; break; } vq_config.num_max =3D virtio_queue_get_num(vdev, vq_config.index); - cpu_to_be16s(&vq_config.num_max); + vq_config.num_max =3D cpu_to_be16(vq_config.num_max); ccw_dstream_write(&sch->cds, vq_config.num_max); sch->curr_status.scsw.count =3D ccw.count - sizeof(vq_config); ret =3D 0; @@ -621,9 +621,11 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) if (ccw_dstream_read(&sch->cds, thinint)) { ret =3D -EFAULT; } else { - be64_to_cpus(&thinint.ind_bit); - be64_to_cpus(&thinint.summary_indicator); - be64_to_cpus(&thinint.device_indicator); + thinint.ind_bit =3D be64_to_cpu(thinint.ind_bit); + thinint.summary_indicator =3D + be64_to_cpu(thinint.summary_indicator); + thinint.device_indicator =3D + be64_to_cpu(thinint.device_indicator); =20 dev->summary_indicator =3D get_indicator(thinint.summary_indicator, sizeof(uint8_= t)); @@ -654,8 +656,8 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) break; } ccw_dstream_read_buf(&sch->cds, &revinfo, 4); - be16_to_cpus(&revinfo.revision); - be16_to_cpus(&revinfo.length); + revinfo.revision =3D be16_to_cpu(revinfo.revision); + revinfo.length =3D be16_to_cpu(revinfo.length); if (ccw.count < len + revinfo.length || (check_len && ccw.count > len + revinfo.length)) { ret =3D -EINVAL; --=20 2.17.2