From patchwork Sat Mar 8 23:09:08 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: 871627 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp348660wri; Sat, 8 Mar 2025 15:10:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQvloLeWjWIZKJTBkUx7ILLREj3Sv+ngZzugfX4X0ls9Wq/NoWkmZnsP9zg1MY+7CzbvUSeg==@linaro.org X-Google-Smtp-Source: AGHT+IHBx1iEV/uqMgloLlPCj/eAp7EiMIWO2P/p5s3K01UeVnuQ4ogT4B9v0jqAcJXlL0kDCxHi X-Received: by 2002:a05:6214:258f:b0:6e6:6598:84c1 with SMTP id 6a1803df08f44-6e900692cbamr126068996d6.42.1741475447980; Sat, 08 Mar 2025 15:10:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741475447; cv=none; d=google.com; s=arc-20240605; b=PgItFAKOUO5NrQYdHtdMsnjHC94vQ3TiMQ67BZBlJY/LbBEvMYJ0qohPR3aEkanAIK xBOwOkTtPjiozAKQy324acAKceZKo5JQH0stcJtcu3HAQNahe831cHGi8LKVwLS6YS6y TctlcAzwSIRiLDxNDhJIRcM8K50K7IogkU/robH2nm4WRqXELBrSQAA3DG913OWHx0cX KeX3PuA466sJlSy24zXyNNCtc9NagwtmzPHq+N1XWxmBur224TUvr37ODjM4xzpRY4yw YHJwTbDWWHWwfjE6IAHV0MUrxS9WryhighUQttiG3UZS+yCiSPzF3MjzuKesAmZlVZo+ eevw== 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=kqJ8O34qNgm7bETvjKnBNqBiS0iJjz9k+q/OCgWJZ8A=; fh=K+jvfEXLHI1+aHeREoW+qFHLwqI2jh7KnZNeFexCTwE=; b=jZoh/8QH5J46/ardtJPkCxxyOnciX4qBYjq98K3SDNbzNwzI/ixznantQIDWmkV0fe z4G15Lg4Xfjx+GhoE+dBCqTdWL2UGhjzAaBtX+IQ24GtSGLU0idtbA0BFFsOwpdfHJJz xISKW0p+66kjsutdDq9trl6VqZkQn55UoCVytIV7M5LBpUhNzrgVmFgp1xJYH3QOSnWs qQ/P0A8p1iUtiJ2pnvoun4Td3TVLedSFkJloCKpechfwigk1d79QqrJF945p2q+ZMA6G qa7BXxEjZE3HI2UpvTRPl/3pnXFQOZAQMVlr1vwtSjXviirgWyBPZKeM0SC7gmysKO7T JvpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WqHo1vIH; 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-6e8f7486f29si63401646d6.485.2025.03.08.15.10.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 08 Mar 2025 15:10:47 -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=WqHo1vIH; 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 1tr3JX-0006Pc-E0; Sat, 08 Mar 2025 18:10: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 1tr3JT-0006At-Py for qemu-devel@nongnu.org; Sat, 08 Mar 2025 18:10:35 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tr3JQ-0001To-LX for qemu-devel@nongnu.org; Sat, 08 Mar 2025 18:10:35 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-43cef0f03cfso1575455e9.3 for ; Sat, 08 Mar 2025 15:10:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741475431; x=1742080231; 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=kqJ8O34qNgm7bETvjKnBNqBiS0iJjz9k+q/OCgWJZ8A=; b=WqHo1vIHfSkmov+oBwrKtleKwtsA1oTL7gUL85Abp5pOQsyGjv5DPFMUDQAuHtwY/E d0dak797fPbl7I111olYR2ki6MmXif9i/ZWjbyKAH46Ov3iKkZ+3PHI0GxyXnoGoay/R S+V4pI7Yb/lAegqXVPPtmsNrwNBewdhRCxX4urmVmB488t0dEKr/+se7ZNTYrdSOkRN3 SOM8P8S0gdx2Ux3ED1LJT/cKnGG7moxM1DG08z9Ud1NXbg0RnQLuwvh/baO00EZgrGgM zWq6ucaov9xpacY6hz0mk54zdeg3wY8CT1HirYg6P+2k3ThPFgCK//IW2atTxqr2SVWU wQlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741475431; x=1742080231; 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=kqJ8O34qNgm7bETvjKnBNqBiS0iJjz9k+q/OCgWJZ8A=; b=c39iEGua3xhF3S8zp0RSJyES0CHUTHJZgX7uqf+YjM/EBhsdiMgIAB+1rxmYW1hQjl qggvhhbemJ2fp5R2SnOWAAb0cuqFM7GjXI1TSGTB+4k6Aqi5fLfQqLBR2S1dxbqP3KSV Q8l7NC5sJmKYWvcjVZmHXK5yGOVBjmC1uScgN//OwsshgipanK9uWwmQHT1serjoAWPw ouZ0KzhejT7nNwxl5TG86q7RmuV/i17BJvmzWyHhHTLsvzhurdrg2Z8OyNwH0ir8mQM6 42yWNMxqSnLFAb9i20U//Snfs1Qh4ORCKVCjUnITrv9B/tYKNhHLX4fw0SPu6/n2u0gh eiXg== X-Gm-Message-State: AOJu0Yz/Y6KH8wL5q47UJ0oDjNOJdgIXi/XJNVmAZlnBPATlnShsmCMO 5r2uuU5/P95DpQ6aRMSSrEgz3RUkjuev/kDdqfrV9D+cOEWfGORYswwYbSd/jq2BpaUVYxBKPGd xg8c= X-Gm-Gg: ASbGncv3wmvzFuLgMJpVCK2UOHKOgtYl0LRW57zZ8vOwPb8XnN7dXiw2Z/OEUjSFStJ zNbOWHNvLUvCzp8J+ufKbku3r3CsDcsa49odJ3p1eh2Da6GWSBYhAYm80zJjpYeNxM1HD+b3N7z s1cbMnsFDaA3ipBKeX7ALA5jBNlYvKOL6r8F+9KI1u2KvKbqxN+S4RrkXTY3/Zl2I1K8YLadh5t q4iQqaKDaWVxFwtOTdd2pH3BamQ259EWL0G/I24QvnJUyqrgs50Os1C1DwIr+yvM3QJljMYMmSk KDYMYEucMMhJvpZNBIF+Lb3+6L32r5gSTDhb/HD2CnSStL+hqABhsO0E+hdYy80TApfBgZi1eTN kpNRe4b9C0jxwEqoe5IU= X-Received: by 2002:a05:600c:35ca:b0:43b:ca8c:fca1 with SMTP id 5b1f17b1804b1-43c5a610dc3mr61655845e9.16.1741475430716; Sat, 08 Mar 2025 15:10:30 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912c0e2f10sm10124731f8f.65.2025.03.08.15.10.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 08 Mar 2025 15:10:30 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yi Liu , Pierrick Bouvier , Alex Williamson , Christian Borntraeger , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Tony Krowiak , Nicholas Piggin , Halil Pasic , Thomas Huth , David Hildenbrand , Igor Mammedov , Matthew Rosato , Tomita Moeko , qemu-ppc@nongnu.org, Daniel Henrique Barboza , Eric Farman , Eduardo Habkost , Peter Xu , kvm@vger.kernel.org, Zhenzhong Duan , qemu-s390x@nongnu.org, Eric Auger , Paolo Bonzini , Harsh Prateek Bora , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Ilya Leoshkevich , Jason Herne , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v2 12/21] hw/vfio/igd: Check CONFIG_VFIO_IGD at runtime using vfio_igd_builtin() Date: Sun, 9 Mar 2025 00:09:08 +0100 Message-ID: <20250308230917.18907-13-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250308230917.18907-1-philmd@linaro.org> References: <20250308230917.18907-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the compile time check on the CONFIG_VFIO_IGD definition by a runtime one by calling vfio_igd_builtin(), which check whether VFIO_IGD is built in a qemu-system binary. Add stubs to avoid when VFIO_IGD is not built in: /usr/bin/ld: libqemu-x86_64-softmmu.a.p/hw_vfio_pci-quirks.c.o: in function `vfio_bar_quirk_setup': /usr/bin/ld: ../hw/vfio/pci-quirks.c:1216: undefined reference to `vfio_probe_igd_bar0_quirk' /usr/bin/ld: ../hw/vfio/pci-quirks.c:1217: undefined reference to `vfio_probe_igd_bar4_quirk' Signed-off-by: Philippe Mathieu-Daudé --- hw/vfio/pci-quirks.h | 6 ++++++ hw/vfio/igd-stubs.c | 20 ++++++++++++++++++++ hw/vfio/pci-quirks.c | 9 ++++----- hw/vfio/meson.build | 3 +++ 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 hw/vfio/igd-stubs.c diff --git a/hw/vfio/pci-quirks.h b/hw/vfio/pci-quirks.h index fdaa81f00aa..dcdb1962600 100644 --- a/hw/vfio/pci-quirks.h +++ b/hw/vfio/pci-quirks.h @@ -13,6 +13,7 @@ #define HW_VFIO_VFIO_PCI_QUIRKS_H #include "qemu/osdep.h" +#include "qom/object.h" #include "exec/memop.h" /* @@ -71,4 +72,9 @@ extern const MemoryRegionOps vfio_generic_mirror_quirk; #define TYPE_VFIO_PCI_IGD_LPC_BRIDGE "vfio-pci-igd-lpc-bridge" +static inline bool vfio_igd_builtin(void) +{ + return type_is_registered(TYPE_VFIO_PCI_IGD_LPC_BRIDGE); +} + #endif /* HW_VFIO_VFIO_PCI_QUIRKS_H */ diff --git a/hw/vfio/igd-stubs.c b/hw/vfio/igd-stubs.c new file mode 100644 index 00000000000..5d4e88aeb1b --- /dev/null +++ b/hw/vfio/igd-stubs.c @@ -0,0 +1,20 @@ +/* + * IGD device quirk stubs + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (C) Linaro, Ltd. + */ + +#include "qemu/osdep.h" +#include "pci.h" + +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) +{ + g_assert_not_reached(); +} + +void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) +{ + g_assert_not_reached(); +} diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index c53591fe2ba..22cb35af8cc 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -11,7 +11,6 @@ */ #include "qemu/osdep.h" -#include CONFIG_DEVICES #include "exec/memop.h" #include "qemu/units.h" #include "qemu/log.h" @@ -1213,10 +1212,10 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr) vfio_probe_nvidia_bar5_quirk(vdev, nr); vfio_probe_nvidia_bar0_quirk(vdev, nr); vfio_probe_rtl8168_bar2_quirk(vdev, nr); -#ifdef CONFIG_VFIO_IGD - vfio_probe_igd_bar0_quirk(vdev, nr); - vfio_probe_igd_bar4_quirk(vdev, nr); -#endif + if (vfio_igd_builtin()) { + vfio_probe_igd_bar0_quirk(vdev, nr); + vfio_probe_igd_bar4_quirk(vdev, nr); + } } void vfio_bar_quirk_exit(VFIOPCIDevice *vdev, int nr) diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index a8939c83865..6ab711d0539 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -17,6 +17,9 @@ specific_ss.add_all(when: 'CONFIG_VFIO', if_true: vfio_ss) system_ss.add(when: 'CONFIG_VFIO_XGMAC', if_true: files('calxeda-xgmac.c')) system_ss.add(when: 'CONFIG_VFIO_AMD_XGBE', if_true: files('amd-xgbe.c')) +system_ss.add(when: 'CONFIG_VFIO_IGD', if_false: files( + 'igd-stubs.c', +)) system_ss.add(when: 'CONFIG_VFIO', if_true: files( 'helpers.c', 'container-base.c',