From patchwork Thu Jan 9 17:19:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 855991 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1340828wra; Thu, 9 Jan 2025 09:20:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX45FFVTLkcA0I5JKRN99crl6tWsEuEqQGCbktRFwENB0r9V7SB77P4nW2wSDjD0qaFAoN1nw==@linaro.org X-Google-Smtp-Source: AGHT+IHmM/jq48Z8+ufKb65feoPsQU747M3a2XNzDyPMvmj4U11tTUk0q0382unWC6HqxKivcg5h X-Received: by 2002:a05:620a:2890:b0:7b7:28c:dcd9 with SMTP id af79cd13be357-7bcd9717200mr1024473885a.29.1736443233617; Thu, 09 Jan 2025 09:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736443233; cv=none; d=google.com; s=arc-20240605; b=iwJMboaWlo685qUW9EeQiTglLfOKHdXVfQW7jq+t4z5b9J8jrRFmlFNdiyGsEtJ0eq S8qkijJbHv348H6qwrJVZG4/lRnuwM31ikiMVHZOU3hkMvQb9XruOMY1dZV6AnSvw82y 9Le6rwyyh/J8Y++cAjh+6ty24Lo7ZbNnF2jP8JK94nMCTE7f2BERI2e7R1vYj0vm+Wps hcdqGhkHoxTEs+UFDyiWImREof5bG9iUUx3KICM6a86yNZlSoIfCYumVnKG5R9cdK2mR hqwOX04sRAhn6y4rhQP0Rfe91V2ZlUPg43FKNMt2BETBTk8IKaSaWzq0QB5X/ZfYDaDP NaIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/Q9jLlzxL8Ky1CJr0jutwQaeChtyLfFwACEyWiRFh40=; fh=HgGJrWXVl3hYi88ajpLYsGB2pi3+kPNWC12fLzcpGeE=; b=lozMf4RJ8ZrGklbqX0r3hY2v5WdArIBZ0UrEUjS5huMjQW8hg2O70KLy3YoLvi6JwP zzsignwpSslYk0Jb9Zj0yPH8jAM0iiCsr7AZvTIzZBzM4q0syyIA/aEkoOiQSP9XUNt/ L4384POXz/ZuPOIlLg1cBudSdXSUJJS6nA2oGuy3qjV4yz1cBe01QtNwLZgLZldirjpP lyTenc+tP8VpsbDiUEf4nhsnhXRUJbNhTflb5kyDilaUn7B1D35q+PbupFHHlv3TCVoI 8NV1NuOJGBNLZBww+BDOUVHsKOPMrgRj4KXX2pd7fQJQbx+avmMR9HfmDpvZBcudOrKi aq/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=irH9t4Co; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dfadbc0298si742246d6.165.2025.01.09.09.20.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 09:20:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=irH9t4Co; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVwCQ-0002Ep-A3; Thu, 09 Jan 2025 12:20:02 -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 1tVwCN-0002EO-Hf for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:19:59 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVwCL-0000ab-Mg for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:19:59 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43623f0c574so9707295e9.2 for ; Thu, 09 Jan 2025 09:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736443195; x=1737047995; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/Q9jLlzxL8Ky1CJr0jutwQaeChtyLfFwACEyWiRFh40=; b=irH9t4Co6pOxpFCOCF/IhakaPR1LEoAdPcdxmwaq/K/ucONvE2PLblkDO0Qj0cVN6q vkaVw5y/GLJWx34Tnl0gq1Syk8WSoyu3drxFxWsxpodAfddt5WbBNSZ+ng+yoZVpNOiI 7eRNOKMzjUa6CSbjPMOy+O2yHKauOIUlqrorzlSXjk0jrVG+6XUtnSXtULqKa6Qergew IbUEEjnBSI+/sEmv8KdnbQaGhRdrlnBMlpJmdRKJLm7+QRi3R02ccR0+C8zNHgbU00ht dSM3RlvQiFJnE6XzUVBAXTF6hPEVHzYE1vodYJreKvgGovN7NfiuNTZIGISHhXqTS1ZZ n4iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736443195; x=1737047995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/Q9jLlzxL8Ky1CJr0jutwQaeChtyLfFwACEyWiRFh40=; b=qUI5EYpV5Ltc51rgMIJEeXd1M7aMP5nJFLZFowYB4FZVcF54jgk1zNMjqLWIKHYUfy 7JNOJVABKIU+1v/euCa9gXtZwKU9+MOQwZEsCpqJjGMrUFTyGmF1wwfUR/I49+qmwRLz mnkbBS5ttin+UGXmVr2m/Zp2idLoe2I4jScsIlLuClJ0FEMAt16XYsJ6yNQhTCET/i9H dFB3sJr86af2cDugyIpoAt1ldABC/ohVeGrfA8gv4uB+naijWzT6iyr7hEJGoG4PiJsA ZwTo96zTto578E06zT32K7AYjZ9vid6ghOaZ2jODwrxC/t6TLOisLPcdEknoj0JR9k1k +AyQ== X-Gm-Message-State: AOJu0YxBpgmeyDBPgFrEbnlo75I7WCOwwAaQe4oIiYDQvUpSWEF0G/rk 5ipEWtUwTDJAgcs6LGmZ+e9ZA8lm9GbNUPk0WJoYrea0az1OzzxJ0p33NjMYVYZT4b7ovBf94kK /hbU= X-Gm-Gg: ASbGncsdwsJIvfAkcJpANnHVy93SghIGY8JOewIvTuDnSrjIqgxZwQmnRgBYtkyUOW/ Xmp/S1sLUqfyXesruyRocfBaX2nBiIApyu6Lhw6morGFiOrDHz85+9Bzow05g56I5NezcF+9HVE KLXADgZCvk1TTnSxfq6PmGr3rHPsOePlBHkKdhs+QYt09QeAfIjtZZ/WGfMknINS1rpK4ZILers jw+OPxrfXPQ76uvPxKAFK6JdydoSOB8Htm+KUs3GIggjIrHcuF8tQWBeBk2LW8vwFtSbYWLlkzw GzaewqrnSYlZgyiG8A6N+Z8Gqx0qBZD8ci2R X-Received: by 2002:a05:600c:3505:b0:434:a7b6:10e9 with SMTP id 5b1f17b1804b1-436e26a9045mr74163005e9.17.1736443195346; Thu, 09 Jan 2025 09:19:55 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9e37d74sm26954385e9.29.2025.01.09.09.19.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jan 2025 09:19:54 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 01/11] hw/pci: Use -1 as the default value for rombar Date: Thu, 9 Jan 2025 18:19:38 +0100 Message-ID: <20250109171948.31092-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109171948.31092-1-philmd@linaro.org> References: <20250109171948.31092-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.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, 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Akihiko Odaki vfio_pci_size_rom() distinguishes whether rombar is explicitly set to 1 by checking dev->opts, bypassing the QOM property infrastructure. Use -1 as the default value for rombar to tell if the user explicitly set it to 1. The property is also converted from unsigned to signed. -1 is signed so it is safe to give it a new meaning. The values in [2 ^ 31, 2 ^ 32) become invalid, but nobody should have typed these values by chance. Suggested-by: Markus Armbruster Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20250104-reuse-v18-13-c349eafd8673@daynix.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 2 +- hw/vfio/pci.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 8eaf0d58bb3..16ea7f4c19b 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -148,7 +148,7 @@ struct PCIDevice { uint32_t romsize; bool has_rom; MemoryRegion rom; - uint32_t rom_bar; + int32_t rom_bar; /* INTx routing notifier */ PCIINTxRoutingNotifier intx_routing_notifier; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b6c630c3236..78907527f2e 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -85,7 +85,7 @@ static const Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), - DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), + DEFINE_PROP_INT32("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, diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 17080b9dc0b..ab17a98ee5b 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 = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK); off_t offset = vdev->config_offset + PCI_ROM_ADDRESS; - DeviceState *dev = DEVICE(vdev); char *name; int fd = vdev->vbasedev.fd; @@ -1046,12 +1045,12 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) } if (vfio_opt_rom_in_denylist(vdev)) { - if (dev->opts && qdict_haskey(dev->opts, "rombar")) { + if (vdev->pdev.rom_bar > 0) { warn_report("Device at %s is known to cause system instability" " issues during option rom execution", vdev->vbasedev.name); error_printf("Proceeding anyway since user specified" - " non zero value for rombar\n"); + " positive value for rombar\n"); } else { warn_report("Rom loading for device at %s has been disabled" " due to system instability issues",