From nobody Sat Apr 27 06:54:58 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506524338728149.1496521087381; Wed, 27 Sep 2017 07:58:58 -0700 (PDT) Received: from localhost ([::1]:55152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDnV-0001UD-06 for importer@patchew.org; Wed, 27 Sep 2017 10:58:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDm0-0000Wq-Rh for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxDlw-0001Yd-Vq for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60459) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxDlp-0001VG-Im; Wed, 27 Sep 2017 10:57:05 -0400 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 6B1DD12988B; Wed, 27 Sep 2017 14:57:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-163.ams2.redhat.com [10.36.116.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EC8094C6D; Wed, 27 Sep 2017 14:57:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6B1DD12988B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wanghaibin.wang@huawei.com Date: Wed, 27 Sep 2017 16:56:43 +0200 Message-Id: <1506524205-20763-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1506524205-20763-1-git-send-email-eric.auger@redhat.com> References: <1506524205-20763-1-git-send-email-eric.auger@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, 27 Sep 2017 14:57:04 +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] [RFC 1/3] hw/intc/arm_gicv3_its: Don't abort on table save/restore 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: wei@redhat.com, drjones@redhat.com, vijay.kilari@gmail.com, quintela@redhat.com, dgilbert@redhat.com, wu.wubin@huawei.com, christoffer.dall@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ITS is not properly reset at the moment. It is possible the GITS_BASER.valid is set and the in-kernel ITS caches are not empty (list of devices, collections, LPIs) while data structures in guest RAM are invalid/inconsistent. For instance, this happens after a guest shutdown -r now or a system reset, if we save the state before the guest re-writes the ITS registers or map devices, the table save ioctl may produce a QEMU abort. Until there is a proper reset implemented, let's unplug the consistency error checking. The reset issue will be fixed in subsequent patches. Signed-off-by: Eric Auger Reported-by: wanghaibin --- this patch would deserve being cc'ed stable (2.10) --- hw/intc/arm_gicv3_its_kvm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 39903d5..120b86d 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -64,20 +64,16 @@ static void vm_change_state_handler(void *opaque, int r= unning, { GICv3ITSState *s =3D (GICv3ITSState *)opaque; Error *err =3D NULL; - int ret; =20 if (running) { return; } =20 - ret =3D kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, - KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, + KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); if (err) { error_report_err(err); } - if (ret < 0 && ret !=3D -EFAULT) { - abort(); - } } =20 static void kvm_arm_its_realize(DeviceState *dev, Error **errp) @@ -157,6 +153,7 @@ static void kvm_arm_its_pre_save(GICv3ITSState *s) */ static void kvm_arm_its_post_load(GICv3ITSState *s) { + Error *err =3D NULL; int i; =20 if (!s->iidr) { @@ -188,7 +185,11 @@ static void kvm_arm_its_post_load(GICv3ITSState *s) =20 kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_ITS_RESTORE_TABLES, NULL, true, - &error_abort); + &err); + + if (err) { + error_report_err(err); + } =20 kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, GITS_CTLR, &s->ctlr, true, &error_abort); --=20 2.5.5 From nobody Sat Apr 27 06:54:58 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506524346191969.463147750666; Wed, 27 Sep 2017 07:59:06 -0700 (PDT) Received: from localhost ([::1]:55154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDni-0001dm-BG for importer@patchew.org; Wed, 27 Sep 2017 10:59:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDmA-0000ho-Cq for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxDm4-0001c4-R8 for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxDm2-0001ag-A2; Wed, 27 Sep 2017 10:57:18 -0400 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 2F1B27EAA0; Wed, 27 Sep 2017 14:57:17 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-163.ams2.redhat.com [10.36.116.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFAA395211; Wed, 27 Sep 2017 14:57:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F1B27EAA0 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wanghaibin.wang@huawei.com Date: Wed, 27 Sep 2017 16:56:44 +0200 Message-Id: <1506524205-20763-3-git-send-email-eric.auger@redhat.com> In-Reply-To: <1506524205-20763-1-git-send-email-eric.auger@redhat.com> References: <1506524205-20763-1-git-send-email-eric.auger@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.28]); Wed, 27 Sep 2017 14:57:17 +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] [RFC 2/3] linux-headers: Partial header update for ITS reset 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: wei@redhat.com, drjones@redhat.com, vijay.kilari@gmail.com, quintela@redhat.com, dgilbert@redhat.com, wu.wubin@huawei.com, christoffer.dall@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This aims at importing the KVM_DEV_ARM_ITS_CTRL_RESET attribute which allows to trigger a reset of the in-kernel emulated ITS. This is not yet upstream but can be found on the follwing branch: https://github.com/eauger/linux/tree/v4.14-rc2-its-reset-v2 Signed-off-by: Eric Auger --- linux-headers/asm-arm/kvm.h | 1 + linux-headers/asm-arm64/kvm.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h index fa9fae8..8dd0ba7 100644 --- a/linux-headers/asm-arm/kvm.h +++ b/linux-headers/asm-arm/kvm.h @@ -215,6 +215,7 @@ struct kvm_arch_memory_slot { #define KVM_DEV_ARM_ITS_SAVE_TABLES 1 #define KVM_DEV_ARM_ITS_RESTORE_TABLES 2 #define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 +#define KVM_DEV_ARM_ITS_CTRL_RESET 4 =20 /* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24 diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index d254700..2585a50 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -227,6 +227,7 @@ struct kvm_arch_memory_slot { #define KVM_DEV_ARM_ITS_SAVE_TABLES 1 #define KVM_DEV_ARM_ITS_RESTORE_TABLES 2 #define KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES 3 +#define KVM_DEV_ARM_ITS_CTRL_RESET 4 =20 /* Device Control API on vcpu fd */ #define KVM_ARM_VCPU_PMU_V3_CTRL 0 --=20 2.5.5 From nobody Sat Apr 27 06:54:58 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506524473263264.1745969213126; Wed, 27 Sep 2017 08:01:13 -0700 (PDT) Received: from localhost ([::1]:55167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDpc-0003Pg-Fc for importer@patchew.org; Wed, 27 Sep 2017 11:01:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxDmL-0000rf-Qb for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxDmK-0001iL-W8 for qemu-devel@nongnu.org; Wed, 27 Sep 2017 10:57:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46924) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxDmG-0001gJ-4U; Wed, 27 Sep 2017 10:57:32 -0400 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 EF34C883BF; Wed, 27 Sep 2017 14:57:30 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-163.ams2.redhat.com [10.36.116.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 895B096558; Wed, 27 Sep 2017 14:57:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF34C883BF Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=eric.auger@redhat.com From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, wanghaibin.wang@huawei.com Date: Wed, 27 Sep 2017 16:56:45 +0200 Message-Id: <1506524205-20763-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1506524205-20763-1-git-send-email-eric.auger@redhat.com> References: <1506524205-20763-1-git-send-email-eric.auger@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.26]); Wed, 27 Sep 2017 14:57:31 +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] [RFC 3/3] hw/intc/arm_gicv3_its: Implement reset 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: wei@redhat.com, drjones@redhat.com, vijay.kilari@gmail.com, quintela@redhat.com, dgilbert@redhat.com, wu.wubin@huawei.com, christoffer.dall@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently the ITS is not reset and this causes trouble when state backup is initiated before the guest has initialized the ITS registers and especially GITS_CBASER. We are likely to save register values set before the reset/ restart. The register values may not be consistent with the data structures in RAM. So let's use the ITS KVM device new combo, KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_ITS_CTRL_RESET to explicitly force the in-kernel emulated reset. Signed-off-by: Eric Auger --- hw/intc/arm_gicv3_its_common.c | 5 ++--- hw/intc/arm_gicv3_its_kvm.c | 22 ++++++++++++++++++---- include/hw/intc/arm_gicv3_its_common.h | 1 + 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c index 68b20fc..a2fe561 100644 --- a/hw/intc/arm_gicv3_its_common.c +++ b/hw/intc/arm_gicv3_its_common.c @@ -129,15 +129,14 @@ static void gicv3_its_common_reset(DeviceState *dev) s->creadr =3D 0; s->iidr =3D 0; memset(&s->baser, 0, sizeof(s->baser)); - - gicv3_its_post_load(s, 0); } =20 static void gicv3_its_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + GICv3ITSCommonClass *c =3D ARM_GICV3_ITS_COMMON_CLASS(klass); =20 - dc->reset =3D gicv3_its_common_reset; + c->parent_reset =3D gicv3_its_common_reset; dc->vmsd =3D &vmstate_its; } =20 diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 120b86d..3c2e724 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -156,10 +156,6 @@ static void kvm_arm_its_post_load(GICv3ITSState *s) Error *err =3D NULL; int i; =20 - if (!s->iidr) { - return; - } - kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_ITS_REGS, GITS_IIDR, &s->iidr, true, &error_abort); =20 @@ -195,6 +191,23 @@ static void kvm_arm_its_post_load(GICv3ITSState *s) GITS_CTLR, &s->ctlr, true, &error_abort); } =20 +static void kvm_arm_its_reset(DeviceState *dev) +{ + GICv3ITSState *s =3D ARM_GICV3_ITS_COMMON(dev); + GICv3ITSCommonClass *c =3D ARM_GICV3_ITS_COMMON_GET_CLASS(s); + + c->parent_reset(dev); + + if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, + KVM_DEV_ARM_ITS_CTRL_RESET)) { + error_report("ITS KVM: reset is not supported by the kernel"); + return; + } + + kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, + KVM_DEV_ARM_ITS_CTRL_RESET, NULL, true, &error_abort= ); +} + static Property kvm_arm_its_props[] =3D { DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "kvm-arm-gicv3", GICv3State *), @@ -211,6 +224,7 @@ static void kvm_arm_its_class_init(ObjectClass *klass, = void *data) icc->send_msi =3D kvm_its_send_msi; icc->pre_save =3D kvm_arm_its_pre_save; icc->post_load =3D kvm_arm_its_post_load; + dc->reset =3D kvm_arm_its_reset; } =20 static const TypeInfo kvm_arm_its_info =3D { diff --git a/include/hw/intc/arm_gicv3_its_common.h b/include/hw/intc/arm_g= icv3_its_common.h index fd1fe64..c158e9f 100644 --- a/include/hw/intc/arm_gicv3_its_common.h +++ b/include/hw/intc/arm_gicv3_its_common.h @@ -79,6 +79,7 @@ struct GICv3ITSCommonClass { int (*send_msi)(GICv3ITSState *s, uint32_t data, uint16_t devid); void (*pre_save)(GICv3ITSState *s); void (*post_load)(GICv3ITSState *s); + void (*parent_reset)(DeviceState *dev); }; =20 typedef struct GICv3ITSCommonClass GICv3ITSCommonClass; --=20 2.5.5