From nobody Mon Oct 27 13:52:29 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1761295621; cv=none; d=zohomail.com; s=zohoarc; b=Wf2LXXS0QMAm5OeBkbljYgfctcpWVDJ3B5OKvAY6whGTcnXw+kyGDKgf+zluEnp1ZybHshmP5tgqf14dqEV28o0Nbyao2H6psuD9JWpbZ0SSeKPvNkGzjbRACfGtLom/yfMVvMhW/khY6Q2u25Me5R++nTt5CQMUkDcRfV/NadQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761295621; h=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=qcBssjuN02YIFcSH4HSkqfs3+oubU//OTHxOz+tXwYY=; b=k1jwY56zfDTOeyiesgmZRo7Ss8bwL6edcCYwmCAVzGMYzKjECS+PnoBTX29Zc5oD7hqdc3Yh++t/5ZM8OgK3hj9HB/Sw8uc3e4kcesXrnSNRNhuTKaIIxVEX6d38S8nBaaJgnCelJpiub5cSLZNb7bil027qdHg8tDrK+Nd5wRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1761295621259701.0780312307734; Fri, 24 Oct 2025 01:47:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vCDR0-0006GW-Pz; Fri, 24 Oct 2025 04:46:06 -0400 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 1vCDQp-00068n-Hx for qemu-devel@nongnu.org; Fri, 24 Oct 2025 04:45:56 -0400 Received: from mgamail.intel.com ([192.198.163.19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vCDQn-0006Vx-Go for qemu-devel@nongnu.org; Fri, 24 Oct 2025 04:45:55 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2025 01:45:43 -0700 Received: from unknown (HELO gnr-sp-2s-612.sh.intel.com) ([10.112.230.229]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2025 01:45:39 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1761295554; x=1792831554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G9NYNT/BTF1+pHfUhU7z1uUhIj/5SiXz+/P9BecLONY=; b=VbH51TJHJ1QNnBLeWDwe9nSS74Ki8o0+2f2BXAuCvbhJZmq4a2o6p+LN oWu9qXbowDORjflvvPXqmw5I2ufs61imHqgRQYDg0QfvRiBJxeefsFk1j ZF3e4W0E0DRRVUh4Ew2lci0BA02JlKh8nQadn7e5Ytg5hq1AJqOxurHlY jICID2XTa1WoUwXy1wXnEqBwiWDMc79MP3x71236SJsicymcWlhWTmbEE iHHnHZTSVVmVrdu9iUbnvuOOBcFbs+LbOT9LT51ax8vROm9jAKrsRAZkg 72GzmQAwcts50JEyH6dY2rsygdJzuDGSaf84mpBHGa9wjxQAL2IB2lmm4 Q==; X-CSE-ConnectionGUID: 54rd9rX2TzGMo1skoE31Qw== X-CSE-MsgGUID: 3tcaSLqpSm2MNOzaaYngcg== X-IronPort-AV: E=McAfee;i="6800,10657,11586"; a="62504897" X-IronPort-AV: E=Sophos;i="6.19,252,1754982000"; d="scan'208";a="62504897" X-CSE-ConnectionGUID: vJ5EwJMrQF6cdvJSE4pwXg== X-CSE-MsgGUID: 1WoXB/qmRBeQ8INXgAhZ3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,252,1754982000"; d="scan'208";a="183986024" From: Zhenzhong Duan To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, clg@redhat.com, eric.auger@redhat.com, mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, ddutile@redhat.com, jgg@nvidia.com, nicolinc@nvidia.com, skolothumtho@nvidia.com, joao.m.martins@oracle.com, clement.mathieu--drif@eviden.com, kevin.tian@intel.com, yi.l.liu@intel.com, chao.p.peng@intel.com, Zhenzhong Duan Subject: [PATCH v7 17/23] iommufd: Introduce a helper function to extract vendor capabilities Date: Fri, 24 Oct 2025 04:43:41 -0400 Message-ID: <20251024084349.102322-18-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20251024084349.102322-1-zhenzhong.duan@intel.com> References: <20251024084349.102322-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 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=192.198.163.19; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1761295625891158500 Content-Type: text/plain; charset="utf-8" In VFIO core, we call iommufd_backend_get_device_info() to return vendor specific hardware information data, but it's not good to extract this raw data in VFIO core. Introduce host_iommu_extract_quirks() to help extracting the raw data and return a bitmap in iommufd.c because it's the place defining iommufd_backend_get_device_info(). The other choice is to put vendor data extracting code in vendor vIOMMU emulation file, but that will make those files mixed with vIOMMU emulation and host IOMMU extracting code, also need a new callback in PCIIOMMUOps. So we choose a simpler way as above. Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: Nicolin Chen --- include/hw/iommu.h | 5 +++++ include/system/host_iommu_device.h | 15 +++++++++++++++ backends/iommufd.c | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/include/hw/iommu.h b/include/hw/iommu.h index 9b8bb94fc2..6d61410703 100644 --- a/include/hw/iommu.h +++ b/include/hw/iommu.h @@ -22,4 +22,9 @@ enum viommu_flags { VIOMMU_FLAG_WANT_NESTING_PARENT =3D BIT_ULL(0), }; =20 +/* Host IOMMU quirks. Extracted from host IOMMU capabilities */ +enum host_iommu_quirks { + HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO =3D BIT_ULL(0), +}; + #endif /* HW_IOMMU_H */ diff --git a/include/system/host_iommu_device.h b/include/system/host_iommu= _device.h index ab849a4a82..9ae7f4cc6d 100644 --- a/include/system/host_iommu_device.h +++ b/include/system/host_iommu_device.h @@ -39,6 +39,21 @@ typedef struct HostIOMMUDeviceCaps { uint64_t hw_caps; VendorCaps vendor_caps; } HostIOMMUDeviceCaps; + +/** + * host_iommu_extract_quirk: Extract host IOMMU quirks + * + * This function converts @type specific hardware information data + * into a standard bitmap format. + * + * @type: IOMMU Hardware Info Types + * + * @VendorCaps: IOMMU @type specific hardware information data + * + * Returns: bitmap with each representing a host IOMMU quirk defined in + * enum host_iommu_quirks + */ +uint64_t host_iommu_extract_quirks(uint32_t type, VendorCaps *caps); #endif =20 #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device" diff --git a/backends/iommufd.c b/backends/iommufd.c index 086bd67aea..61b991ec53 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -19,6 +19,7 @@ #include "migration/cpr.h" #include "monitor/monitor.h" #include "trace.h" +#include "hw/iommu.h" #include "hw/vfio/vfio-device.h" #include #include @@ -411,6 +412,18 @@ bool iommufd_backend_get_device_info(IOMMUFDBackend *b= e, uint32_t devid, return true; } =20 +uint64_t host_iommu_extract_quirks(uint32_t type, VendorCaps *caps) +{ + uint64_t quirks =3D 0; + + if (type =3D=3D IOMMU_HW_INFO_TYPE_INTEL_VTD && + caps->vtd.flags & IOMMU_HW_INFO_VTD_ERRATA_772415_SPR17) { + quirks |=3D HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO; + } + + return quirks; +} + bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id, uint32_t data_type, uint32_t entry_l= en, uint32_t *entry_num, void *data, --=20 2.47.1