From patchwork Fri Mar 7 18:03:33 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: 871220 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp894632wri; Fri, 7 Mar 2025 10:05:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW9LZvin6vVcRCZI8gHihUOngHE+wJ+uRAY6zcLlbpPBeC+3h0ULDeCpBGNM3Pmtj4V5MP4oQ==@linaro.org X-Google-Smtp-Source: AGHT+IGhoyyhJrB0+7Vd+Q/l++xKtCdkxrfSCbFPZXVT+QL5rWiVMIoY567XUC3YEOIc3yoPVFuX X-Received: by 2002:a05:620a:8908:b0:7c3:ceeb:7d4f with SMTP id af79cd13be357-7c4e6199c12mr687025485a.51.1741370749895; Fri, 07 Mar 2025 10:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741370749; cv=none; d=google.com; s=arc-20240605; b=UhXEmTKITR5ToFwXFyjBq5EmbMPGcLwniBUQJXHz2e/HLV484swbDdWlSOSava9Rhy qJuTTCVcgUGJ/xcfO/cRUbGai6GjHzTig58goN0mq7TFqctq/VdylyaUmb5H+2prTb5B vhY7viCtjPI3upgxlViaalwD4j3jT/2iWUwNPBJMAInYwJHQrDqTD4Dr3aiOO77tIMna WAC1MyTJczsCj+3T9E8Url3HSa0wsSwO3EfPc38XMR6RHGb1xvk7WcwrLkSiN2Xh8LQN 8yG2N4oxNFE5U7UUdn0d1EiBsdz202Dn/ftnzogl8p81osYODaYKQTKYslfzHlGoAmwO 0tDQ== 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=jwX1K0+iQl31BRmPX8xi9KD5c4T56nkQjSQYXLzdF0A=; fh=ZyzqLhNGJAXkYZjVqygzIY1NON/Kumlz+Vm/jUj6bQE=; b=Ya/6Q4Zrq0MpKbnL5AFHK69mg/N9wWEsqvDNaCGzLHStzN5GOvnOVaC/JLNRP2Tbmm K2C+AYiBSiSH4MumyZdLldElYL1xRzN2hxjrQ6rq0ELcBglaF71RfsaHwh0ylcZ9cLSV ZsMgZYyNmZ72ypO6jD+1qXzC/LPJK2u5lwiKYzFcIUK96Bhp3a39Xy5xGpKMtGC+8MX9 anFgRUeX9FTFtx+F94+cdvmZxpTdbGgF4uMbgZje7VKhczTKJerrcmmccR3e8aot5Pk1 nZQzwVCqqrXo4dRoDRo6TpjdTc5ReiN28WsSYxapf5EIqVNi0c+riMsI4xVY7Og6eRNE Ww0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FsaGK+bY; 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 af79cd13be357-7c3e533b6e0si397904185a.121.2025.03.07.10.05.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 10:05:49 -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=FsaGK+bY; 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 1tqc4f-00052v-9h; Fri, 07 Mar 2025 13:05:35 -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 1tqc3s-0004FE-83 for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:40 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqc3p-0002GQ-7h for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:04:39 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4394a823036so18351005e9.0 for ; Fri, 07 Mar 2025 10:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741370675; x=1741975475; 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=jwX1K0+iQl31BRmPX8xi9KD5c4T56nkQjSQYXLzdF0A=; b=FsaGK+bYWMrrh1VO/iXLetGyjlNAB0rEFx8h9NyObQsRr6MS2DfTywFCRUkVvOIcGt +DIs3wJQTNioNiisTopZ+5iyTWkIoRsUZ+ALNIVb8Ec20ZD5W1vRxz850koLIAoYd4y6 o1Z58s/32fdXayGgmPpS4np3kTxQiRlAY5AvkulUGiEx+aSaiHAserAAlqo1BAI/UpL7 4vvZVnG9k2Ik0QVWLvBbnhJ7GTx75sjSiHm0xGdW1jTYeO5/I+lkLBgVjOiH7H/WXEKC +lgPvcxwERvxAH4GPZpprbgP7WThhj9+pJ4g4GR8QyTafwzDDz7pfQzEIl9MKqbBVdJn AKyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741370675; x=1741975475; 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=jwX1K0+iQl31BRmPX8xi9KD5c4T56nkQjSQYXLzdF0A=; b=sSR/rFklsuREpW9wiTEsfEgX46fFQunSiGXJUZK5RoD44OT+DVXmQh2Jgk4RIkgtjC 8OOGElHrG9q+KAV6lc8vsURlkyIviuIlpJEJ7OAfG82a+idsyCovkXBm6HmRwtrGXVqS G89VzbYzeRm44yVavP59msIE4Io5G4Wyk/DnmLEBsEITXZuyPec6fuezB+d0nByOCNx5 U+AOMVQBOY768QqhIAqgI3e5ponWOBX7wYkNojPMRq0I8PV2qvg85CzQIXC8M+6KqExx BoKW1Hz/B6Juy2/PDt22gLsJu7nIO4ca1+kUcz4hzvvAH9adpgI+/JQUUpF1jHh/Z+f+ YlMg== X-Gm-Message-State: AOJu0YzgQFDehffAtH4O1+wOksbWmkXTxq6iIM38qtxwQcDfpVFyxURY lg7SMwqHLtp+icyErwgKVpifhs4+vKSASTc4ZEeJjVCqyTl/uuD7jSx7uepRBPXwNTNUtReCED3 iAe0= X-Gm-Gg: ASbGncsEXp3Ypc6kfrm/kYA2vOFm6HMvyM3ys9zL/j9Ld24ZO5Lq0X5Ejoc2zlPBGr4 Al1NaQm5zvNhcJbK4CFZ4yu9GClv2cC9lLqCo4KRNGAG+9Qgjs+uk2gZ8n3JT811udcwHegipxI +Au08cB2vkuJbYWAdOKPXWMOGGlYhQdJSMC+CGKWYBVpBVp5bH8pAo/iAxNiiqxJ/c6QpEwv3xB ZfC+H4RNoHLgnqHEyQxkOY+7NDXaSkEn5urncb6LyWu9buJagvngIPejNbhJNmAqTDV8yqTBW7j Y/5fuWL1PIHabNBynka6D9mC+o3Gbrzdv22pveKw52ON2u5IRDx7eick+Bs4NDshOFxsGaoFrxZ KsZKieqO5dVG4v9iwXBY= X-Received: by 2002:a05:600c:350a:b0:439:86fb:7326 with SMTP id 5b1f17b1804b1-43c602082a0mr29865065e9.22.1741370675155; Fri, 07 Mar 2025 10:04:35 -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-43bdd8db6c7sm58089865e9.22.2025.03.07.10.04.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 07 Mar 2025 10:04:34 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-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_Mathieu-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_Le_Goater?= , David Hildenbrand , =?utf-8?q?Alex_Benn=C3=A9e?= , Harsh Prateek Bora , Nicholas Piggin , Halil Pasic , Christian Borntraeger Subject: [PATCH 10/14] system/iommufd: Introduce iommufd_builtin() helper Date: Fri, 7 Mar 2025 19:03:33 +0100 Message-ID: <20250307180337.14811-11-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 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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 iommufd_builtin() can be used to check at runtime whether the IOMMUFD feature is built in a qemu-system binary. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- docs/devel/vfio-iommufd.rst | 2 +- include/system/iommufd.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/devel/vfio-iommufd.rst b/docs/devel/vfio-iommufd.rst index 3d1c11f175e..08882094eee 100644 --- a/docs/devel/vfio-iommufd.rst +++ b/docs/devel/vfio-iommufd.rst @@ -88,7 +88,7 @@ Step 2: configure QEMU ---------------------- Interactions with the ``/dev/iommu`` are abstracted by a new iommufd -object (compiled in with the ``CONFIG_IOMMUFD`` option). +object (which availability can be checked at runtime using ``iommufd_builtin()``). Any QEMU device (e.g. VFIO device) wishing to use ``/dev/iommu`` must be linked with an iommufd object. It gets a new optional property diff --git a/include/system/iommufd.h b/include/system/iommufd.h index cbab75bfbf6..ce459254025 100644 --- a/include/system/iommufd.h +++ b/include/system/iommufd.h @@ -63,4 +63,12 @@ bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id, Error **errp); #define TYPE_HOST_IOMMU_DEVICE_IOMMUFD TYPE_HOST_IOMMU_DEVICE "-iommufd" + +static inline bool iommufd_builtin(void) +{ + bool ambig = false; + + return object_resolve_path_type("", TYPE_IOMMUFD_BACKEND, &ambig) || ambig; +} + #endif