From nobody Tue Apr 30 21:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568895717; cv=none; d=zoho.com; s=zohoarc; b=fG4b5mCiIew5T0SsTJaawpxyvqFcl+SlemjHy9mUAl+iCfWmBfSXQPx+rrUXKklMY3IuNViUEDDCIqQib2v1jEMxCHtKLyZw3VbV6kbVllt1ASU4WFa+jt+lSnrICRBGMkGkQ2cJiahUNMajZnxGcGs8vIGou458k5/hnPXThFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568895717; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oNVYLQy1ElpKhISzXhwKTbYZl0rcLsbdO/tsk+iLaas=; b=IOV+/0rMOPamf5WRwa5gBvmCO8EnNGzyFHvJvEwDNM+cqtxgKPgUJZGSJHebuuGM/5GxkrKMkKQ0dLdY7H6Tpw5OCGjWN9sWr3mFIdmxEjH0ptFU0PBUMcvZ3TvyQhiHROouEEJSFgndjWu1Am+tb7Ia5XBSZepjxEb49WbgiSU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568895717056561.5546326122608; Thu, 19 Sep 2019 05:21:57 -0700 (PDT) Received: from localhost ([::1]:43400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvRb-0007Ky-9W for importer@patchew.org; Thu, 19 Sep 2019 08:21:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37681) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvOw-0005Bc-Ps for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAvOu-0003v4-Q3 for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAvOq-0003ph-07; Thu, 19 Sep 2019 08:19:04 -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 3E8B22A09A0; Thu, 19 Sep 2019 12:19:03 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7E1F60BF1; Thu, 19 Sep 2019 12:19:00 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, alex.williamson@redhat.com, peterx@redhat.com Date: Thu, 19 Sep 2019 14:18:41 +0200 Message-Id: <20190919121845.29520-2-eric.auger@redhat.com> In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com> References: <20190919121845.29520-1-eric.auger@redhat.com> MIME-Version: 1.0 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]); Thu, 19 Sep 2019 12:19:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/5] memory: allow memory_region_register_iommu_notifier() to fail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Currently, when a notifier is attempted to be registered and its flags are not supported (especially the MAP one) by the IOMMU MR, we generally abruptly exit in the IOMMU code. The failure could be handled more nicely in the caller and especially in the VFIO code. So let's allow memory_region_register_iommu_notifier() to fail as well as notify_flag_changed() callback. All sites implementing the callback are updated. This patch does not yet remove the exit(1) in the amd_iommu code. in SMMUv3 we turn the warning message into an error message saying that the assigned device would not work properly. Signed-off-by: Eric Auger --- v2 -> v3: - turn the warning message into an error message --- hw/arm/smmuv3.c | 12 +++++++----- hw/i386/amd_iommu.c | 7 ++++--- hw/i386/intel_iommu.c | 7 ++++--- hw/ppc/spapr_iommu.c | 7 ++++--- include/exec/memory.h | 18 +++++++++++++----- memory.c | 28 ++++++++++++++++++---------- 6 files changed, 50 insertions(+), 29 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index db051dcac8..2845aa7ffd 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1469,9 +1469,9 @@ static void smmuv3_class_init(ObjectClass *klass, voi= d *data) dc->realize =3D smmu_realize; } =20 -static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) +static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new) { SMMUDevice *sdev =3D container_of(iommu, SMMUDevice, iommu); SMMUv3State *s3 =3D sdev->smmu; @@ -1481,8 +1481,9 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryReg= ion *iommu, int bus_num =3D pci_bus_num(sdev->bus); PCIDevice *pcidev =3D pci_find_device(sdev->bus, bus_num, sdev->de= vfn); =20 - warn_report("SMMUv3 does not support notification on MAP: " - "device %s will not function properly", pcidev->name); + error_report("SMMUv3 does not support notification on MAP: " + "device %s would not function properly", pcidev->name= ); + return -EINVAL; } =20 if (old =3D=3D IOMMU_NOTIFIER_NONE) { @@ -1492,6 +1493,7 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryReg= ion *iommu, trace_smmuv3_notify_flag_del(iommu->parent_obj.name); QLIST_REMOVE(sdev, next); } + return 0; } =20 static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass, diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 08884523e2..137ba367db 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1466,9 +1466,9 @@ static const MemoryRegionOps mmio_mem_ops =3D { } }; =20 -static void amdvi_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) +static int amdvi_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new) { AMDVIAddressSpace *as =3D container_of(iommu, AMDVIAddressSpace, iommu= ); =20 @@ -1478,6 +1478,7 @@ static void amdvi_iommu_notify_flag_changed(IOMMUMemo= ryRegion *iommu, PCI_FUNC(as->devfn)); exit(1); } + return 0; } =20 static void amdvi_init(AMDVIState *s) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index f1de8fdb75..6465a570a1 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2929,9 +2929,9 @@ static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryR= egion *iommu, hwaddr addr, return iotlb; } =20 -static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) +static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new) { VTDAddressSpace *vtd_as =3D container_of(iommu, VTDAddressSpace, iommu= ); IntelIOMMUState *s =3D vtd_as->iommu_state; @@ -2944,6 +2944,7 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemory= Region *iommu, } else if (new =3D=3D IOMMU_NOTIFIER_NONE) { QLIST_REMOVE(vtd_as, next); } + return 0; } =20 static int vtd_post_load(void *opaque, int version_id) diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index e87b3d50f7..8d3b38f90b 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -205,9 +205,9 @@ static int spapr_tce_get_attr(IOMMUMemoryRegion *iommu, return -EINVAL; } =20 -static void spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, - IOMMUNotifierFlag old, - IOMMUNotifierFlag new) +static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, + IOMMUNotifierFlag old, + IOMMUNotifierFlag new) { struct SpaprTceTable *tbl =3D container_of(iommu, SpaprTceTable, iommu= ); =20 @@ -216,6 +216,7 @@ static void spapr_tce_notify_flag_changed(IOMMUMemoryRe= gion *iommu, } else if (old !=3D IOMMU_NOTIFIER_NONE && new =3D=3D IOMMU_NOTIFIER_N= ONE) { spapr_tce_set_need_vfio(tbl, false); } + return 0; } =20 static int spapr_tce_table_post_load(void *opaque, int version_id) diff --git a/include/exec/memory.h b/include/exec/memory.h index a30245c25a..83257e3dce 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -288,10 +288,14 @@ typedef struct IOMMUMemoryRegionClass { * @iommu: the IOMMUMemoryRegion * @old_flags: events which previously needed to be notified * @new_flags: events which now need to be notified + * + * Returns 0 on success, or a negative errno; in particular + * returns -EINVAL if the new flag bitmap is not supported by the + * IOMMU memory region. */ - void (*notify_flag_changed)(IOMMUMemoryRegion *iommu, - IOMMUNotifierFlag old_flags, - IOMMUNotifierFlag new_flags); + int (*notify_flag_changed)(IOMMUMemoryRegion *iommu, + IOMMUNotifierFlag old_flags, + IOMMUNotifierFlag new_flags); /* Called to handle memory_region_iommu_replay(). * * The default implementation of memory_region_iommu_replay() is to @@ -1067,13 +1071,17 @@ void memory_region_notify_one(IOMMUNotifier *notifi= er, * memory_region_register_iommu_notifier: register a notifier for changes = to * IOMMU translation entries. * + * Returns 0 on success, or a negative errno otherwise. In particular, + * -EINVAL indicates that at least one of the attributes of the notifier + * is not supported (flag/range) by the IOMMU memory region. + * * @mr: the memory region to observe * @n: the IOMMUNotifier to be added; the notify callback receives a * pointer to an #IOMMUTLBEntry as the opaque value; the pointer * ceases to be valid on exit from the notifier. */ -void memory_region_register_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n); +int memory_region_register_iommu_notifier(MemoryRegion *mr, + IOMMUNotifier *n); =20 /** * memory_region_iommu_replay: replay existing IOMMU translations to diff --git a/memory.c b/memory.c index b9dd6b94ca..2545d22ca9 100644 --- a/memory.c +++ b/memory.c @@ -1837,33 +1837,37 @@ bool memory_region_is_logging(MemoryRegion *mr, uin= t8_t client) return memory_region_get_dirty_log_mask(mr) & (1 << client); } =20 -static void memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iom= mu_mr) +static int memory_region_update_iommu_notify_flags(IOMMUMemoryRegion *iomm= u_mr) { IOMMUNotifierFlag flags =3D IOMMU_NOTIFIER_NONE; IOMMUNotifier *iommu_notifier; IOMMUMemoryRegionClass *imrc =3D IOMMU_MEMORY_REGION_GET_CLASS(iommu_m= r); + int ret =3D 0; =20 IOMMU_NOTIFIER_FOREACH(iommu_notifier, iommu_mr) { flags |=3D iommu_notifier->notifier_flags; } =20 if (flags !=3D iommu_mr->iommu_notify_flags && imrc->notify_flag_chang= ed) { - imrc->notify_flag_changed(iommu_mr, - iommu_mr->iommu_notify_flags, - flags); + ret =3D imrc->notify_flag_changed(iommu_mr, + iommu_mr->iommu_notify_flags, + flags); } =20 - iommu_mr->iommu_notify_flags =3D flags; + if (!ret) { + iommu_mr->iommu_notify_flags =3D flags; + } + return ret; } =20 -void memory_region_register_iommu_notifier(MemoryRegion *mr, - IOMMUNotifier *n) +int memory_region_register_iommu_notifier(MemoryRegion *mr, + IOMMUNotifier *n) { IOMMUMemoryRegion *iommu_mr; + int ret; =20 if (mr->alias) { - memory_region_register_iommu_notifier(mr->alias, n); - return; + return memory_region_register_iommu_notifier(mr->alias, n); } =20 /* We need to register for at least one bitfield */ @@ -1874,7 +1878,11 @@ void memory_region_register_iommu_notifier(MemoryReg= ion *mr, n->iommu_idx < memory_region_iommu_num_indexes(iommu_mr)); =20 QLIST_INSERT_HEAD(&iommu_mr->iommu_notify, n, node); - memory_region_update_iommu_notify_flags(iommu_mr); + ret =3D memory_region_update_iommu_notify_flags(iommu_mr); + if (ret) { + QLIST_REMOVE(n, node); + } + return ret; } =20 uint64_t memory_region_iommu_get_min_page_size(IOMMUMemoryRegion *iommu_mr) --=20 2.20.1 From nobody Tue Apr 30 21:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568895853; cv=none; d=zoho.com; s=zohoarc; b=Lm6nRi6Vzmcvnt9FfLc05xUC7di3KY8VrHkgrftrM3cLUZTaqaXsxRY9BibPYRZNLPwgYtni9I+NUJ8ZG2E2VX3wu2/6seRNkIRKWSDoqkjXpXlD/7uKipe6RWmGSJZRtvv4zNI6yma9jpYIfAXgS98q9jeMK/Hdx6XQmiURuWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568895853; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=17+6090PQIPDr6ZvOhE7jTG5x63df14ldFloFN3eCvQ=; b=RiVs1Pk47Q0Py27DljeTY0Odz9u7+W8oW6hoEvt5x8NxWFh7kpzTrVEBOJnG0AUFg9tRmrgbhaF4bo65hh40z10lPKRXF9fctoI57kBuTu/eOB6arMxhiShtel4zgdteCYKzdb8eEUnsE5T7Je7pcGrXVjn7Bq2unXbcnhlYepY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156889585304359.45245005485981; Thu, 19 Sep 2019 05:24:13 -0700 (PDT) Received: from localhost ([::1]:43426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvTn-0001hQ-F2 for importer@patchew.org; Thu, 19 Sep 2019 08:24:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37674) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvOw-0005Af-5c for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAvOv-0003vQ-2r for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAvOs-0003s8-JU; Thu, 19 Sep 2019 08:19:06 -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 BF48581DF7; Thu, 19 Sep 2019 12:19:05 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 953C560BF1; Thu, 19 Sep 2019 12:19:03 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, alex.williamson@redhat.com, peterx@redhat.com Date: Thu, 19 Sep 2019 14:18:42 +0200 Message-Id: <20190919121845.29520-3-eric.auger@redhat.com> In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com> References: <20190919121845.29520-1-eric.auger@redhat.com> MIME-Version: 1.0 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.25]); Thu, 19 Sep 2019 12:19:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/5] vfio/common: Handle memory_region_register_iommu_notifier() failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now memory_region_register_iommu_notifier() is allowed to fail, let's handle the returned value in vfio_listener_region_add(). This will allow to remove the error handling (exit) in the IOMMUs that implement a notify_flag_changed() that sometimes cannot accept the MAP flag. Signed-off-by: Eric Auger --- hw/vfio/common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 3e03c495d8..d57d72cfb9 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -630,9 +630,13 @@ static void vfio_listener_region_add(MemoryListener *l= istener, section->offset_within_region, int128_get64(llend), iommu_idx); - QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); =20 - memory_region_register_iommu_notifier(section->mr, &giommu->n); + ret =3D memory_region_register_iommu_notifier(section->mr, &giommu= ->n); + if (ret) { + g_free(giommu); + goto fail; + } + QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next); memory_region_iommu_replay(giommu->iommu, &giommu->n); =20 return; --=20 2.20.1 From nobody Tue Apr 30 21:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568895873; cv=none; d=zoho.com; s=zohoarc; b=lHruXa3yyTNogjrE1CoWtTCHkX663V1o0YiOafdko3PKweZ1v7GSMaMqENT4GxrDo90BZ0//NSoI3oZusjacfLVycqZAIUZm8/B/AUDBdBh0KdjopkatFAgzTFHqfx3VedWTpMPsnBGAaD4FK4H8Ep/Mskcm2EWhabRZ23R9+Uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568895873; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vcc28BwxLNfNT2It+VAFt4c/0L40zv4cz8x35B/F/gc=; b=aD9UjjwoTgfQtkQii8AKgvyDg4mgoz/Fvj2C0ROpMR6D9v12AcgcNlWsXbIFOcNlt8V6IOLpRXGZlZIuPk/f99NUBNgq8D+JmQRymBEcHhRpbOKd0exPtceq7/0rnaCd8P7STDYNwtPIl5yGdfCFj37GQvXedRea5njkn/N5lRQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568895873486409.76345220796145; Thu, 19 Sep 2019 05:24:33 -0700 (PDT) Received: from localhost ([::1]:43432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvU8-0002I1-0W for importer@patchew.org; Thu, 19 Sep 2019 08:24:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37705) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvP1-0005IN-3X for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAvOz-00040d-Vi for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64579) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAvOx-0003xf-LX; Thu, 19 Sep 2019 08:19:11 -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 E52AE3D962; Thu, 19 Sep 2019 12:19:10 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 239A660BF1; Thu, 19 Sep 2019 12:19:05 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, alex.williamson@redhat.com, peterx@redhat.com Date: Thu, 19 Sep 2019 14:18:43 +0200 Message-Id: <20190919121845.29520-4-eric.auger@redhat.com> In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com> References: <20190919121845.29520-1-eric.auger@redhat.com> MIME-Version: 1.0 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.30]); Thu, 19 Sep 2019 12:19:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/5] exec: assert on memory_region_register_iommu_notifier() failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" memory_region_register_iommu_notifier now returns an error in case of failure. Assert in such a case. Signed-off-by: Eric Auger --- v1 -> v2: - add assert(!ret) --- exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 8b998974f8..5be8db6253 100644 --- a/exec.c +++ b/exec.c @@ -663,7 +663,7 @@ static void tcg_register_iommu_notifier(CPUState *cpu, */ MemoryRegion *mr =3D MEMORY_REGION(iommu_mr); TCGIOMMUNotifier *notifier; - int i; + int i, ret; =20 for (i =3D 0; i < cpu->iommu_notifiers->len; i++) { notifier =3D g_array_index(cpu->iommu_notifiers, TCGIOMMUNotifier = *, i); @@ -692,7 +692,9 @@ static void tcg_register_iommu_notifier(CPUState *cpu, 0, HWADDR_MAX, iommu_idx); - memory_region_register_iommu_notifier(notifier->mr, ¬ifier->n); + ret =3D memory_region_register_iommu_notifier(notifier->mr, + ¬ifier->n); + assert(!ret); } =20 if (!notifier->active) { --=20 2.20.1 From nobody Tue Apr 30 21:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568895773; cv=none; d=zoho.com; s=zohoarc; b=jGeexLKi/3t7P+egAA+vO3Oef6qbKcNSsVEZdfRuyGXn2V2F+F5WOxJ9Z66iL2ZSG+TPxSML6p/U6UVtLfKY3kl65ocDzxqG1ClijtGKqmCuZ9BwXvleF6HZ/Su0IRUje1J5Fqcrn/hV9NjPkmYIC0xkLGwq2m09aegOOA0sTmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568895773; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1FmU6jkkeCfOKR4wYokieSQnAYYfOJ/Q+B4jLLcuoUw=; b=mUdXVTT7juMT60wlpxBUGMZ8BBlBiPyREJLlr8wlsI5q1X3hNgEuY26aqrrparW8ilaXcGIgqItMDFy1w0DG5KIJnZ/wsS+EGq77iI1mY2BrzaEsl/ORmHfPjhXqsLjiVWkvbw6yt/7yGRW1ea2OH2Qfl7FqALcr28e/UzYNAG8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568895773228336.33515723951166; Thu, 19 Sep 2019 05:22:53 -0700 (PDT) Received: from localhost ([::1]:43412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvSV-0000Ti-Hu for importer@patchew.org; Thu, 19 Sep 2019 08:22:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37782) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvPO-0005Q2-OH for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAvPM-0004Vh-Oz for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40044) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAvP8-0004AA-75; Thu, 19 Sep 2019 08:19:22 -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 84371A3D3A8; Thu, 19 Sep 2019 12:19:21 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4785E60BF1; Thu, 19 Sep 2019 12:19:11 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, alex.williamson@redhat.com, peterx@redhat.com Date: Thu, 19 Sep 2019 14:18:44 +0200 Message-Id: <20190919121845.29520-5-eric.auger@redhat.com> In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com> References: <20190919121845.29520-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Thu, 19 Sep 2019 12:19:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/5] vhost: assert on memory_region_register_iommu_notifier() failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" memory_region_register_iommu_notifier now returns an error in case of failure. Assert in such a case. Signed-off-by: Eric Auger --- v1 -> v2: - assert(!ret) --- hw/virtio/vhost.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 34accdf615..975cb4c28c 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -672,7 +672,7 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, iommu_listener); struct vhost_iommu *iommu; Int128 end; - int iommu_idx; + int iommu_idx, ret; IOMMUMemoryRegion *iommu_mr; =20 if (!memory_region_is_iommu(section->mr)) { @@ -696,7 +696,8 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, iommu->iommu_offset =3D section->offset_within_address_space - section->offset_within_region; iommu->hdev =3D dev; - memory_region_register_iommu_notifier(section->mr, &iommu->n); + ret =3D memory_region_register_iommu_notifier(section->mr, &iommu->n); + assert(!ret); QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next); /* TODO: can replay help performance here? */ } --=20 2.20.1 From nobody Tue Apr 30 21:31:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568896004; cv=none; d=zoho.com; s=zohoarc; b=ai58Z1savek/EXVusTbYV8UT86w2VBKBDkLyJ3q046NtetrRTlG4QWb3eV1aMlgnV+royridNvgVJesKMSFDq5AhkyaLZy5uUL4DNU3IjgQj5Ps2IpURjhEahUndYBqQS/qVBXRqa3DArC4unbdJCJCNS90Fv8K3jl5KhZNQDXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568896004; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nCbChdrLyaLbkeV86imhEZZQMfLmIqNy8p3AMtqNx3w=; b=dR3Lt2LKm5MtNYIqcMENJP7uVQ6bfEE+be4i/LNA0OMBzAnl6fKtK3VktMjhi7cHltkhN7dPYGAzarX8NUwqEDA2SKndEr8CYcMipFvOcjsy8hoEv1GEyzenkeres4U2qe6/bQJm2MLavtpnvXBtoBN7YRpb9xgflZTNzklxNXc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568896004922111.89193526125814; Thu, 19 Sep 2019 05:26:44 -0700 (PDT) Received: from localhost ([::1]:43458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvWF-0004oo-8E for importer@patchew.org; Thu, 19 Sep 2019 08:26:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37784) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAvPO-0005Q4-O8 for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAvPM-0004Vf-Oz for qemu-devel@nongnu.org; Thu, 19 Sep 2019 08:19:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAvPA-0004Fn-QW; Thu, 19 Sep 2019 08:19:24 -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 0EA937FDF0; Thu, 19 Sep 2019 12:19:24 +0000 (UTC) Received: from laptop.redhat.com (ovpn-117-220.ams2.redhat.com [10.36.117.220]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBB4060BF1; Thu, 19 Sep 2019 12:19:21 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, alex.williamson@redhat.com, peterx@redhat.com Date: Thu, 19 Sep 2019 14:18:45 +0200 Message-Id: <20190919121845.29520-6-eric.auger@redhat.com> In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com> References: <20190919121845.29520-1-eric.auger@redhat.com> MIME-Version: 1.0 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.27]); Thu, 19 Sep 2019 12:19:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/5] amd_iommu: Let amdvi_iommu_notify_flag_changed() fail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In case a MAP notifier is attempted to be registered, let's simply return an error. This latter now is handled in the VFIO code. Signed-off-by: Eric Auger --- hw/i386/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 137ba367db..09dee48fac 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1476,7 +1476,7 @@ static int amdvi_iommu_notify_flag_changed(IOMMUMemor= yRegion *iommu, error_report("device %02x.%02x.%x requires iommu notifier which is= not " "currently supported", as->bus_num, PCI_SLOT(as->devf= n), PCI_FUNC(as->devfn)); - exit(1); + return -EINVAL; } return 0; } --=20 2.20.1