From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887698; cv=none; d=zohomail.com; s=zohoarc; b=MkOvp50xkRAg5pLJqda0fbkZ9U2Cjz+1m27KauUWYSp1Q9WpxnvHKUjn08NtSlFW/IPOzUrzGdL339NTTvaEnd2pPSpXdo2cuSyNjvow5aBjRY5Ad/UxV3Qrt67ZCUJPO5QNeQpRPbUa3MkmUaHKDob91eV3tlkzGzkm/5cHf84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887698; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=izEY9a2th2CCeu2Q299I2utX7A1cTWXGb6PxvgTVHgg=; b=L94JQ2ca1+DCFsmGecoTJrnkpsew/OxDCGQvgxwtnAk4FCu3irEmsFb3A07HY3lew5glydDtowz4V9kQmh3G1bwkfntyzqbMxM60MNuwaUNhzlqT2Av19OCqhxGJaTpC30NRQc6yODOYv9jO5C5KtWYbktusD5iEsMYYH32ZlKI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887698395598.1414597847422; Tue, 13 Feb 2024 21:14:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7ak-0005oH-NH; Wed, 14 Feb 2024 00:13:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7aj-0005ns-6n for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:13:53 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7ag-0007oq-N9 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:13:52 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d7393de183so11843855ad.3 for ; Tue, 13 Feb 2024 21:13:50 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id kh13-20020a170903064d00b001da2924e576sm2874122plb.204.2024.02.13.21.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887629; x=1708492429; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=izEY9a2th2CCeu2Q299I2utX7A1cTWXGb6PxvgTVHgg=; b=sBQw5F9WFlFOw42oYt7DGO91nc4vwJVJ6LjQJrRVaKQlHIaM2C8ipv/YGQh18C2euQ 7zX6mP7iR1tRPdBjbFQr8DKiPNchMJWpcwNkyw8TGpxbHpmyM9vJnAxy+L08bQ6emeKL iWIkaJZIfWvHhFf0vD/N0dwd1P1XUeZDgpxnP2Ucasi/3xcivEwqUAvC16/6mdcMuIZt zXRq+LzBw1HTpMOZiKmgnCnxzaggo8h4O/syDlYXgbnS6IrC6bL5S5nIRPwu9MH8wV2M bHUX1qopXeLp2lqmrfaOGk9gVkuAv8dsyObotkxehBu5KiVN7zm6BoKZutOHf1kD6siP LtOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887629; x=1708492429; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=izEY9a2th2CCeu2Q299I2utX7A1cTWXGb6PxvgTVHgg=; b=vViEFt+Ds/E2HCY7zfqkkwKV/oZ+1U2MaIbMBe/cUK5/nKv1KS5Wk/3W68mv38xHRM +yU34pQVCndyPG2B1uNxoLkdZfv924aiNxXuiqkiiaGlwXDCupC791fOZXD4bPOd1rNC bBiIKVVHxWkciWZt9xhYn6YeQkxvVrfj9LZCLhO2YRNh7dhQIhaqetBs4vEhyIlltKlg DCb5aCWOPXNj0ZynwG7DmELX6BMLDsMfQXG+iol15gEy3SAk/ZRzP32zXS8vAuKIHGYq fBBiNKKDPVdok0LdjsDYzK3uzqd9v3fbKE5bpTftzjnH58YYpxVpUqU83X1HfmAsxVDW E7vA== X-Gm-Message-State: AOJu0Yx05N2jlxHh7kwM2hHAXvCXmo4dTU7yGGWXGce+08Dd7fI4iJA0 MU2twpGa5PezCA0lEgb8gcY2cypX0Qtrgq/y/rgfaRA4H0gTSj5GjvLJEHgLT+5RPimnkNzVsxK 0 X-Google-Smtp-Source: AGHT+IEilZlzkpak2Q/+B9Nxii1tWMpMCbZgo0JMZnOuotqp/pL7966w26A5/a6VCM2mGUGvlOKrKA== X-Received: by 2002:a17:902:d507:b0:1d9:5cfc:ac6a with SMTP id b7-20020a170902d50700b001d95cfcac6amr1590510plg.69.1707887629400; Tue, 13 Feb 2024 21:13:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWP2eXgsHAdF4zTkFVmUWm2/dCf3NzpqgT9WSQzkuazJLtclDHkbu6LZMm6JLDx2U6PrU/hwu9yGwn8wm5q5Nbrv/BearPcpmdHY+m4mM93sbWBiP1CxpIh+mCinHO8vvW55Oqil5iLCY7a4iRFbY3Lr/bNmPiQXnmZRlrt6LWC6D2niSVxjnKtPgjUQhMBbz45fRXkWqZjuG/RiVfmu1CFAE/lUDAG6v5XA+xbD5ntv9KxcroMn0isySbCgfF+sA3btmnBDO0IfAS5BCr2j00LzYpjRIJe+WpXuQGl3s7FxgY0Dztfde7tzUKaTjV1rEnVqDnwpZOJd6TyHEKztM2HucsXkuUEhwWE71tZ3u7AuU0mVVBIG64GyPEV5B6aAQga/l2NyYWEYC/bWAa8uY9dSi5udiTsCsFhdrku7lgLmwrV+5qzqN+hv3yJrKk= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:39 +0900 Subject: [PATCH v4 1/9] hw/pci: Use -1 as a default value for rombar MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-1-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887700201100003 Currently there is no way to distinguish the case that rombar is explicitly specified as 1 and the case that rombar is not specified. Set rombar -1 by default to distinguish these cases just as it is done for addr and romsize. It was confirmed that changing the default value to -1 will not change the behavior by looking at occurences of rom_bar. $ git grep -w rom_bar hw/display/qxl.c:328: QXLRom *rom =3D memory_region_get_ram_ptr(&d->rom_= bar); hw/display/qxl.c:431: qxl_set_dirty(&qxl->rom_bar, 0, qxl->rom_size); hw/display/qxl.c:1048: QXLRom *rom =3D memory_region_get_ram_ptr(&qxl->r= om_bar); hw/display/qxl.c:2131: memory_region_init_rom(&qxl->rom_bar, OBJECT(qxl)= , "qxl.vrom", hw/display/qxl.c:2154: PCI_BASE_ADDRESS_SPACE_MEMORY, &qxl->rom_bar); hw/display/qxl.h:101: MemoryRegion rom_bar; hw/pci/pci.c:74: DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), hw/pci/pci.c:2329: if (!pdev->rom_bar) { hw/vfio/pci.c:1019: if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { hw/xen/xen_pt_load_rom.c:29: if (dev->romfile || !dev->rom_bar) { include/hw/pci/pci_device.h:150: uint32_t rom_bar; rom_bar refers to a different variable in qxl. It is only tested if the value is 0 or not in the other places. Signed-off-by: Akihiko Odaki --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 6496d027ca61..47f38375bb09 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -71,7 +71,7 @@ static Property pci_props[] =3D { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, -1), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, -1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), DEFINE_PROP_BIT("x-pcie-lnksta-dllla", PCIDevice, cap_present, --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887704; cv=none; d=zohomail.com; s=zohoarc; b=Fi+2aQv6ChtivWW2oUhNL52xTxaXN30HbZt15IXQvAZe2p9HIwyrs7LMjgBD+uWjtJpq6Bya/Vqfu0D7a4hRaTdWK6mFjFPAFpmZ8duuxYJm6txp3B8xGTI7SezuLj/3XW05OkcygAZS+lkzwa3HODPwrDYnh2+LCQusqQsCDB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887704; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AMJKf0v/M+FFicTJu/HiSNXQGXhiRqdJXUW8dIKkkgw=; b=SWCIlZyh694rczSn89AuOFD+EMIXKEHbIk124P3WM8qwP4vP8oGbNp4D0AtL0fKWyts463ngM9M+aKd32gyAMY2Q0GKk8I7h99/oIOgsGVeHO9YZnVoufhKee+7my+9YBD4jYVk0sI07SbofMxFHqnsZTOHGfoVfku3I6PuUnkg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887704910466.77137570442835; Tue, 13 Feb 2024 21:15:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7ao-0005ot-7k; Wed, 14 Feb 2024 00:13:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7am-0005oc-WD for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:13:57 -0500 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7al-0007pZ-IO for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:13:56 -0500 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6e09493eb8eso353186b3a.1 for ; Tue, 13 Feb 2024 21:13:55 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id b18-20020aa78ed2000000b006e0a4022fa2sm7452600pfr.189.2024.02.13.21.13.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887634; x=1708492434; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AMJKf0v/M+FFicTJu/HiSNXQGXhiRqdJXUW8dIKkkgw=; b=ZdctagRL7KFhnweQSnfiDEr91LJucWbw1BetMw7UHAghBNSqIEfYbOxghtCWryqop/ fvXQB3ZAI7yHdSk8FDd5KY8mCuG3h4NSM/g0qlb9BJFOCU0/SqskAMlRk1IujZt6shli caykxWGT6OxYDSsjCikAvl4JPXikI07MkkQpKGLzQa+bM0pA2WUe9Zl0l706ua1ZQlbh Y4ehN6cfWjX7OtFHzW8Z0kRQMv3YHtkIIKPdLrq3a9p3c8tGLXVBN0X7qj/APc7Yar3K 4BZMvQXXIOTvZDuUItXLIzRj7Dy/AepoxtJGQfPHmwdSQmx95RS2i+Xp0318Q/ZwcRzD gsqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887634; x=1708492434; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AMJKf0v/M+FFicTJu/HiSNXQGXhiRqdJXUW8dIKkkgw=; b=IWOsf5y0byTUVRCZZxlBynEtOdGzauHzGRB/NZJobZRtPi2EpIMsFXcaozuzteLHzZ GH2K2IZGUUX6sozX6c+GVlgkFh6ScK/GonbfXmsR/GIeXRxLGwTIH9YKLxFLTmbnpvvK RPg8nkOCqnSgLFh/DykdyjaP1p5hcLzDetyhrK9o98P9XwgAkRTLvFX/15cVSYKWRAWk 62Cwq2vaPWkicdEDPSFFCUT4zFpdPx2Y3PC63GFBQGtK4SvXLGm5hSMQhsrnmTkAbnyI 6+KDiMD5fY8zbc+3cD72YFjmABp/GimOoj1szSi47wUUYlcpP6cU2tj/Oiw7t/vyJVj2 ux/Q== X-Gm-Message-State: AOJu0YzRya2nGpCUc6tuq/1y2Rjl/sRssnQlsHXsy7rIs2G84xu69VkO WFaPvLWXDBm5tHXaCB8/4xPHz5HWc23pFBSx8MhcQ2B+4mIfUTPqTqgK8qh/ZJY= X-Google-Smtp-Source: AGHT+IEkABjnERuYiGH+MKfqwmoIwC+4yd/WPG+EO8ooQA6EpkLNyMbKvwllFSlvbcVYBBN9/X72kQ== X-Received: by 2002:a05:6a20:43a2:b0:19e:4ab2:c362 with SMTP id i34-20020a056a2043a200b0019e4ab2c362mr1423478pzl.14.1707887634206; Tue, 13 Feb 2024 21:13:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUrsfXnd8sOujh39hlWsakF+8H3UF+75cXdFu6d7D4+fXN5+FOL933E811oM5roRicpwsjyqLA2aNuwHlMhWJJI8Kxtv0CtC4PEYmg3CeNILXfdkER/ifPHaMk5E8Z8xKS31nUG1eXkKiPrWSAFataBKJ2s2XoqCqhDQiE28xab7Fyjtc1ayF+/7rbnyUiskG0dzWX/tWGL47UR1nA6LqoRd2qzdn8x9gNJtwCj8istPanjUpGiONs/7hIc6h2dXRyWHuNvfgshNy2vQRYjh/FCt32r4PEBE8jFr4uN96G9G5K3prqwfpAtdDaHto6Bp88zXO03vgK/HbgmbLpr2bm8wRZR/TiUQRUWYkEn3WR54VrKWksiwMWLLZKTiOlhJTw3AWqvWFAaUDaB9/qRisYPzRmkJ8bKCKhbixkf/WKZbY8jSUjzZdlB1pphm+Q= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:40 +0900 Subject: [PATCH v4 2/9] hw/pci: Determine if rombar is explicitly enabled MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-2-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::42f; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887705981100003 vfio determines if rombar is explicitly enabled by inspecting QDict. Inspecting QDict is not nice because QDict is untyped and depends on the details on the external interface. Add an infrastructure to determine if rombar is explicitly enabled to hw/pci. Signed-off-by: Akihiko Odaki --- include/hw/pci/pci_device.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index d3dd0f64b273..54fa0676abf1 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -205,6 +205,11 @@ static inline uint16_t pci_get_bdf(PCIDevice *dev) return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn); } =20 +static inline bool pci_rom_bar_explicitly_enabled(PCIDevice *dev) +{ + return dev->rom_bar && dev->rom_bar !=3D -1; +} + uint16_t pci_requester_id(PCIDevice *dev); =20 /* DMA access functions */ --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887698; cv=none; d=zohomail.com; s=zohoarc; b=CWe5EeBaETtviaZKv6TpRIKGuxWMKGI5D26s30LOvH9v10+nEgaWLGcrAJq99VTtjm20ckgQdIhpsnwr1N9auZKCak2KmOzlLnMVIvbJrQPz4e87I4CJngbKpP81Qsam2O3Q5RFW964FiEqW4hJ+AYFytu9IpF/j982hXn3jtOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887698; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VHN067INkkZHjqlocgeNRkot+SvYyjvp5oGzjd4gfAY=; b=lsnA/3tO38mySC9LWvcTe/XrioYLvQzXS6wavVs+jjgMd/pDq7mvFdATkhb+jgJjHT7gI5ZyEQt0wxxOFR9o+VvutX4WMnxjzuPsTTn/GHBghSObdJ6Cxs8uyqaxn4DKepW4dUvNHk0JzbUQUxqz21Fxv4FN7zshn8D3o5GPuJU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887698394978.3347611600751; Tue, 13 Feb 2024 21:14:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7at-0005qQ-PC; Wed, 14 Feb 2024 00:14:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7as-0005pq-8J for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:02 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7aq-0007qm-Uv for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:02 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d746856d85so38640955ad.0 for ; Tue, 13 Feb 2024 21:14:00 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id lg3-20020a170902fb8300b001db5bdd5e33sm316711plb.48.2024.02.13.21.13.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887639; x=1708492439; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VHN067INkkZHjqlocgeNRkot+SvYyjvp5oGzjd4gfAY=; b=m94hwDg1QMmVOe7YIfcl8evYoDTosjfzPgCtwp6ZsDnwLy/0UOIG+Kqr+PrLpVmGAu h31nIXliL0wpf3pdh8n8ihilkYWXgV1yqijBlHY53bYagNsyk9VsMV4+0C5XP78Eo+lj 1a0MmJXPtYngvT2aO4w0cXNiJ7htu6Tlk3sURcbSDuP629RU0f/f1cdm82pP1T5ux7m6 CNrjLMP6h8jWT9ZSfYxoTxvM30cfh0sgbJImFc4l1fs68dDg741iAD2+h6zBClfGSthU Zj6OrhIv9RHFGV64QUT2BGs6Bbsnvt1HMCk9p3nCS/CIAwEU6E3+vgLcOMtIB2r48LdS NOjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887639; x=1708492439; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VHN067INkkZHjqlocgeNRkot+SvYyjvp5oGzjd4gfAY=; b=YWHO2XJw2W+WjojMotPjiQdxJPK3RE/4CkfXi0D9GINm8eboyFRSoaHu0GtP2gN7LN /tx8pBlf6nJ871P20MwX4QKQKzp4ZaRRw+I53yX8i0UOTLBEK6H3OlyFCB447MwqlgLN 87pMBVmtOkOpSnhUIbNc/Cnvbsce2jrvX/ySAhCVk/lpiwElfxYcBH+7uuuxbaL6N+/F qZkBRRDjW+xW0c+2U0Er4uDOds108bcIO1TDUN4HR4Sk/v8Iv1sU0SVF+YMEshQKfszr BuIoesbDxD2zJZNJAnWeV2CRXC1kyEnwphB/1DwxrkZCJK/NnM15QTjjbYn7i3YL5ZBV ciZQ== X-Gm-Message-State: AOJu0YwVHaw3KNA+do1a+O/P9l7PcbkL53kjZ+0otJHJFow5jD3Cfqwa E3HCJQBT0zszURcMq82LKjIoR8dRBwPx5HeX575PhQCTpntKkzYuV4Nfl9pP43o= X-Google-Smtp-Source: AGHT+IH2FGBIu9QCoE9aEHKrrw2BfdioS8blYsBJ3CZCIEILit3plMRG0cPLKgZDjJC/7beqf8lheQ== X-Received: by 2002:a17:902:ea8b:b0:1d5:dac4:5015 with SMTP id x11-20020a170902ea8b00b001d5dac45015mr1650461plb.11.1707887639565; Tue, 13 Feb 2024 21:13:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU6wG/7/RK70wnxnbS+iunJmixB2pzdQM4pHaNJVXN+NJxFScN6PU2QJYB0WjAkO/3XqAtnjrBFIs6k7YToZAsQNgbst+8HXyTIHu/cqO/K3plKN58g/+qEe1bvUGtRjEVUEEz/yRPOin63hR61IEyRqmYgZzquUgqVxzU5QHJbLN0CYSMnmzQxgMUy/VGwmrqkm1AMe9KPL5ofuASCJfOG5myCHSBiytRXDrFtny3/V6nhf55RsF59UO0oMhohQ2bKuz5Pq0/APrfHZ+hxfxu+sF1zqw3WXeCPC16xsqwX0YU91XwcgH0J5P+s++dLnP19y++6cltk6mLcmfeUpjco3A3aeB/3B9a8yOJybkjJ3J2EMp8Q2EeKcE8Wzk7E5Y+CMJR+Z7WC5klpVyfKxXRaq9IjEz7I+mz/NkB5exH2YCAkPw2Nr9ZMdpSHL+s= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:41 +0900 Subject: [PATCH v4 3/9] vfio: Avoid inspecting option QDict for rombar MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-3-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::62d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x62d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887700197100002 Use pci_rom_bar_explicitly_enabled() to determine if rombar is explicitly enabled. Signed-off-by: Akihiko Odaki --- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 4fa387f0430d..647f15b2a060 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1012,7 +1012,6 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) { uint32_t orig, size =3D cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset =3D vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev =3D DEVICE(vdev); char *name; int fd =3D vdev->vbasedev.fd; =20 @@ -1046,7 +1045,7 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } =20 if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (pci_rom_bar_explicitly_enabled(&vdev->pdev)) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887752; cv=none; d=zohomail.com; s=zohoarc; b=jtNUG7ffho1b9Nf7TkWB9QaioxGeqJQkUjSOBLg0BylK72zT5bU8LWxrJd76Pu2beS3gDpRnk2tII7ztSBMweJkaUgVqEqednivcECD0BkIZn9UMjJnJPt0hh/mekfhS5amQmLrvrEkhmqRcOECex6SqM0OZ8pBsdtEHyl2BZlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887752; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VGm/yeCb4fxZuqjysuL7fb9UBHAA2o92NlG+eX2nX9E=; b=VLUg5LHrUzRLquqKeCw1VxyPjB0POZlxWCbc47/LHthSHIDXXPDVhy7wHf+RwA/BZhbGMXpiNGJsqBShv8hOdZBPVkeyX8eN2WWeFNrKFPoZnbK/xzeUhdfgEVOWX11EG3Nsi3YONBfR0ED5QwEEgN+5k91K7MDrzhLe+b3saB4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887752719612.7784960456692; Tue, 13 Feb 2024 21:15:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7ay-0005rQ-Gr; Wed, 14 Feb 2024 00:14:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7ax-0005rA-Ns for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:07 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7aw-0007rV-A6 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:07 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6e0cd3bed29so1694490b3a.1 for ; Tue, 13 Feb 2024 21:14:06 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id o8-20020a17090323c800b001d78a08e8e7sm2874199plh.250.2024.02.13.21.14.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887645; x=1708492445; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VGm/yeCb4fxZuqjysuL7fb9UBHAA2o92NlG+eX2nX9E=; b=gBw+gLNgjqGz4fmd6G1oIj15/ODgmO6+caY5Uy7JqXzeiXGzJ7SxCHT0fT/o0RblY+ pB+VQ7qweWZzbp1P1+xzmxcduoEXQiDYnL3Er7lwsLMA8Zotv7CImED/obt7BnM5JpMH ykZ98CGd976rBDp+0CtvZW1mI/W7rjgjqga/4k1Sk4RiprXCGIgE6iCYw5tVLRVAliJ3 j9dd/iV84NcnBjf1X4j5vzgPpj3sSuyrBcWhvU4+ZKeZkc1nFWRMnCrQljmEPzrrOOdV ocvZ5+PI82/aRDKpOca+FiulXrGElwUuXzjwcN816ua23Us8Z7hE1A1VXPPsq6pF7ixt KJ8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887645; x=1708492445; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VGm/yeCb4fxZuqjysuL7fb9UBHAA2o92NlG+eX2nX9E=; b=pKn5EVuf5VCawqTxR9Xm7AaEeQXrXKVanRzN5iGjRu+E1s1LHcqe/Orf8+GVRfbE4I kYLYhwH2o0QYdGSowsAaH6h1XDqH908jhsgu8x9R7dW+Jk+BwRY7bT+BvA5JN6i06mWT RUKDSf26Wt7VXDfUCGJ22982VoNJ+LDQHaqacQpbn2sKYqfuHshQId/sO0TpAwKPN2sb BVm06QmNTzkRaKwWd/72qJ3AnpXFKXIRJ5Gf34NmL7oH3ZMHRdTNxk/2WJTN2nsZyKiv EgnRSLLCYwH54iZSuUiwnIPUVafYlaQnsYehvSWPjARn3xACNH7f2jgamLQq4Sg1ipKn tshQ== X-Gm-Message-State: AOJu0YzbNmCT3GRFquUekQjQNKy3yHMiHm5pMyG1hV8Al4GAH02EtMn7 00NR7LmfokGUHMEAmcbOdhEctcIfmiPefaLK0zFXUuJpt6v0E/nT0blx4WOLdhs= X-Google-Smtp-Source: AGHT+IGkIF1yNibwcTzdUwqu2hjVOuPWns3tPwmK46+/XHAvdyx5YP+NE2vzKlmhcyRXlbvbW0BXzg== X-Received: by 2002:a05:6a21:3606:b0:19e:a524:a92c with SMTP id yg6-20020a056a21360600b0019ea524a92cmr1355351pzb.23.1707887645001; Tue, 13 Feb 2024 21:14:05 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX/wSQ8RoCCVRCnCH8yVRWlYS1vs8h2eSvxvCOJrNN+ltOf0++42F5iJU7r744Fa5wwOcFz+RVEROSrjzGOVID/NOBlvR3ojxjhvjpJoGyKIu3hiXD/Yo51cwryJYjc/30LJTcL1ZCY+oxollAey7FJKZLjhY6IGk+JfweDE+1r/bfZza9s7P1k601jehnjpCwLhErB7rMUj0W4tfbx2Se8VMZ+1nFUBR3aKx7SmHs7scMf90L6HnwexN+tTyTVrjYlla2GczWVN+naNF758IE5onoSBoFVeTkByUOCLLx5WovbrcZjOCFqY4Ff540SQDbHjAjFkXXjzLS0mMlYJao52VMPcyW8KmbSaN6M+gH3I04v6P52bt4zBx9Wd6Wj+4nuccOtfwj5Wao++bnlzmcfn6tfbC3ZAlU6ZYbILAOR216FHOE358PRMyYx80k= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:42 +0900 Subject: [PATCH v4 4/9] hw/qdev: Remove opts member MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-4-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::42d; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887754114100003 It is no longer used. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/qdev-core.h | 4 ---- hw/core/qdev.c | 1 - system/qdev-monitor.c | 12 +++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 9228e96c87e9..5954404dcbfe 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -237,10 +237,6 @@ struct DeviceState { * @pending_deleted_expires_ms: optional timeout for deletion events */ int64_t pending_deleted_expires_ms; - /** - * @opts: QDict of options for the device - */ - QDict *opts; /** * @hotplugged: was device added after PHASE_MACHINE_READY? */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index c68d0f7c512f..7349c9a86be8 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -706,7 +706,6 @@ static void device_finalize(Object *obj) dev->canonical_path =3D NULL; } =20 - qobject_unref(dev->opts); g_free(dev->id); } =20 diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index a13db763e5dd..71c00f62ee38 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -625,6 +625,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *op= ts, char *id; DeviceState *dev =3D NULL; BusState *bus =3D NULL; + QDict *properties; =20 driver =3D qdict_get_try_str(opts, "driver"); if (!driver) { @@ -705,13 +706,14 @@ DeviceState *qdev_device_add_from_qdict(const QDict *= opts, } =20 /* set properties */ - dev->opts =3D qdict_clone_shallow(opts); - qdict_del(dev->opts, "driver"); - qdict_del(dev->opts, "bus"); - qdict_del(dev->opts, "id"); + properties =3D qdict_clone_shallow(opts); + qdict_del(properties, "driver"); + qdict_del(properties, "bus"); + qdict_del(properties, "id"); =20 - object_set_properties_from_keyval(&dev->parent_obj, dev->opts, from_js= on, + object_set_properties_from_keyval(&dev->parent_obj, properties, from_j= son, errp); + qobject_unref(properties); if (*errp) { goto err_del_dev; } --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887768; cv=none; d=zohomail.com; s=zohoarc; b=I2GuNYNMwUmolpNMThr6FOwEWcrrhpC/n39o5PWOy0EJZhmxTFV8Th1oCV9wwYO1bZJYjS8XJXHXO/ONRbcEaqr50ZV8g0AeS4MepWFcw6wkMZCxdvn2DXvkQNZ8DEcoJxYgsdXPxEXes9EsLfOcu4d736TiC8SbFAIBGAYfuz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887768; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sVsDDgcIpEBlmcq1EWawWovzpkmUUsK5fa5lmtMzwhw=; b=do+E2PzBk1aLos1HRrOGJPTOzykHIP7onzms65NribTnFY1gXAzhOAFRTb3bo7fTZIzDSmNpc3O3+vUQCgrOoIdzM+q38jEHrQrfkvpnqtKRdYAFAR3bxJrAMi+hIBNRgktCJg9GEz3h+HGlSOxzZzP9dcvYE7OrEEQ+uNrhjJo= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887768206139.27019721090574; Tue, 13 Feb 2024 21:16:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7b4-0005sz-A2; Wed, 14 Feb 2024 00:14:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7b2-0005sH-Or for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:12 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7b1-0007sJ-Dt for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:12 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3c02adddb8eso3062406b6e.0 for ; Tue, 13 Feb 2024 21:14:11 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id h28-20020a056a00001c00b006dbe4452741sm8366599pfk.72.2024.02.13.21.14.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887650; x=1708492450; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=sVsDDgcIpEBlmcq1EWawWovzpkmUUsK5fa5lmtMzwhw=; b=jR4I5L1eOPJD0C50DTzk7y9UYVagOerNrEEqeGk9BGIaGVkVHiUCxcAV1XXOYe0vZi Sfk3S+/7aLiCR1SlgD3ynBt9XtB90qS75lHcohKTU5IHxDoEtt0+7mC+vlCK5ONLkAi2 f7pzFHt4mIVT3Z9OCS7/jV/K5FkMIvaNe+Y/XfAcV7fxooxPRQtyQl8KRNr4+4Z+yYiT YCNOaJ/Qpzsc3Ykthw7M4rOxz2ioItD9tnOIxtWSIVzHJpSFf2p5/fmJMZwBbf/td1zr PrL7Lo0YQG3Wn4Ef5qzOsUVxk9wVCTY6L1JpfNgkyV735Z2oLfaLSApve/VvtOKGheJj Hevw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887650; x=1708492450; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sVsDDgcIpEBlmcq1EWawWovzpkmUUsK5fa5lmtMzwhw=; b=fkErmi9ZK0zghR4yvpt11tK6eBlHDQCks+J6mBYkPMneU8/qsH9H6YibWfPVsb48SX E8kpMc9358WuDsqp6ILhakhihqI9Z+gcJ6v+++yRwRfUTwyQ5YYiQbbGkPszTeL3ixVD QLujdw6N8+Hp4V9VYq4YkZgWhdfCU7z3S0dyRPfQ7+/fTwOLawzxhShpeXZiXbD1nUBd PjggE/knN61TwcVnL6JsGuk1wVMLBFwwvrU+58pBVohEgkpmfOOOrw7OfXXkDKPNcgbE FnRhMAa/1CaiMSrGkErMAzGI/5FqgAbpW48X7eBytmL81nJAVQbLmjywEpBnilv6QaJ/ T35w== X-Gm-Message-State: AOJu0YziBSLG5h9C4KQqV9C3PPXeD7iWdBmLmjzdKE8VQWqNlXsOAYeb os1/8AHzM002pvsdyMF92UBuE6GVIKj1kZYrNSuSlNHn4pmdDHud83nzDz5SiJU= X-Google-Smtp-Source: AGHT+IFQ+QZu3dNiTd7YAMs6Qfg5c7w1+yTOtPcN2oHwUWIhrGAcX+U6M2805pVA5Cc0mQZmysDThg== X-Received: by 2002:aca:f06:0:b0:3c0:48aa:1bd9 with SMTP id 6-20020aca0f06000000b003c048aa1bd9mr1572762oip.21.1707887650412; Tue, 13 Feb 2024 21:14:10 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUIakWlVCQZYSpZlMrbN9Q+n9UrKcVpXJeJdP1ZmR5Kqab4FY/qOVy7JwM7pgUEmo3m/uRfq8L9Pt4Y5rCXYNgs5D4AoKOyc7ZGBMO4S6b1q0vE/7S/Td6nCk3GQvx6+W/oXGL47ZOtHBd/1ikin8GwCrKu07jrsTeHnHBwaj+vxp3VHeEblZjtRwYGX5e7xCRaAljNUtEz5M1u0jIrH9+C8cJ/rmyD68vkd+h6gVBSfa4UWNGznneT7rF2b7GHyAiegHSlgu7zghpGZ3Q37TkDxHF53dh8zmMdAF5eHjoGlhbkOWsGP28o9Y88mhz7bPVKF2WZBwYQbB46JlorgWlay6Tg/y8vgZ1bNhMI9//hSQYFee2rYJOe0Y7bLo3M5nWPiJt22tDWzbC1/9bFdAzhNyi6DSCXJiTAak+hdjVKDNKyPvO+234Pu4oT4tI= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:43 +0900 Subject: [PATCH v4 5/9] pcie_sriov: Validate NumVFs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-5-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::234; envelope-from=akihiko.odaki@daynix.com; helo=mail-oi1-x234.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887770208100007 The guest may write NumVFs greater than TotalVFs and that can lead to buffer overflow in VF implementations. Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization = (SR/IOV)") Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index a1fe65f5d801..da209b7f47fd 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -176,6 +176,9 @@ static void register_vfs(PCIDevice *dev) =20 assert(sriov_cap > 0); num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); + if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_V= F)) { + return; + } =20 dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, num_vfs); =20 --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887767; cv=none; d=zohomail.com; s=zohoarc; b=OGNYzE5L1SILZ9JoVQQpIKKBuNCCpL1ecy6aOfBPnahaZuDLkmY8bjscSf4crw1omLZFPgTeSuj2pP+YDe0mPeiU0UwnQGcb30222GyOsTdkvJSpRqBTJvohE07a6HNMgrudQu8q91qld4eQhAeoCTxyoEkfrD828TIPVDdir1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887767; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J9Eo5udu3C/tLuiBCtuIdjVgA/w+3CUPNT2kUUAhl3M=; b=kIueO/DNnjouT6eDnNmHp0Lc3J9CNhhKo1/O4rVJtqkiNaugFeZ49GlP9yGA8h/KwxZ/fV+VC/H5dq+MiXCOuuD6xng6ZjBr1SvoG1OpYEQmQg7OgmC//olTWVc7mT6KJ6c5EQytoEetovOHL34CQseZVjHorne4+MA11022Ov0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887767487684.3919825131746; Tue, 13 Feb 2024 21:16:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7bE-0005uN-Pw; Wed, 14 Feb 2024 00:14:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7bA-0005tT-Un for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:20 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7b8-0007sx-LV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:20 -0500 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-29026523507so3608992a91.0 for ; Tue, 13 Feb 2024 21:14:16 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id go23-20020a17090b03d700b00298cc2b7e94sm417339pjb.34.2024.02.13.21.14.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887655; x=1708492455; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=J9Eo5udu3C/tLuiBCtuIdjVgA/w+3CUPNT2kUUAhl3M=; b=ppF34dQhLdT34nqWQldmgNDjXELKuqk62SayH4RPHkRsmH2vIaLKGMSWTlXWXAGdR0 cYQrXFOf6SomvahLyAp17bu+VWKcf+Xn5yCU6O6JOLkOyOceCjfkV6bJvF7zER9kzW4N 1ssGaTEdSut153fJakBhC4bfB8l1mT0HSObIuSQyLgWuG9xNgElggxn5LbkworgRB0wi XltP3sxegDS0K5wKobEtDxlT9oQ6jGyT6Vd9GhQfZ8QZ9vfqxP7iCwnwQ9FtTEc3Efc/ XO0K5dNado7e62/6hhVSeL0HKUrVsi49MIZaTiIsXpwtGOfB/3ptUus9CKKRIrQNAh+Q gazw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887655; x=1708492455; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J9Eo5udu3C/tLuiBCtuIdjVgA/w+3CUPNT2kUUAhl3M=; b=KJRuTTtzgMBPfaJTmX5n0yIs/BFsZgn+9AnL+LOk91kRZ3Gd0fgW/0IaysgIkkbVpt tKzAaIEdXal1RJElijpq6yJ2+rjnc7CWbClSNS5MdXmMoI9W2tnJFibCHv4sbAxcGLNR 0Sk4MPahQhRE3CsP5oXAShdSSQ2LPPSYTBk33OK9A43LrkgpLPNEzrF+JiQSz/2ECwkJ WQUSDw3CYjFF5WWu/m6jsxfbBztsLV69aKMZ9LECwlvPBsBhn+JTpOHHc+dujCNQjEWc UWNkOL1U7DDFE95/9MndKSgrKNLDcU5evhhsT2k8fVhj2RB+lZIXamOligWZhyiPTd8w B2Dw== X-Gm-Message-State: AOJu0Yzcbv6FjF97a6QUqKq3zje9XV+WHIyhAGiMDstH5aDV8MVv/lWu zzObBc50nwu7cAePRmJg8xTE6z2zvqTcj5PZRc1OFb9sSMy/tsRHyVUAckStBwg= X-Google-Smtp-Source: AGHT+IEnem5FLGMeQkvfHp52ZQZIXESfHCsNGPoK+942qZT6XEGQCyOf+bXqtutidhQMU9ApGz3k2g== X-Received: by 2002:a17:90a:ea0e:b0:298:bc68:a8c8 with SMTP id w14-20020a17090aea0e00b00298bc68a8c8mr1666884pjy.6.1707887655363; Tue, 13 Feb 2024 21:14:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXzZMoSOQKNLM/PZItR684D/uxkbrw/tvVfohxspXP+q+JrIQf1dHh8CxxYxXtS7yLtvZL/ExxodrOJ/wH4KLR8cQo7j5sKFXzoNovn1i7teMuSxttA1aNE9ehbcszGwxVUmTmBwMyuAj3mOgKavrEZcBk8rlbwKK822I1vUkYC4dn0CL8RI8KhMLdszQgpReSzyClMl/w9n0pXkki7vJJMAVl3YNO2rGVpQmlS5JSRLKBAZSXhVFiyOQzYlibQTAT8vCRVbYjdalZHxa4Lfcy3JILKHNAR4fh3REG2nLJfIGGDE5UG5H0Vu9MUJvexf/iVkavgAfEWCGa7kFlEtsEWzwm5TlOSFmON64cDOaKcNhgBzqGWhuKiel3/3NxWNF0RhkBHln+tzAqZB3worRpxZWHvEIetEgcTIVhnj52nHJJrMV97j6lvVlp3rUc= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:44 +0900 Subject: [PATCH v4 6/9] pcie_sriov: Reuse SR-IOV VF device instances MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-6-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::1031; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1031.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887768231100002 Disable SR-IOV VF devices by reusing code to power down PCI devices instead of removing them when the guest requests to disable VFs. This allows to realize devices and report VF realization errors at PF realization time. Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 8 ++-- include/hw/pci/pci.h | 2 +- include/hw/pci/pci_device.h | 2 +- include/hw/pci/pcie_sriov.h | 6 +-- hw/net/igb.c | 13 ++++-- hw/nvme/ctrl.c | 24 +++++++---- hw/pci/pci.c | 18 ++++---- hw/pci/pci_host.c | 4 +- hw/pci/pcie.c | 4 +- hw/pci/pcie_sriov.c | 100 ++++++++++++++++++++--------------------= ---- 10 files changed, 97 insertions(+), 84 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index a47aad0bfab0..ab2142807f79 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -52,9 +52,11 @@ setting up a BAR for a VF. ... =20 /* Add and initialize the SR/IOV capability */ - pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", - vf_devid, initial_vfs, total_vfs, - fun_offset, stride); + if (!pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", + vf_devid, initial_vfs, total_vfs, + fun_offset, stride, errp)) { + return; + } =20 /* Set up individual VF BARs (parameters as for normal BARs) */ pcie_sriov_pf_init_vf_bar( ... ) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eaa3fc99d884..442017b4865d 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -642,6 +642,6 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) } =20 MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); -void pci_set_power(PCIDevice *pci_dev, bool state); +void pci_set_enabled(PCIDevice *pci_dev, bool state); =20 #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 54fa0676abf1..f5aba8ae2675 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -56,7 +56,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; - bool has_power; + bool is_enabled; =20 /* PCI config space */ uint8_t *config; diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 095fb0c9edf9..d9a39daccac4 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -18,7 +18,6 @@ struct PCIESriovPF { uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ - const char *vfname; /* Reference to the device type used for the VFs */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ }; =20 @@ -27,10 +26,11 @@ struct PCIESriovVF { uint16_t vf_number; /* Logical VF number of this function */ }; =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride); + uint16_t vf_offset, uint16_t vf_stride, + Error **errp); void pcie_sriov_pf_exit(PCIDevice *dev); =20 /* Set up a VF bar in the SR/IOV bar area */ diff --git a/hw/net/igb.c b/hw/net/igb.c index 0b5c31a58bba..1079a33d4000 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -447,9 +447,16 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error = **errp) =20 pcie_ari_init(pci_dev, 0x150); =20 - pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF, - IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, - IGB_VF_OFFSET, IGB_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, + TYPE_IGBVF, IGB_82576_VF_DEV_ID, + IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, + IGB_VF_OFFSET, IGB_VF_STRIDE, + errp)) { + pcie_cap_exit(pci_dev); + igb_cleanup_msix(s); + msi_uninit(pci_dev); + return; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, IGBVF_MMIO_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f026245d1e9e..f8df622fe590 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8031,7 +8031,8 @@ static uint64_t nvme_bar_size(unsigned total_queues, = unsigned total_irqs, return bar_size; } =20 -static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et) +static bool nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et, + Error **errp) { uint16_t vf_dev_id =3D n->params.use_intel_id ? PCI_DEVICE_ID_INTEL_NVME : PCI_DEVICE_ID_REDHAT_N= VME; @@ -8040,12 +8041,17 @@ static void nvme_init_sriov(NvmeCtrl *n, PCIDevice = *pci_dev, uint16_t offset) le16_to_cpu(cap->vifrsm), NULL, NULL); =20 - pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, - n->params.sriov_max_vfs, n->params.sriov_max_vfs, - NVME_VF_OFFSET, NVME_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, + n->params.sriov_max_vfs, n->params.sriov_max_v= fs, + NVME_VF_OFFSET, NVME_VF_STRIDE, + errp)) { + return false; + } =20 pcie_sriov_pf_init_vf_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, bar_size); + + return true; } =20 static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) @@ -8124,6 +8130,12 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) return false; } =20 + if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs && + !nvme_init_sriov(n, pci_dev, 0x120, errp)) { + msix_uninit(pci_dev, &n->bar0, &n->bar0); + return false; + } + nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); =20 if (n->params.cmb_size_mb) { @@ -8134,10 +8146,6 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) nvme_init_pmr(n, pci_dev); } =20 - if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs) { - nvme_init_sriov(n, pci_dev, 0x120); - } - return true; } =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 47f38375bb09..838c261c21f0 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1524,7 +1524,7 @@ static void pci_update_mappings(PCIDevice *d) continue; =20 new_addr =3D pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->is_enabled) { new_addr =3D PCI_BAR_UNMAPPED; } =20 @@ -1612,7 +1612,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + & PCI_COMMAND_MASTER) && d->is_enabled); } =20 msi_write_config(d, addr, val_in, l); @@ -2154,7 +2154,9 @@ static void pci_qdev_realize(DeviceState *qdev, Error= **errp) return; } =20 - pci_set_power(pci_dev, true); + if (!pci_is_vf(pci_dev)) { + pci_set_enabled(pci_dev, true); + } =20 pci_dev->msi_trigger =3D pci_msi_trigger; } @@ -2810,18 +2812,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int = vector) return msg; } =20 -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power =3D=3D state) { + if (d->is_enabled =3D=3D state) { return; } =20 - d->has_power =3D state; + d->is_enabled =3D state; pci_update_mappings(d); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); - if (!d->has_power) { + & PCI_COMMAND_MASTER) && d->is_enabled); + if (d->qdev.realized) { pci_device_reset(d); } } diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfe6fe618401..d7e13d72ce07 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -86,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uin= t32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->is_enabled || is_pci_dev_ejected(pci_dev)) { return; } =20 @@ -111,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev= , uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->is_enabled || is_pci_dev_ejected(pci_dev)) { return ~0x0; } =20 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 6db0cf69cd8a..f34c157e1fd3 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -394,7 +394,9 @@ static void pcie_set_power_device(PCIBus *bus, PCIDevic= e *dev, void *opaque) { bool *power =3D opaque; =20 - pci_set_power(dev, *power); + if (!pci_is_vf(dev)) { + pci_set_enabled(dev, *power); + } } =20 static void pcie_cap_update_power(PCIDevice *hotplug_dev) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index da209b7f47fd..9ba34cf8f8ed 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,15 +20,29 @@ #include "qapi/error.h" #include "trace.h" =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, - const char *name, uint16_t vf_num); -static void unregister_vfs(PCIDevice *dev); +static void unrealize_vfs(PCIDevice *dev, uint16_t total_vfs) +{ + for (uint16_t i =3D 0; i < total_vfs; i++) { + Error *err =3D NULL; + PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; + if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)= ) { + error_reportf_err(err, "Failed to unplug: "); + } + object_unparent(OBJECT(vf)); + object_unref(OBJECT(vf)); + } + g_free(dev->exp.sriov_pf.vf); + dev->exp.sriov_pf.vf =3D NULL; +} =20 -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride) + uint16_t vf_offset, uint16_t vf_stride, + Error **errp) { + BusState *bus =3D qdev_get_parent_bus(&dev->qdev); + int32_t devfn =3D dev->devfn + vf_offset; uint8_t *cfg =3D dev->config + offset; uint8_t *wmask; =20 @@ -36,7 +50,6 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap =3D offset; dev->exp.sriov_pf.num_vfs =3D 0; - dev->exp.sriov_pf.vfname =3D g_strdup(vfname); dev->exp.sriov_pf.vf =3D NULL; =20 pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -69,13 +82,35 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, 0x553); =20 qdev_prop_set_bit(&dev->qdev, "multifunction", true); + + dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, total_vfs); + + for (uint16_t i =3D 0; i < total_vfs; i++) { + PCIDevice *vf =3D pci_new(devfn, vfname); + vf->exp.sriov_vf.pf =3D dev; + vf->exp.sriov_vf.vf_number =3D i; + + if (!qdev_realize(&vf->qdev, bus, errp)) { + unrealize_vfs(dev, i); + return false; + } + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(vf->config, 0xffff); + pci_config_set_device_id(vf->config, 0xffff); + + dev->exp.sriov_pf.vf[i] =3D vf; + devfn +=3D vf_stride; + } + + return true; } =20 void pcie_sriov_pf_exit(PCIDevice *dev) { - unregister_vfs(dev); - g_free((char *)dev->exp.sriov_pf.vfname); - dev->exp.sriov_pf.vfname =3D NULL; + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + + unrealize_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); } =20 void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, @@ -141,38 +176,11 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int r= egion_num, } } =20 -static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, - uint16_t vf_num) -{ - PCIDevice *dev =3D pci_new(devfn, name); - dev->exp.sriov_vf.pf =3D pf; - dev->exp.sriov_vf.vf_number =3D vf_num; - PCIBus *bus =3D pci_get_bus(pf); - Error *local_err =3D NULL; - - qdev_realize(&dev->qdev, &bus->qbus, &local_err); - if (local_err) { - error_report_err(local_err); - return NULL; - } - - /* set vid/did according to sr/iov spec - they are not used */ - pci_config_set_vendor_id(dev->config, 0xffff); - pci_config_set_device_id(dev->config, 0xffff); - - return dev; -} - static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; uint16_t i; uint16_t sriov_cap =3D dev->exp.sriov_cap; - uint16_t vf_offset =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_OFFSET); - uint16_t vf_stride =3D - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_STRIDE); - int32_t devfn =3D dev->devfn + vf_offset; =20 assert(sriov_cap > 0); num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); @@ -180,18 +188,10 @@ static void register_vfs(PCIDevice *dev) return; } =20 - dev->exp.sriov_pf.vf =3D g_new(PCIDevice *, num_vfs); - trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - dev->exp.sriov_pf.vf[i] =3D register_vf(dev, devfn, - dev->exp.sriov_pf.vfname, i); - if (!dev->exp.sriov_pf.vf[i]) { - num_vfs =3D i; - break; - } - devfn +=3D vf_stride; + pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } dev->exp.sriov_pf.num_vfs =3D num_vfs; } @@ -204,16 +204,8 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i =3D 0; i < num_vfs; i++) { - Error *err =3D NULL; - PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; - if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)= ) { - error_reportf_err(err, "Failed to unplug: "); - } - object_unparent(OBJECT(vf)); - object_unref(OBJECT(vf)); + pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - g_free(dev->exp.sriov_pf.vf); - dev->exp.sriov_pf.vf =3D NULL; dev->exp.sriov_pf.num_vfs =3D 0; pci_set_word(dev->config + dev->exp.sriov_cap + PCI_SRIOV_NUM_VF, 0); } --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887748; cv=none; d=zohomail.com; s=zohoarc; b=IyfRpsgAdB61qVsCmW88zB7yDMwnjzr0VwiNfa3X5a/JqRPZwLKY9lmf8s9y3qgEjA8l0oTn5GzXXavh9AEnqaulZm/MT+3wl+5/I3HKYocTcb1/qozdmlK07ighl3daax4BCrRidgycm4+E+5P1oBPyoc8qhQ3yM9bru+e+v/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887748; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HYSjFZHgQ2mbSqHRTj9z4C9g2BrbZ8iNuTfeoBp92uM=; b=mGj8AL+KDBb9cOfYsVhDxHSjHGtKh6YujxKseay3pg37Zhxgp9ncR0frW9qUsspf9hzwmawaTeqiZ1ztg/PAMX0F6GdNjwuhaOx4idW9ClOF5lCfIbky28EGQ89XV7Fg3F7h5aywiwNk4W2Lfl4QFF+Pkyug/oaXB3J/4BH2udc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887748512351.0532330942041; Tue, 13 Feb 2024 21:15:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7bU-00061K-FW; Wed, 14 Feb 2024 00:14:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7bS-0005wx-G6 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:38 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7bC-0007tc-Mj for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:38 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6da9c834646so4198250b3a.3 for ; Tue, 13 Feb 2024 21:14:21 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id k192-20020a633dc9000000b005bdbe9a597fsm3231306pga.57.2024.02.13.21.14.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887660; x=1708492460; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HYSjFZHgQ2mbSqHRTj9z4C9g2BrbZ8iNuTfeoBp92uM=; b=piL6B6HF9busd7PInV89zPspNU8uUf46ErSiJR0b42gexzOnSxm2X4B6eBB2cEXFNT vdiVS9WPmz87YMjQ1dUDQnugZBOXklaBUidBr8fLX6HhtDQrrI2OrB5lr1+ooWEmM72E XbkXtjCG6rjVt09gP3VMZlxOqFfZpz7LPEevx17hQFmKeCOa/8LMcgtNni2RX+daPTEl 1Lp9lREPI43FwF4U1aZfogp2BDsRknaYZg9BShCO1t5ZilSAGChFb4wUM75pULd7/SJi 7bJUK1N85j9YQxmkDBtbZ1DI2uO9zzrHhPT2WIOPLlw1A8p+kmHhTF3m3ehGsckfu5un GvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887660; x=1708492460; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HYSjFZHgQ2mbSqHRTj9z4C9g2BrbZ8iNuTfeoBp92uM=; b=fPefMhVNDQuhF7s5tU324LvZkm2xjVfZQW8lUG+0985Vw5pwNzmesvvfAzlE6+epqE SAWpmIw55VfNq/DPpwTHJNB0To9/QVNK+s1Ef/Q4xBjoQdJi2k/1yo+GShcTdmi60exQ hJCPRH5ElWM59ZFs54oa8xQuSsoQwWhcKFvz64v1UODjVHAJOeFE8vXunGM6q2DGqXyG gQUVX4GVRB+qLWG13twXbIVvPfVmME0fdJg8fxtLd0bV4yjWFY+og3t6b4xJ3uabsVrl FkhGzGXQu1IR3nUxTtfOQJ83wwckRBJwdWSiEVL3do3ZnOvHoqQ04MJVgKJORwwwlzjW IsSw== X-Gm-Message-State: AOJu0YxllD3nrziIs2Dgic9u4SksliEnlYz6/QHCnjofFaO+QyXdGrKw s46mEjhHJpzKuebkwwfYPnrBgZ5UxuPsC9GY0IN0b3hexet5Ki5GPb9KkVlMZ1U= X-Google-Smtp-Source: AGHT+IFI+QZhX9t88wBI0BG2my7wAq7GuidFmjDjGR70paVTgD0NZECmadhnw/9hJRtkCPCL6df37g== X-Received: by 2002:a05:6a00:80ce:b0:6de:3b41:2845 with SMTP id ei14-20020a056a0080ce00b006de3b412845mr1081770pfb.32.1707887660436; Tue, 13 Feb 2024 21:14:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVAXE/lMtHTK3L5UD7HWBbf5Yy4ikOEY6AEF4XiW9CVu3BIpykXC364tYTrAnzLAbdpnT68ccae/NtGSNDBJNPNw6RWOP0RneLJEP2ADc1M7JEjRflBjuj1dbHQThG9NvOt3JceHH/xLwiNODQZ0j9RTH3kV/p7UYv9yJxIIHU6IJFfoQ6yMXukZEG+DcmaK+scSaYLadp4pA1Q3gpejtAhsiMis0YXB4mncKCy5M2KBZdHtC9lgksZWUMVbIh6K2MXsVejC/lEXE0rvdwnjNmQiPify+6HNJ/0Jw8CuG8q6MZy3P3xLfT79RxdpzRawh48pgCIlOrFUMHaZ3Kwl+poBHOMZhYn0h50KgTRx4uJdoXl34yHYlb+Gisq1FG2CfTauEUIvcK+UwoCt2iKvacD/H1cNfOZBtQoNFEgrL0rqhxDom5sfkL/OquOiZ4= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:45 +0900 Subject: [PATCH v4 7/9] pcie_sriov: Release VFs failed to realize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-7-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x432.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=unavailable 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887750401100003 Release VFs failed to realize just as we do in unregister_vfs(). Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization = (SR/IOV)") Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 9ba34cf8f8ed..9d668b8d6c17 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -91,6 +91,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, vf->exp.sriov_vf.vf_number =3D i; =20 if (!qdev_realize(&vf->qdev, bus, errp)) { + object_unparent(OBJECT(vf)); + object_unref(vf); unrealize_vfs(dev, i); return false; } --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887698; cv=none; d=zohomail.com; s=zohoarc; b=nQkxUm+fejb7dvZOdgIIF3R0FPIzTn71Kd0MyOFp6sFGWCusEINsya7XLJwTEuT2HT+YRng6lfvL4tnFYgSPfPVDCyaLwY6aiUx7h9Wtue0MsAXLDbQI/uNFJ9D2rsjB3pePOkKd8do3514rjTc3Y36guk2Gbqq7Yha6F8AYVrw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887698; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5zPblC140h1Ee5DUGEevPBRRbeJIXN5dk7ADyGIIOUg=; b=hA/POa60LPY5pEFKjBN/G0WjeTy4HJ8UDD2LZenwv1cZRmPHdc14kf83byU/HDCGnI8yyoqvQmt4LGU/nEIKaT/Z7qqatOqlboM+QXbKrrxBcheICB5tjarCJYrRszs9dz61ybOnelZDWrBr1iGa++XygfOxIJCpP1rrQa2bfxA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887698288818.7121863225965; Tue, 13 Feb 2024 21:14:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7bM-0005vn-F5; Wed, 14 Feb 2024 00:14:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7bL-0005vL-3s for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:31 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7bI-0007uD-K9 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:30 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d911c2103aso25836525ad.0 for ; Tue, 13 Feb 2024 21:14:27 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id iw2-20020a170903044200b001db57e999dfsm408298plb.81.2024.02.13.21.14.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887665; x=1708492465; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5zPblC140h1Ee5DUGEevPBRRbeJIXN5dk7ADyGIIOUg=; b=VuKf7RkYcsI0gJrOq1Lap0GeZ5kWmvoAyvREYRlmvJbJCgrXIqPJL19GV6ePwrl+aT 4OzmAgLgkRN7rAUG5qLuZF/4z64nCIgwt0TTa9CZ5FT+podqd5XaJfaXJtBltkkoU5pR beqrczoo2CgPLFfKDQNkkewVKLxlrKQ7YInlZ5J5iO5iooNvJw1iHm9QiVA09+D4jlDQ FrvPA7KB+tlKehp8eDN6dfhi5TiRuNEL6J6qZO2MjLZ8hwa3/WiYOzvqmOb62vnrITyD 8I0CO3kwMCL63kDS7qn76qC/j0zbIY6bzyuFl4Q3gABo2hnZ8k3EZj+N/S0nooU3ekdf YQGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887665; x=1708492465; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5zPblC140h1Ee5DUGEevPBRRbeJIXN5dk7ADyGIIOUg=; b=qU/5pdtg3YrryxLcKTgPLZON1QAwIvqve6u86vNz+BAnknst5F58KXKmDFWYt9jSrc PO9l9lDSk6jLfNwSy9XRoZxfKuhu7LFOWfR5RUda2IBqCGdMOKS5CwPbuk3NDTMOEcV7 WLyXVlLXUG66GDVSXuAC97mTBODWjNiZJsdX7X2fJrUA2yJSKHmhFlg2x68XMr04vK0z x2RPYi3qBpCPCvKzv/cRMk2DX66tMCAob5xMUoBFHerOC7Xy/FECPt15o9ftaP6l+xLc 7ZOeZMcJEShvvqOcpBdVTT/xzKYZ6X77bJHsFEaz9Y+kPDU3oeCLXfnvUGGg+54mtigA MqvA== X-Gm-Message-State: AOJu0Yzq7lmEX3O+JtmZdx5QUDMfLag8Tm0G4b7PH4bh5rBS6LFR2Srl jexU7AJp6Mmf47MmL8Y3TkekvnE19cmS7Eek5fmtu3QKEeSnB8+wrvnGNRGnkRBwoqaD8B5CxbR t X-Google-Smtp-Source: AGHT+IEwa2mo30f+EVn/lnpF0N6aSWnTiryFCxVJ+ha05OyiotKvzCnH4arzVOIyYd58G5U7tqvuZA== X-Received: by 2002:a17:902:e74f:b0:1d9:626b:ae3d with SMTP id p15-20020a170902e74f00b001d9626bae3dmr2428312plf.18.1707887665104; Tue, 13 Feb 2024 21:14:25 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV7YeqgYPCUI2Edy+zFrh0YR4KHoh8FWPhQZwe3FOOEGJ2BtFYrRpiFgUK/Qzj5IAJoThVCnTRvcvENqz5X/Q2gI0ndFejzLuWdT6INHG7okPgB91Kw55K99DdU2PAgDzhW6y7tkMhgFiGEyEXNFPgBNVhhEiIcYVpPTwmY48K8UdmcY9Hr48cqVt+NsybfJwJW1ce/oFyHZsEydtsLAqYPh+Vwo6pq11U1SZhvyta+Djl4WbIAy3uBwo6Znkk9wLNMpe4CLbHplLM0u8FjDd67+F84o8wACVKnx/urmV2L+DrPwEZwgo1x7PN+M+tuzMsov8DaPbkeBTk+4NkFLpphOMg71WAWq4ju7Z+vhuULFrcDHKdXKAaqr1lQXc3Uzy+Z+7YDmlchTBKgaRmfPNmz37Mni31Ts0m23yzC3V9wUs0GV3X7A7iYTM0IJn4= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:46 +0900 Subject: [PATCH v4 8/9] pcie_sriov: Do not reset NumVFs after unregistering VFs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-8-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::629; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887700194100001 I couldn't find such a behavior specified. Signed-off-by: Akihiko Odaki --- hw/pci/pcie_sriov.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 9d668b8d6c17..410bc090fc58 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -209,7 +209,6 @@ static void unregister_vfs(PCIDevice *dev) pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } dev->exp.sriov_pf.num_vfs =3D 0; - pci_set_word(dev->config + dev->exp.sriov_cap + PCI_SRIOV_NUM_VF, 0); } =20 void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, --=20 2.43.0 From nobody Tue Nov 26 10:36:10 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 ARC-Seal: i=1; a=rsa-sha256; t=1707887769; cv=none; d=zohomail.com; s=zohoarc; b=Jgqasls1YShDgUtpsdG3ICOE6LHTMkAClF12UURPy9+g0MXit5uDZs1g8Ua7MPk7npvtR5A6Xf5C/e2nieo/ArV3AWQitJ94Ed/Iu8qYNee8PJJLrIQK3+hMcRiVP2qAhfNCazuh30YLgCV3vq3oLc9litWJVbBSZpJC1a1ohpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707887769; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fiPAxXFh2UsNlgKv2vLTmbdWvoiU4X8Pblc6jhDb2eQ=; b=RyVrxVseB1zoTbYu2n+Kki5WFImcIIljVPsKTg1C14aJnqWjLj2G+AX3eQd1wRqU7fzXxIO6DnfJDA0gqlSS6ZmQLS9bGFYQ8HQtXjQp7ltX8GZcYiQfNEih7QH/6Xza8mbQHF2+t/PnZmjm6DvvrfSb4dyngFC3401DBNebtyA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1707887769452605.0152650945631; Tue, 13 Feb 2024 21:16:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ra7bT-0005zi-Fq; Wed, 14 Feb 2024 00:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ra7bR-0005wp-UV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:37 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ra7bM-0007ur-7i for qemu-devel@nongnu.org; Wed, 14 Feb 2024 00:14:36 -0500 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5ce2aada130so4337790a12.1 for ; Tue, 13 Feb 2024 21:14:31 -0800 (PST) Received: from localhost ([2400:4050:a840:1e00:9ac7:6d57:2b16:6932]) by smtp.gmail.com with UTF8SMTPSA id ns1-20020a17090b250100b002970994278csm443432pjb.8.2024.02.13.21.14.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 21:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1707887670; x=1708492470; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fiPAxXFh2UsNlgKv2vLTmbdWvoiU4X8Pblc6jhDb2eQ=; b=hXNddgfLES/0bkIc/MnOCGtVNxWgTiT/paxfC3a9TzL0zccZuMMNSq96GxDbmCF/IH fxK1UVMwrPW0EjfPscdw6yH+gVm+RdrPkC5LF40zBL6OttWWkHXiI7t8RcUmqTo6NJ91 6Lhv/Z6yU+2hmyihFZuIz88S0IJApup3Bbs24Kt9G0BiweOcVTiWkOGVE9WglZ9TCczq AC4E4fqrRV5a0fyLzPhGwWRUanOyEZhOGoKkq75hdBk7WuwUVSMa5YatLEVfiFvCaox7 ziZdv9fj5U8oIy9v8Xrmwv74HaAQNi9c1XZQoO4waUp805Iqxr4RTZW2JWzZqYcaHLbh ttBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707887670; x=1708492470; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fiPAxXFh2UsNlgKv2vLTmbdWvoiU4X8Pblc6jhDb2eQ=; b=RMEH8ORvBftJG6Np6YuYtK3ZNhYEVZJbVVo05S4v8s5geDyZuP4ZAv/CPHXPJTgtSC KreMaMPzsHSbrfJ0G8pCLFVeANdYffV83Tlk0J61oQDPOMh/IgTmCpUH7rRrK7nN/zzH Dn+SKr4NwkGX1rs3n9BNLJ2Mc1Wa82lL1PXn/8R3rAl2c/wEcfSY1Cj2a9+j51tkRlg7 6bTEblQkgO4lVgzusMABInFQ48RS5S62PCTXTNaoS3dXqqBaElcPp7MMEnTPKqfwex9f Z4G39CrSGP5O6gxLBFpKMfl6eez2havRaY1g/eYpidv/K1ZieiWqPlMmo5opE6bWE4iW 8JYg== X-Gm-Message-State: AOJu0YxAzdbfiJzp+plYuOEFQ55eStgIO3kxD6luopRNb0cxlRxG9vXm MlPpY7gIZL+5rCi8XnVnY3HbcMGix0pc3PEEb3+pZtYyqKLTlFOF6sF6C+3gFM4= X-Google-Smtp-Source: AGHT+IHrTcZfLNyMj7tKRCffiwizk1wVp7ZvKL2PYKDrfE8wSyPqQTCWoa83ae7RUMoj3bvlNggpPQ== X-Received: by 2002:a17:90a:348d:b0:298:b0e3:b3fc with SMTP id p13-20020a17090a348d00b00298b0e3b3fcmr1553586pjb.26.1707887670312; Tue, 13 Feb 2024 21:14:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXgvc0WFvJ27f7zxQ5xkFdxLppnQz6AzbJ8KXi51DBsVJqvXllz7ukEvNZK9Km9/awIM4F3+u83eRDFGQFtTxWOJ5LDPwCt6Hc/Y79tRgAnedA8uLloLmjddETk0rKEgBuT4eUjOluaZoZ33YnQK/OOgXvH9zytQfs21NTr/viEAKBU3CCfkcGWOXMvggXKos+Fqk3p3eXIfvlDwscFMgkQAWtHAnzOEX3/RRhuBBp4MzR7+ID39W+G+QbCdrpT80lGHdRqA6sMiQEv49BXtKZ0HkU0fFe2ZAdgPcnuN+NRpcDdIQ+yQu/L/CHPQzcxxP7yRCbO/7Y8upXpxTV2IM1d75UyJEWHWgDFNsFu6kQlPzhI6R8o58/oSrOgNFGzTEutfrKeVIqmZ+mNqttU23hYXi2faeSTXHbFtAECfIXpDM8w6dfCCoMSFirWZiQ= From: Akihiko Odaki Date: Wed, 14 Feb 2024 14:13:47 +0900 Subject: [PATCH v4 9/9] hw/nvme: Refer to dev->exp.sriov_pf.num_vfs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240214-reuse-v4-9-89ad093a07f4@daynix.com> References: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> In-Reply-To: <20240214-reuse-v4-0-89ad093a07f4@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 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: none client-ip=2607:f8b0:4864:20::530; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1707887770212100008 NumVFs may not equal to the current effective number of VFs because VF Enable is cleared, NumVFs is set after VF Enable is set, or NumVFs is greater than TotalVFs. Fixes: 11871f53ef8e ("hw/nvme: Add support for the Virtualization Managemen= t command") Signed-off-by: Akihiko Odaki --- hw/nvme/ctrl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f8df622fe590..daedda5d326f 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8481,7 +8481,7 @@ static void nvme_sriov_pre_write_ctrl(PCIDevice *dev,= uint32_t address, NvmeSecCtrlEntry *sctrl; uint16_t sriov_cap =3D dev->exp.sriov_cap; uint32_t off =3D address - sriov_cap; - int i, num_vfs; + int i; =20 if (!sriov_cap) { return; @@ -8489,8 +8489,7 @@ static void nvme_sriov_pre_write_ctrl(PCIDevice *dev,= uint32_t address, =20 if (range_covers_byte(off, len, PCI_SRIOV_CTRL)) { if (!(val & PCI_SRIOV_CTRL_VFE)) { - num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_N= UM_VF); - for (i =3D 0; i < num_vfs; i++) { + for (i =3D 0; i < dev->exp.sriov_pf.num_vfs; i++) { sctrl =3D &n->sec_ctrl_list.sec[i]; nvme_virt_set_state(n, le16_to_cpu(sctrl->scid), false); } --=20 2.43.0