From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279066; cv=none; d=zohomail.com; s=zohoarc; b=RDgvgStT+SdFFxV+hEW4pG4Pfg4CVCanAuYZqeG/5UDRgwcFd/VQyTVwieVGTz+b2aqDq0hEdDzbpF2iUynmoyfwTRG0sS6Vn4y5isBegfTkcPtQQAvkgjCF+JGiY/GLDBQfTR6QINW0s8qa7FWMZn1urTKKSoOyv4A7+wAehus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279066; h=Content-Type: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; bh=qnVGWjSMIp3mECXi5SalJudL78dZzeCiGZ1sn97SGrQ=; b=U0Q84PtcDAKNX+V8Q4S70WMfDnXKtW9H7/kN8khgKsTJj4acCqM0tyhdB0sJgoEpYltxJTJgGUmFfaQdXWCbPV5ZwjhxszoOuUWePqYiQpqoZoJQEt6pJDePf/xmfxGkPcZHSCUW/8qc+EOyDBIL1h9WzVhIIsebSfdml3la6Lc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166127906696069.61285074167142; Tue, 23 Aug 2022 11:24:26 -0700 (PDT) Received: from localhost ([::1]:33724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYZc-000832-Gy for importer@patchew.org; Tue, 23 Aug 2022 14:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVt-0005HU-Tl for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVe-00032W-Fg for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:20 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-46-l4-ZCZXzMiWT8XV9YY8RLA-1; Tue, 23 Aug 2022 14:20:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68FEE3803903; Tue, 23 Aug 2022 18:20:14 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99DD040D2830; Tue, 23 Aug 2022 18:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qnVGWjSMIp3mECXi5SalJudL78dZzeCiGZ1sn97SGrQ=; b=i0OPouDGytmHg0k6iQVF9nrT1IOjQR6RylxPKOBS7P9kAc1LDTFKwRfDtdSgBEvIztxy/r i+seDVkCozdStogCi3KaKU3hWPc8DVKhYBoV0u0uu93hdDTnbcOLV5gY1cBWY0U5v7fjR3 kCgNKbGAWmTDWtNpclAjUqwIvGamzAY= X-MC-Unique: l4-ZCZXzMiWT8XV9YY8RLA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 1/7] vdpa: Skip the maps not in the iova tree Date: Tue, 23 Aug 2022 20:20:02 +0200 Message-Id: <20220823182008.97141-2-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279069894100001 Next patch will skip the registering of dma maps that the vdpa device rejects in the iova tree. We need to consider that here or we cause a SIGSEGV accessing result. Reported-by: Lei Yang Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3ff9ce3501..983d3697b0 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -289,6 +289,10 @@ static void vhost_vdpa_listener_region_del(MemoryListe= ner *listener, }; =20 result =3D vhost_iova_tree_find_iova(v->iova_tree, &mem_region); + if (!result) { + /* The memory listener map wasn't mapped */ + return; + } iova =3D result->iova; vhost_iova_tree_remove(v->iova_tree, result); } --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279221; cv=none; d=zohomail.com; s=zohoarc; b=Hh92bDo0rjUzHT52BSnquMTU3tUt2YdBx2lSAwCNA+wGXh6krdBGb3JNCGZiGHI9xkqS60NV58K51/XexojpFgJrxMBI6Praab6G3JehcLeMZM8zaPYJnxeX8FlUpzmMqYdZnS5+KyS/0fFNF2S7GapD9Ca7kzanqaJHmCZkVjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279221; h=Content-Type: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; bh=PKFdaN2tkUi5mrhylR6MDQmGbp3hAyCJTgJURDlH6rQ=; b=S+03Stn0mCQbbgRjM6hgfhSu0iAa/KJdJVLbnFQLTjqEw95yiWvh1+Yxy/s3qF86cD4uiMLmj9My5zoNLjR7pBc/T5YyxP2Tv1pMVNi7Gj9kC09nkfOwN7Tm1CTL92z+Q8R14UuUmTYo1n2i3fQMlwFK/EwXnQUx0K/+Ka13YEc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279221876819.1366472080817; Tue, 23 Aug 2022 11:27:01 -0700 (PDT) Received: from localhost ([::1]:39686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYc8-00047L-TS for importer@patchew.org; Tue, 23 Aug 2022 14:27:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVu-0005HW-DX for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVf-00032a-8l for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:21 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-402-XDA0a584Ml-8CWUBQngS5g-1; Tue, 23 Aug 2022 14:20:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CF9B85A58B; Tue, 23 Aug 2022 18:20:16 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA0904010D2A; Tue, 23 Aug 2022 18:20:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PKFdaN2tkUi5mrhylR6MDQmGbp3hAyCJTgJURDlH6rQ=; b=VvUY3mVoKMlL3o2PWIIDCzbjYhdODGV0E8MwbQncStFWupmxPQOUFVsEH0B2QtglODFxVb BOO/C2vi9bJJH22U0In4uNYGSkEk8pz9h/EyuhfaxhpOpzwIAUp8c1wrKPYa+AAosuOzoi zuywjjANyx0vSml3I7qw6pJJph5ZeK8= X-MC-Unique: XDA0a584Ml-8CWUBQngS5g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 2/7] vdpa: do not save failed dma maps in SVQ iova tree Date: Tue, 23 Aug 2022 20:20:03 +0200 Message-Id: <20220823182008.97141-3-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279223544100001 If a map fails for whatever reason, it must not be saved in the tree. Otherwise, qemu will try to unmap it in cleanup, leaving to more errors. Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Reported-by: Lei Yang Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 983d3697b0..7e28d2f674 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -176,6 +176,7 @@ static void vhost_vdpa_listener_commit(MemoryListener *= listener) static void vhost_vdpa_listener_region_add(MemoryListener *listener, MemoryRegionSection *section) { + DMAMap mem_region =3D {}; struct vhost_vdpa *v =3D container_of(listener, struct vhost_vdpa, lis= tener); hwaddr iova; Int128 llend, llsize; @@ -212,13 +213,13 @@ static void vhost_vdpa_listener_region_add(MemoryList= ener *listener, =20 llsize =3D int128_sub(llend, int128_make64(iova)); if (v->shadow_vqs_enabled) { - DMAMap mem_region =3D { - .translated_addr =3D (hwaddr)(uintptr_t)vaddr, - .size =3D int128_get64(llsize) - 1, - .perm =3D IOMMU_ACCESS_FLAG(true, section->readonly), - }; + int r; =20 - int r =3D vhost_iova_tree_map_alloc(v->iova_tree, &mem_region); + mem_region.translated_addr =3D (hwaddr)(uintptr_t)vaddr, + mem_region.size =3D int128_get64(llsize) - 1, + mem_region.perm =3D IOMMU_ACCESS_FLAG(true, section->readonly), + + r =3D vhost_iova_tree_map_alloc(v->iova_tree, &mem_region); if (unlikely(r !=3D IOVA_OK)) { error_report("Can't allocate a mapping (%d)", r); goto fail; @@ -232,11 +233,16 @@ static void vhost_vdpa_listener_region_add(MemoryList= ener *listener, vaddr, section->readonly); if (ret) { error_report("vhost vdpa map fail!"); - goto fail; + goto fail_map; } =20 return; =20 +fail_map: + if (v->shadow_vqs_enabled) { + vhost_iova_tree_remove(v->iova_tree, &mem_region); + } + fail: /* * On the initfn path, store the first error in the container so we --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279356; cv=none; d=zohomail.com; s=zohoarc; b=OvwFzfjwrGjzGrsAhR45/2VTQGwFtgDUKllPA7AAddEh2j7xQDHm+OBKFtmghvZj8aENMkSvYp4pL0vfVGb37oFN7K53ef5Jm1uFB9xhkfxTR9BPx/zPtIud6FeBgSjKxiHPeuCJeidc+klczgF9dvIBYZsnjaLGJqiIlBEjwhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279356; h=Content-Type: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; bh=eVAI0XQR71Qx+C2I4r1Zdev0VxbN2Lha6UU6sZcicsk=; b=dT0ml1BSSfQupgThskKmvuzPGYDz0zdVM6Z49DPMcstQcrQocpGchqmEyw3yj6cwJl9kAq+xaD+wFq6Cxo9/H3RAVbL5Wkzh/qvFDHq8CWx0uPtKHSMOmo/VVcT3ZET/C1dJxsEd4rXFUdhyK0WNiIUNKTBIotNcDBUug0InatE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279356747820.8085812405047; Tue, 23 Aug 2022 11:29:16 -0700 (PDT) Received: from localhost ([::1]:34874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYeJ-0006R7-Pg for importer@patchew.org; Tue, 23 Aug 2022 14:29:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVv-0005Hr-FX for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVn-00032s-0j for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-390-wgJcY9HzOPKo5LZBjqaP8Q-1; Tue, 23 Aug 2022 14:20:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D6C0811E83; Tue, 23 Aug 2022 18:20:18 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE5CB40D2830; Tue, 23 Aug 2022 18:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eVAI0XQR71Qx+C2I4r1Zdev0VxbN2Lha6UU6sZcicsk=; b=NFMWexMeUEZR1eeDzc5D6QqyInIHwls+uAzq8IwXAdhrA+CTs+Ky3Vj8Jjcwfkl8Ad02qs kc/76RCPezVZHjIvKcLDJ6813BWtIEYH22z8DHerXd2TNw0ZLy+4p+n50XZdKy4Jpx4ZVJ Fk8GjE3JkjoG6nVNkW7R8MHm3rNbJcc= X-MC-Unique: wgJcY9HzOPKo5LZBjqaP8Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 3/7] util: accept iova_tree_remove_parameter by value Date: Tue, 23 Aug 2022 20:20:04 +0200 Message-Id: <20220823182008.97141-4-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279358813100001 It's convenient to call iova_tree_remove from a map returned from iova_tree_find or iova_tree_find_iova. With the current code this is not possible, since we will free it, and then we will try to search for it again. Fix it making accepting the map by value, forcing a copy of the argument. Not applying a fixes tag, since there is no use like that at the moment. Signed-off-by: Eugenio P=C3=A9rez --- v2: Accept map parameter by value instead of make a copy --- hw/virtio/vhost-iova-tree.h | 2 +- include/qemu/iova-tree.h | 2 +- hw/i386/intel_iommu.c | 6 +++--- hw/virtio/vhost-iova-tree.c | 2 +- hw/virtio/vhost-vdpa.c | 6 +++--- net/vhost-vdpa.c | 4 ++-- util/iova-tree.c | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/virtio/vhost-iova-tree.h b/hw/virtio/vhost-iova-tree.h index 6a4f24e0f9..4adfd79ff0 100644 --- a/hw/virtio/vhost-iova-tree.h +++ b/hw/virtio/vhost-iova-tree.h @@ -22,6 +22,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostIOVATree, vhost_iova_t= ree_delete); const DMAMap *vhost_iova_tree_find_iova(const VhostIOVATree *iova_tree, const DMAMap *map); int vhost_iova_tree_map_alloc(VhostIOVATree *iova_tree, DMAMap *map); -void vhost_iova_tree_remove(VhostIOVATree *iova_tree, const DMAMap *map); +void vhost_iova_tree_remove(VhostIOVATree *iova_tree, DMAMap map); =20 #endif diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h index 16bbfdf5f8..8528e5c98f 100644 --- a/include/qemu/iova-tree.h +++ b/include/qemu/iova-tree.h @@ -73,7 +73,7 @@ int iova_tree_insert(IOVATree *tree, const DMAMap *map); * all the mappings that are included in the provided range will be * removed from the tree. Here map->translated_addr is meaningless. */ -void iova_tree_remove(IOVATree *tree, const DMAMap *map); +void iova_tree_remove(IOVATree *tree, DMAMap map); =20 /** * iova_tree_find: diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2162394e08..05d53a1aa9 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1187,7 +1187,7 @@ static int vtd_page_walk_one(IOMMUTLBEvent *event, vt= d_page_walk_info *info) return ret; } /* Drop any existing mapping */ - iova_tree_remove(as->iova_tree, &target); + iova_tree_remove(as->iova_tree, target); /* Recover the correct type */ event->type =3D IOMMU_NOTIFIER_MAP; entry->perm =3D cache_perm; @@ -1200,7 +1200,7 @@ static int vtd_page_walk_one(IOMMUTLBEvent *event, vt= d_page_walk_info *info) trace_vtd_page_walk_one_skip_unmap(entry->iova, entry->addr_ma= sk); return 0; } - iova_tree_remove(as->iova_tree, &target); + iova_tree_remove(as->iova_tree, target); } =20 trace_vtd_page_walk_one(info->domain_id, entry->iova, @@ -3563,7 +3563,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *= as, IOMMUNotifier *n) =20 map.iova =3D n->start; map.size =3D size; - iova_tree_remove(as->iova_tree, &map); + iova_tree_remove(as->iova_tree, map); } =20 static void vtd_address_space_unmap_all(IntelIOMMUState *s) diff --git a/hw/virtio/vhost-iova-tree.c b/hw/virtio/vhost-iova-tree.c index 67bf6d57ab..3d03395a77 100644 --- a/hw/virtio/vhost-iova-tree.c +++ b/hw/virtio/vhost-iova-tree.c @@ -104,7 +104,7 @@ int vhost_iova_tree_map_alloc(VhostIOVATree *tree, DMAM= ap *map) * @iova_tree: The vhost iova tree * @map: The map to remove */ -void vhost_iova_tree_remove(VhostIOVATree *iova_tree, const DMAMap *map) +void vhost_iova_tree_remove(VhostIOVATree *iova_tree, DMAMap map) { iova_tree_remove(iova_tree->iova_taddr_map, map); } diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7e28d2f674..87e0ad393f 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -240,7 +240,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, =20 fail_map: if (v->shadow_vqs_enabled) { - vhost_iova_tree_remove(v->iova_tree, &mem_region); + vhost_iova_tree_remove(v->iova_tree, mem_region); } =20 fail: @@ -300,7 +300,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, return; } iova =3D result->iova; - vhost_iova_tree_remove(v->iova_tree, result); + vhost_iova_tree_remove(v->iova_tree, *result); } vhost_vdpa_iotlb_batch_begin_once(v); ret =3D vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize)); @@ -944,7 +944,7 @@ static bool vhost_vdpa_svq_map_ring(struct vhost_vdpa *= v, DMAMap *needle, needle->perm =3D=3D IOMMU_RO); if (unlikely(r !=3D 0)) { error_setg_errno(errp, -r, "Cannot map region to device"); - vhost_iova_tree_remove(v->iova_tree, needle); + vhost_iova_tree_remove(v->iova_tree, *needle); } =20 return r =3D=3D 0; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 303447a68e..a49e7e649d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -244,7 +244,7 @@ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa = *v, void *addr) error_report("Device cannot unmap: %s(%d)", g_strerror(r), r); } =20 - vhost_iova_tree_remove(tree, map); + vhost_iova_tree_remove(tree, *map); } =20 static size_t vhost_vdpa_net_cvq_cmd_len(void) @@ -297,7 +297,7 @@ static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, return true; =20 dma_map_err: - vhost_iova_tree_remove(v->iova_tree, &map); + vhost_iova_tree_remove(v->iova_tree, map); return false; } =20 diff --git a/util/iova-tree.c b/util/iova-tree.c index fee530a579..536789797e 100644 --- a/util/iova-tree.c +++ b/util/iova-tree.c @@ -164,11 +164,11 @@ void iova_tree_foreach(IOVATree *tree, iova_tree_iter= ator iterator) g_tree_foreach(tree->tree, iova_tree_traverse, iterator); } =20 -void iova_tree_remove(IOVATree *tree, const DMAMap *map) +void iova_tree_remove(IOVATree *tree, DMAMap map) { const DMAMap *overlap; =20 - while ((overlap =3D iova_tree_find(tree, map))) { + while ((overlap =3D iova_tree_find(tree, &map))) { g_tree_remove(tree->tree, overlap); } } --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279070; cv=none; d=zohomail.com; s=zohoarc; b=QrCeRs+KaUk0lugOjfQRYKWSFRDorkSoTT3NCVoBS+rOhZzd0Kr1XwCFZxqfX7ODt62gQ0LGK2YUS3HiAFNkCtEaI5/y8sYxA/7qoeT/IFn2OlDy0gfc1V8VjrMKg63xms+SIzW+/7f5aNcVVPegIjhJ2QfFxsquGoUrg4JkTNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279070; h=Content-Type: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; bh=CKtSgt7LhyQcdf+VJZwA77ZO1cebZdKFkWgMUA7YOXY=; b=e1MCoZKCp+JbTptW4IBGEC2oIp6zG3OPtZAD0sAmEkErTfKsB3h0GoJ11CwZDSNvror+ZQMRon/LQ9CULQFtx5Ui7SJjQx/G8QMxEbKNE1Xh+RfbrLvrMV/eJABET9J/z2McBqUvoX7s3hZLy7FHdw6DG1ej+YVw9jVS1iWmyIk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279070343261.1002786858901; Tue, 23 Aug 2022 11:24:30 -0700 (PDT) Received: from localhost ([::1]:33730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYZg-00088T-Vu for importer@patchew.org; Tue, 23 Aug 2022 14:24:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYW3-0005Jr-Ji for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVs-000332-DF for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:39 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225--pBfUA6VNfC7Bk7eAgc9PA-1; Tue, 23 Aug 2022 14:20:21 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB666811E83; Tue, 23 Aug 2022 18:20:20 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id E82F840D2830; Tue, 23 Aug 2022 18:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CKtSgt7LhyQcdf+VJZwA77ZO1cebZdKFkWgMUA7YOXY=; b=dB+yhCf+kvj5/La/nRiuXmJDEm76mrwPh9O86VKabgynR2xZt/2saGcWqFws8KSKTC4feZ 4FzlcWbb+QTHRUiq4ndh8tZL9VpWYJSlFtLY8jUEoZbUkfj77iYnlPYoqRBD+smLpsKOse i+95784a0SYcYVcdeMoqkDRQUvHMRI8= X-MC-Unique: -pBfUA6VNfC7Bk7eAgc9PA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 4/7] vdpa: Remove SVQ vring from iova_tree at shutdown Date: Tue, 23 Aug 2022 20:20:05 +0200 Message-Id: <20220823182008.97141-5-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279070759100004 Although the device will be reset before usage, the right thing to do is to clean it. Reported-by: Lei Yang Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Signed-off-by: Eugenio P=C3=A9rez --- v2: * Call vhost_iova_tree_remove with the map as value. * report_error on vhost_vdpa_dma_unmap fail --- hw/virtio/vhost-vdpa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 87e0ad393f..e16e0e222e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -898,6 +898,12 @@ static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdp= a *v, =20 size =3D ROUND_UP(result->size, qemu_real_host_page_size()); r =3D vhost_vdpa_dma_unmap(v, result->iova, size); + if (unlikely(r < 0)) { + error_report("Unable to unmap SVQ vring: %s (%d)", g_strerror(-r),= -r); + return false; + } + + vhost_iova_tree_remove(v->iova_tree, *result); return r =3D=3D 0; } =20 --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279069; cv=none; d=zohomail.com; s=zohoarc; b=JujYx+iEz9dXY1vMnmm2tHmZtS9zp/bC/ZWNJkd1/t53jlkQ1br1Kji+f4QPrDgfYDjytRAhPMkJjBbJQUSACWWdBSKFRHs1yjElP7hjwWYwrMsxetYAXBsa/0nR6Iz3FpSpx+5UY1qjoy6bd/BA7o5a2gPZXHnjiAYveoYQyvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279069; h=Content-Type: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; bh=k/ysaHEg4wLVJ9cVvql+QZB8JlJSjwXw/DATO27gCZY=; b=g8n6Sf63OzAY/0TLtzd8yZHr/p7hP3ahjpG4sJPbnXPCvzgRfD8dTRWP2guuN0dndV7f/ho6ynXc9mtXFDPrQjIsu69PI27BYZjXX8z0U62dCfUzS6plGgmdN+COhRuUPiFxrQzPq4kQWpBCbKeUHZw400ohn4hKKHa58dHnu5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279069933809.7148785835086; Tue, 23 Aug 2022 11:24:29 -0700 (PDT) Received: from localhost ([::1]:33726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYZg-00083e-Lw for importer@patchew.org; Tue, 23 Aug 2022 14:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYW3-0005Js-KZ for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVs-00033B-Cn for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-8Cso2PujNfy2-JABWIrP2g-1; Tue, 23 Aug 2022 14:20:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF75B80A0AE; Tue, 23 Aug 2022 18:20:22 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08C0C40D2830; Tue, 23 Aug 2022 18:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k/ysaHEg4wLVJ9cVvql+QZB8JlJSjwXw/DATO27gCZY=; b=PzDGs6k2Bi+cdeiT6YPO60mvPOOk8XXExUc91YAIEEq7141WXb5at5tqcamaEmgcy17miJ 0i8r9qVJuIgNU25k2+Dwvs+eI1XnlzVTBob+CaMWiZtTCyznCLVsEfQQyJJC8HJHOWnBMH kWHJOXIsDu59PdJ7rlo2Fdwhx1TTvZc= X-MC-Unique: 8Cso2PujNfy2-JABWIrP2g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 5/7] vdpa: Make SVQ vring unmapping return void Date: Tue, 23 Aug 2022 20:20:06 +0200 Message-Id: <20220823182008.97141-6-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279070662100003 Nothing actually reads the return value, but an error in cleaning some entries could cause device stop to abort, making a restart impossible. Better ignore explicitely the return value. Reported-by: Lei Yang Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e16e0e222e..e208dd000e 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -884,7 +884,7 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *dev, /** * Unmap a SVQ area in the device */ -static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, +static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, const DMAMap *needle) { const DMAMap *result =3D vhost_iova_tree_find_iova(v->iova_tree, needl= e); @@ -893,38 +893,33 @@ static bool vhost_vdpa_svq_unmap_ring(struct vhost_vd= pa *v, =20 if (unlikely(!result)) { error_report("Unable to find SVQ address to unmap"); - return false; + return; } =20 size =3D ROUND_UP(result->size, qemu_real_host_page_size()); r =3D vhost_vdpa_dma_unmap(v, result->iova, size); if (unlikely(r < 0)) { error_report("Unable to unmap SVQ vring: %s (%d)", g_strerror(-r),= -r); - return false; + return; } =20 vhost_iova_tree_remove(v->iova_tree, *result); - return r =3D=3D 0; } =20 -static bool vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, +static void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, const VhostShadowVirtqueue *svq) { DMAMap needle =3D {}; struct vhost_vdpa *v =3D dev->opaque; struct vhost_vring_addr svq_addr; - bool ok; =20 vhost_svq_get_vring_addr(svq, &svq_addr); =20 needle.translated_addr =3D svq_addr.desc_user_addr; - ok =3D vhost_vdpa_svq_unmap_ring(v, &needle); - if (unlikely(!ok)) { - return false; - } + vhost_vdpa_svq_unmap_ring(v, &needle); =20 needle.translated_addr =3D svq_addr.used_user_addr; - return vhost_vdpa_svq_unmap_ring(v, &needle); + vhost_vdpa_svq_unmap_ring(v, &needle); } =20 /** @@ -1095,26 +1090,22 @@ err: return false; } =20 -static bool vhost_vdpa_svqs_stop(struct vhost_dev *dev) +static void vhost_vdpa_svqs_stop(struct vhost_dev *dev) { struct vhost_vdpa *v =3D dev->opaque; =20 if (!v->shadow_vqs) { - return true; + return; } =20 for (unsigned i =3D 0; i < v->shadow_vqs->len; ++i) { VhostShadowVirtqueue *svq =3D g_ptr_array_index(v->shadow_vqs, i); - bool ok =3D vhost_vdpa_svq_unmap_rings(dev, svq); - if (unlikely(!ok)) { - return false; - } + vhost_vdpa_svq_unmap_rings(dev, svq); } =20 if (v->migration_blocker) { migrate_del_blocker(v->migration_blocker); } - return true; } =20 static int vhost_vdpa_dev_start(struct vhost_dev *dev, bool started) @@ -1131,10 +1122,7 @@ static int vhost_vdpa_dev_start(struct vhost_dev *de= v, bool started) } vhost_vdpa_set_vring_ready(dev); } else { - ok =3D vhost_vdpa_svqs_stop(dev); - if (unlikely(!ok)) { - return -1; - } + vhost_vdpa_svqs_stop(dev); vhost_vdpa_host_notifiers_uninit(dev, dev->nvqs); } =20 --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279669; cv=none; d=zohomail.com; s=zohoarc; b=GmI7gJC151rjKTU6LOpPwhJtGXken+E5Dj/8F/VkB0yibYaup/L6jUrjCyZ/Cu4803xhStiEZPIMXFDYFqjHhMJ87Ge/pNI8X/RKt4aEPGcXx5509flqBKZ/6Q8JFgwi1NkLpV/uI2oeaTrA0Yd1u5Pg03XN/agoOLjSEtOY/EU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279669; h=Content-Type: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; bh=3LXszn1oKHYse3sdyaKlGcH7svqT1e7hqhc+UjpoJZs=; b=GaSo8dWXorXXjo2yot59xri017JOJRJixK1UUA/DjkMlbDeHphJE5Mwmp/h1Jc+PKOB3YOSGQ7kJuremU8pWSZKB7R0VKlz5Y5cD5Md/5HnAFH9Es3fsPC7Q0u6bln1xNLz1r+J3Ef/102g//6SiYwj5zOXW0cAf55A+Oe5OTLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279669075100.81111326284429; Tue, 23 Aug 2022 11:34:29 -0700 (PDT) Received: from localhost ([::1]:36224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYjK-0000Eq-CB for importer@patchew.org; Tue, 23 Aug 2022 14:34:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYW3-0005Jt-KJ for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57233) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVs-000337-CV for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:36 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-uSNUMetrMA-a7ghFVHwF7Q-1; Tue, 23 Aug 2022 14:20:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0B6B804191; Tue, 23 Aug 2022 18:20:24 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1BEDC40D2830; Tue, 23 Aug 2022 18:20:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278827; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3LXszn1oKHYse3sdyaKlGcH7svqT1e7hqhc+UjpoJZs=; b=NqgBZpVtMDurul+tiMbBBjBoIadCHiTzNfQcOFwaP7EVRG78mEhvH0q9jpC/N8BtJ0VDXO Aoh1rgyf3CqY2qbXqfozW8aymgbr815dgrV4uwozFy8cBLAV1Ic2PXYOlEqBIh2/L/7rfw G6NVA5cF5Tv7YBie/O598j5bHCoB+3w= X-MC-Unique: uSNUMetrMA-a7ghFVHwF7Q-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 6/7] vhost: Always store new kick fd on vhost_svq_set_svq_kick_fd Date: Tue, 23 Aug 2022 20:20:07 +0200 Message-Id: <20220823182008.97141-7-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279670788100001 We can unbind twice a file descriptor if we call twice vhost_svq_set_svq_kick_fd because of this. Since it comes from vhost and not from SVQ, that file descriptor could be a different thing that guest's vhost notifier. Likewise, it can happens the same if a guest start and stop the device multiple times. Reported-by: Lei Yang Fixes: dff4426fa6 ("vhost: Add Shadow VirtQueue kick forwarding capabilitie= s") Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-shadow-virtqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index e4956728dd..82a784d250 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -602,13 +602,13 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *= svq, int svq_kick_fd) event_notifier_set_handler(svq_kick, NULL); } =20 + event_notifier_init_fd(svq_kick, svq_kick_fd); /* * event_notifier_set_handler already checks for guest's notifications= if * they arrive at the new file descriptor in the switch, so there is no * need to explicitly check for them. */ if (poll_start) { - event_notifier_init_fd(svq_kick, svq_kick_fd); event_notifier_set(svq_kick); event_notifier_set_handler(svq_kick, vhost_handle_guest_kick_notif= ier); } @@ -655,7 +655,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIOD= evice *vdev, */ void vhost_svq_stop(VhostShadowVirtqueue *svq) { - event_notifier_set_handler(&svq->svq_kick, NULL); + vhost_svq_set_svq_kick_fd(svq, VHOST_FILE_UNBIND); g_autofree VirtQueueElement *next_avail_elem =3D NULL; =20 if (!svq->vq) { --=20 2.31.1 From nobody Sat May 11 18:48:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1661279224; cv=none; d=zohomail.com; s=zohoarc; b=TtHfVSC2NuA7E2Hf5uaKsePtuAyBkhQQVSM99WnaTQZprwsjXr9XY6bI5PSuBLsPZivhLV+85+hZ4IPajJpiOEuJPA3FXa6ATSGBAdqIrDn1w631GS3LJcHoazwqb4V5Uma+rncJosZqhzoqBi6HFB/KzGpPthop+qTfII2poCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661279224; h=Content-Type: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; bh=gGbjYz2nsNd1UgiSarbiowrT7nNfvzmFvntMEpAN2KI=; b=JZ/zqVnj3iQL9HLN0glzvHrNxZbAe8tXLcs48evWNfScLTU8fN2M5a9u8dbo0dxxXAM/I58Oq9B9a829/uEKZPgrxqqCyKR9WADt3sJIsy9/sf+xyEvEIdx1u5TmK1tNiYNfPLGLyItPMVUyeu/mcGrhoJ+srmE1JkxthUCBRYk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661279224983203.9638915868661; Tue, 23 Aug 2022 11:27:04 -0700 (PDT) Received: from localhost ([::1]:51580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQYc9-00045w-1j for importer@patchew.org; Tue, 23 Aug 2022 14:27:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYW3-0005Ju-VV for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQYVv-00034H-7P for qemu-devel@nongnu.org; Tue, 23 Aug 2022 14:20:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-o4wTzj4jPFW5XqyRu0sYBQ-1; Tue, 23 Aug 2022 14:20:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 02345101AA45; Tue, 23 Aug 2022 18:20:27 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.195.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EA6040D2830; Tue, 23 Aug 2022 18:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661278831; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gGbjYz2nsNd1UgiSarbiowrT7nNfvzmFvntMEpAN2KI=; b=AQSkcA8i+mtmws4kQVn/zfc+ZuEMDeyyHrtfIsIATNBQPAlfpz3ZwSui8Wzjb50TtOe4YS TzO96YkXDiECEOAUDPvap21GFOqckVseV9QMwWGQp3BHlavmwjcD3whN1KfTYbff3/fUOx XVWLG1/8+hv6iZK1f0GvDpfD4hA92cg= X-MC-Unique: o4wTzj4jPFW5XqyRu0sYBQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Jason Wang , Paolo Bonzini , "Michael S. Tsirkin" , Peter Xu , Cindy Lu , Laurent Vivier , Lei Yang , Eduardo Habkost , Marcel Apfelbaum Subject: [PATCH v2 7/7] vdpa: Use ring hwaddr at vhost_vdpa_svq_unmap_ring Date: Tue, 23 Aug 2022 20:20:08 +0200 Message-Id: <20220823182008.97141-8-eperezma@redhat.com> In-Reply-To: <20220823182008.97141-1-eperezma@redhat.com> References: <20220823182008.97141-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1661279225450100003 Reduce code duplication. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- hw/virtio/vhost-vdpa.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index e208dd000e..23ae5ef48b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -884,10 +884,12 @@ static int vhost_vdpa_svq_set_fds(struct vhost_dev *d= ev, /** * Unmap a SVQ area in the device */ -static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, - const DMAMap *needle) +static void vhost_vdpa_svq_unmap_ring(struct vhost_vdpa *v, hwaddr addr) { - const DMAMap *result =3D vhost_iova_tree_find_iova(v->iova_tree, needl= e); + const DMAMap needle =3D { + .translated_addr =3D addr, + }; + const DMAMap *result =3D vhost_iova_tree_find_iova(v->iova_tree, &need= le); hwaddr size; int r; =20 @@ -909,17 +911,14 @@ static void vhost_vdpa_svq_unmap_ring(struct vhost_vd= pa *v, static void vhost_vdpa_svq_unmap_rings(struct vhost_dev *dev, const VhostShadowVirtqueue *svq) { - DMAMap needle =3D {}; struct vhost_vdpa *v =3D dev->opaque; struct vhost_vring_addr svq_addr; =20 vhost_svq_get_vring_addr(svq, &svq_addr); =20 - needle.translated_addr =3D svq_addr.desc_user_addr; - vhost_vdpa_svq_unmap_ring(v, &needle); + vhost_vdpa_svq_unmap_ring(v, svq_addr.desc_user_addr); =20 - needle.translated_addr =3D svq_addr.used_user_addr; - vhost_vdpa_svq_unmap_ring(v, &needle); + vhost_vdpa_svq_unmap_ring(v, svq_addr.used_user_addr); } =20 /** @@ -997,7 +996,7 @@ static bool vhost_vdpa_svq_map_rings(struct vhost_dev *= dev, ok =3D vhost_vdpa_svq_map_ring(v, &device_region, errp); if (unlikely(!ok)) { error_prepend(errp, "Cannot create vq device region: "); - vhost_vdpa_svq_unmap_ring(v, &driver_region); + vhost_vdpa_svq_unmap_ring(v, driver_region.translated_addr); } addr->used_user_addr =3D device_region.iova; =20 --=20 2.31.1