From nobody Sun Nov 16 11:14:46 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1741370847; cv=none; d=zohomail.com; s=zohoarc; b=gtpuu2pvxfQxBH7jv5NG4aaTTMBSra5LzLKvEfhPJ/laRiKuCx0QPDSGuT+CstSzh+neyxXszKFKIpAcJ0ZH5WBRJJDWsK069VQwAovKkDtEeyG2DKuOXzSiRJ9pFOKE4hYN5ehq6WgLRitdqwUEKZZkW8F4XgsynCl+VTGrQts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741370847; 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=otdB0Dz5nRAMnlnyGAk6/GxyQibbHb9x6DFoSBTI7l0=; b=m6f/sW1HmRTWTEm33UIzADokiAyflDpCNwN5b+zujyNmthNvxQ74AHSLpWCf1dwfhgYOLDLLlC5dsfI//vXRrM2rdIcEjDmosQSsdDv4jQX85PqPFuBRhesxlMIQBvEd2JWG4NyaXaMj69/O8wxhCRIbtoQhx3zLmp3dKqoXY70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741370847596445.2359530678548; Fri, 7 Mar 2025 10:07:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tqc5f-0006YY-Vc; Fri, 07 Mar 2025 13:06:32 -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 1tqc3x-0004LL-Kc for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:46 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqc3u-0002Ia-K4 for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:45 -0500 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-390e702d481so1168656f8f.1 for ; Fri, 07 Mar 2025 10:04:42 -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-43bdd8b0425sm58830765e9.3.2025.03.07.10.04.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Mar 2025 10:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741370681; x=1741975481; 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=otdB0Dz5nRAMnlnyGAk6/GxyQibbHb9x6DFoSBTI7l0=; b=Tvs8+1q8i7N+avAe1w9JySLJKId9LqyaNg12JeYnWit2UTki8AozYf19g/FM1rGHCC HQCn2yPAoC1uRqFzZrXKCMyhuRWM8Cu+dj7XuOlV5h+4xDP3eOYTHAWCoypeSu+Lgijr 0AHZdPZmW6uTZm/1HLK4siNrv9KwUoIGmrc774WrPoJnYekReo0EYi/jJ3WE6q3xaScK hNveDEfe5bWJ9xK7UsQ1pW3aimm6PKl92Aah2q85wUZd3QO/VkxHJjps2kfCP/lmx3oG JcZb2l4GH1OSLeFUZRkkwWU1u7crDpETYUg4dYOvZTEvqjcnpkeebjx17JxCCj4FnAWM ymgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741370681; x=1741975481; 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=otdB0Dz5nRAMnlnyGAk6/GxyQibbHb9x6DFoSBTI7l0=; b=Mcl8zjK/bt7V3q6QtMjPtM61zgl1J2tZ2cC0mcxBshMm+zBKg/To8fpHCjH2U7IzcN r/SvFoz6T6KbAB/qxtV+OhPhq1o/5Rs9Us7zqMA/rYwCnzMzYY0/2z3CMBjsBBuFrHsX 5o8JulGp8Ri/mLpLqlPPdBrvnmFaLwaoCJYVmz+hGHQMbeGAMDQZhJzg8q6gxQRLPsR+ xEBrHmI8IWnCCghKmj93H1AHs9xmP4vjww/fPI7PxqsNsVZfPov62qZug4TxV0TY8XND /3Vbqk22AUOtthrx89SsXMXqK7kDxoOJ+XlNLrcBHD13Cgyj0PD2Vt017wgyyojilGtx dmVQ== X-Gm-Message-State: AOJu0YwCBY7tiIOB52/HL9OWmw+P1SrpJCFUDsRy3YfqwDhZtm8GOtwE sM9cpB7Nk6ekmIZOKIRabtyn5AyyInrlLsETrLUM4PA+TIs99fhQkZ8e3uXiOpTZBhDLLP8dCbt /xtM= X-Gm-Gg: ASbGncs7CSLUZ80WXwl3djVYxsJIYF2x8aVVnHxFaUEEKaa1Ysw3AcWN7rwOThJ8GPb Qzb+v9uA6X5E3eiqOGebuigPUScnCKK+2ptMEifQNsPjpH/Dr8SlKDuspCvUg7vxI3Nc+ZYKXEh pYLrNw5AkPAeeSQap/lug7MTOLwy4veEbqj6FuIVf6WwUHrZmQ9bWMRnwWA6ryiERUPCq6C09sX bDd+EW6FeujlfQQYHDbWEMyGS46tIITIGXYtQQOc/LU60xTrl6zSF87ppC4hwIe9uhbMDir3kuM zWzbBmahRLHNmqRR4I8E3OmYnSCiMtwm4vmro8i2keN6HGwqqka35LTeTD0b4o7bUge1H5IQzdW nOQHsj8a+vF4WlzQqWIM= X-Google-Smtp-Source: AGHT+IGoXSQiYR+Znceq9QhV/DA24dcXDFRGzeqHnWry6oSbt2EZw73v5ZrTBEMEOa+RqbZY3pfWWQ== X-Received: by 2002:a05:6000:4112:b0:391:d52:d042 with SMTP id ffacd0b85a97d-39132d883f3mr2410120f8f.32.1741370680523; Fri, 07 Mar 2025 10:04:40 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Igor Mammedov , qemu-ppc@nongnu.org, Thomas Huth , Richard Henderson , Tony Krowiak , Ilya Leoshkevich , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , kvm@vger.kernel.org, Yi Liu , Paolo Bonzini , Zhenzhong Duan , Matthew Rosato , Eric Farman , Peter Xu , Pierrick Bouvier , Daniel Henrique Barboza , Eric Auger , qemu-s390x@nongnu.org, Jason Herne , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Hildenbrand , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Harsh Prateek Bora , Nicholas Piggin , Halil Pasic , Christian Borntraeger Subject: [PATCH 11/14] hw/vfio/pci: Check CONFIG_IOMMUFD at runtime using iommufd_builtin() Date: Fri, 7 Mar 2025 19:03:34 +0100 Message-ID: <20250307180337.14811-12-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250307180337.14811-1-philmd@linaro.org> References: <20250307180337.14811-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1741370848800019100 Convert the compile time check on the CONFIG_IOMMUFD definition by a runtime one by calling iommufd_builtin(). Since the file doesn't use any target-specific knowledge anymore, move it to system_ss[] to build it once. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- hw/vfio/pci.c | 38 ++++++++++++++++++-------------------- hw/vfio/meson.build | 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 9872884ff8a..e83252766d1 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -19,7 +19,6 @@ */ =20 #include "qemu/osdep.h" -#include CONFIG_DEVICES /* CONFIG_IOMMUFD */ #include #include =20 @@ -2973,11 +2972,10 @@ static void vfio_realize(PCIDevice *pdev, Error **e= rrp) if (!(~vdev->host.domain || ~vdev->host.bus || ~vdev->host.slot || ~vdev->host.function)) { error_setg(errp, "No provided host device"); - error_append_hint(errp, "Use -device vfio-pci,host=3DDDDD:BB:D= D.F " -#ifdef CONFIG_IOMMUFD - "or -device vfio-pci,fd=3DDEVICE_FD " -#endif - "or -device vfio-pci,sysfsdev=3DPATH_TO_DEVI= CE\n"); + error_append_hint(errp, "Use -device vfio-pci,host=3DDDDD:BB:D= D.F %s" + "or -device vfio-pci,sysfsdev=3DPATH_TO_DEVI= CE\n", + iommufd_builtin() + ? "or -device vfio-pci,fd=3DDEVICE_FD " : ""= ); return; } vbasedev->sysfsdev =3D @@ -3412,19 +3410,18 @@ static const Property vfio_pci_dev_properties[] =3D= { qdev_prop_nv_gpudirect_clique, uint8_t), DEFINE_PROP_OFF_AUTO_PCIBAR("x-msix-relocation", VFIOPCIDevice, msix_r= elo, OFF_AUTO_PCIBAR_OFF), -#ifdef CONFIG_IOMMUFD - DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, - TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), -#endif DEFINE_PROP_BOOL("skip-vsc-check", VFIOPCIDevice, skip_vsc_check, true= ), }; =20 -#ifdef CONFIG_IOMMUFD +static const Property vfio_pci_dev_iommufd_properties[] =3D { + DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd, + TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *), +}; + static void vfio_pci_set_fd(Object *obj, const char *str, Error **errp) { vfio_device_set_fd(&VFIO_PCI(obj)->vbasedev, str, errp); } -#endif =20 static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) { @@ -3433,9 +3430,10 @@ static void vfio_pci_dev_class_init(ObjectClass *kla= ss, void *data) =20 device_class_set_legacy_reset(dc, vfio_pci_reset); device_class_set_props(dc, vfio_pci_dev_properties); -#ifdef CONFIG_IOMMUFD - object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd); -#endif + if (iommufd_builtin()) { + device_class_set_props(dc, vfio_pci_dev_iommufd_properties); + object_class_property_add_str(klass, "fd", NULL, vfio_pci_set_fd); + } dc->desc =3D "VFIO-based PCI device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->realize =3D vfio_realize; @@ -3540,11 +3538,11 @@ static void vfio_pci_dev_class_init(ObjectClass *kl= ass, void *data) "vf-token", "Specify UUID VF token. Required= for VF when PF is owned " "by another VFIO driver"); -#ifdef CONFIG_IOMMUFD - object_class_property_set_description(klass, /* 9.0 */ - "iommufd", - "Set host IOMMUFD backend device= "); -#endif + if (iommufd_builtin()) { + object_class_property_set_description(klass, /* 9.0 */ + "iommufd", + "Set host IOMMUFD backend de= vice"); + } object_class_property_set_description(klass, /* 9.1 */ "x-device-dirty-page-tracking", "Disable device dirty page track= ing and use " diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index 96e342aa8cb..9a004992c11 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -6,7 +6,6 @@ vfio_ss.add(files( vfio_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr.c')) vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( 'pci-quirks.c', - 'pci.c', )) vfio_ss.add(when: 'CONFIG_VFIO_CCW', if_true: files('ccw.c')) vfio_ss.add(when: 'CONFIG_VFIO_PLATFORM', if_true: files('platform.c')) @@ -29,4 +28,5 @@ system_ss.add(when: ['CONFIG_VFIO', 'CONFIG_IOMMUFD'], if= _true: files( )) system_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( 'display.c', + 'pci.c', )) --=20 2.47.1