From nobody Sun Feb 8 21:39:41 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1562297192; cv=none; d=zoho.com; s=zohoarc; b=E0pq4uLh5M3cVTEo5VPcf8J23eUW5ryryjz/lTt77NGxzFCoRC2yRf5XU+QtyEftXbNL9mEUt3kVO0ZptpZst6ccm4/7oI8MLQri5ISEV4DasahdU+YVKoCOtm6m+1yWXT+7Sv9NtgZBq3t0x9/L/g9AlnWqIcAoq/PedRalibs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562297192; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=Xyu6Z2LSOCn1qywquPJ6ecdHEKn82lUE5Mn2XemEEK8=; b=jUd1iA5uCT3hB8jCsdgsCHlWQMiFMXILyJZhneHYreFuWVvTabNZHhdcSGUYkQRdv0tSCNNJ+jgYLH+uDoqzESNzJorFrH2TcxyVlL6oZHA3k7R+yqJC28L1BH5/Qzs6pGjuwNQt46pM9BEwaNcfW0WYzYX9GJfPCtMQh6RUP38= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1562297192001834.9173928792459; Thu, 4 Jul 2019 20:26:32 -0700 (PDT) Received: from localhost ([::1]:49656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjErm-0006Op-ME for importer@patchew.org; Thu, 04 Jul 2019 23:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34178) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hjEqx-0005nu-Ug for qemu-devel@nongnu.org; Thu, 04 Jul 2019 23:25:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hjEqw-0004aC-8y for qemu-devel@nongnu.org; Thu, 04 Jul 2019 23:25:39 -0400 Received: from ozlabs.ru ([107.173.13.209]:54631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hjEqw-0004Z7-3t; Thu, 04 Jul 2019 23:25:38 -0400 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id CED23AE80004; Thu, 4 Jul 2019 23:25:03 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Fri, 5 Jul 2019 13:25:01 +1000 Message-Id: <20190705032501.106966-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [RFC PATCH qemu] vfio-quirks: Pass the actual parent when deleting a memory region 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: Alexey Kardashevskiy , Alex Williamson , qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The usual way of using a quirk's MR is to add it as a subregion of a BAR as this is what quirks are for. However there is less than standard user of this - NVLink2-enabled NVIDIA GPU which exposes a GPU RAM and a ATSD 64K region outside of PCI MMIO window so these MRs get the system address space root as a parent. So when the user unplugs such device, assert occurs: qemu-system-ppc64: /home/aik/p/qemu/memory.c:2391: memory_region_del_subreg= ion: Assertion `subregion->container =3D=3D mr' failed. This passes the actual parent MR to memory_region_del_subregion() in vfio_bar_quirk_exit. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- This removes an extra sanity check that a quirk has a correct parent; I am not sure if it is very useful. I could use the "system" MR if quirk->mem[i].container=3D=3Dget_system_memo= ry() and quirk->mem[i].container otherwise to keep that assert working. Also this does not help with the actual device removal much because of the closed source driver nature - the associated service (nvidia-persistenced, responsible for onlining GPU memory) crashes the guest system but at least the user can reboot the guest after the crash which is not as bad as assert. --- hw/vfio/pci-quirks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 27dddbc8fa3e..ef2e182c1d36 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1896,7 +1896,8 @@ void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) } =20 for (i =3D 0; i < quirk->nr_mem; i++) { - memory_region_del_subregion(bar->region.mem, &quirk->mem[i]); + memory_region_del_subregion(quirk->mem[i].container, + &quirk->mem[i]); } } } --=20 2.17.1