From nobody Sat Nov 15 17:08:38 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=1749018418; cv=none; d=zohomail.com; s=zohoarc; b=QowJIBN4uOj1jReZKgGY9qT//Ar4yxG5Bai5sbTm9xCW8L3bSNqKlcr52Us1fvS8Ww9/1tRuoXuaW7E6mwDu6/X9y6IfuL1r/C1bSAs88xtkcytg2EzKIDSbzkOPB6ae8QqViG6SRdzdPd3MCpZJxuW7kJJzVPcZMIh+GSIkU4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749018418; 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=w9dUYB3sXNj+/Azs414P3w6EcnJ8kp6x85t8QhaKBxc=; b=S8cOYEAilN//T7JheZFBRyTHIJ3//swqudzJiFbza/OAxemq2U73HgVlBnZTrYxdvg4o3SXuHVrOPnR3nr+2t69wqAz45qPcMqCubgs40QyhnBSTcgg+8++t48SboPJmLr6/aHBfbCegZ/eL36zvqVsTp1Hg1gyFirHKiHL9NOA= 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 174901841828257.878391557681084; Tue, 3 Jun 2025 23:26:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uMhZ7-00036T-Nl; Wed, 04 Jun 2025 02:25:33 -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 1uMhZ5-00036B-R4 for qemu-devel@nongnu.org; Wed, 04 Jun 2025 02:25:31 -0400 Received: from mgamail.intel.com ([198.175.65.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uMhZ2-0001ba-SM for qemu-devel@nongnu.org; Wed, 04 Jun 2025 02:25:31 -0400 Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2025 23:25:26 -0700 Received: from spr-s2600bt.bj.intel.com ([10.240.192.127]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2025 23:25:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749018329; x=1780554329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o0AmsQcPj4xV+MPQDwAQCn0gZWrRYxVnEnQFUs8pNyc=; b=JyADO+rl03nx6Azhld870oQZV53tEWr1iGAEUmRE8Hgb824uCPzWCCFZ FYGO6wWFk5XElJ4tsd2lkgs2JaEDMF6FwYhtY9Bv9ir3tln0Y0DlV74Wu Z5L4eWopg9brKoRRsVYIlEFCivZlPiVpe6DWb0D2dIzSogTsybinGO0VS RKdxxjZuSBykoefYzx+r/m4Lu8Ge5Xjc67Usyu6JxmR+dYzyWWOoK1qeV 7We0h/W4taSk4+z8Q943jDcDUuTFeGZrJqBfG7cweV33cEWetGk1ZkAVM dQ1d3CwE3q1fIw8oaK5JAdFYJz/dC6KrSN+LdiT3LRsJ4hzPo4G5puDj6 g==; X-CSE-ConnectionGUID: 0XMyZIOYTy+mX6zLdt0twg== X-CSE-MsgGUID: uzP8r2twRCCXKVRYz9qosA== X-IronPort-AV: E=McAfee;i="6700,10204,11453"; a="73614563" X-IronPort-AV: E=Sophos;i="6.16,208,1744095600"; d="scan'208";a="73614563" X-CSE-ConnectionGUID: FR2ty/p+Qt++YivWo2nQJg== X-CSE-MsgGUID: VBwo8NO8QXaOurfCwqMrYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,208,1744095600"; d="scan'208";a="145693593" 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, shameerali.kolothum.thodi@huawei.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 v3 4/4] vfio/iommufd: Save vendor specific device info Date: Wed, 4 Jun 2025 14:21:15 +0800 Message-Id: <20250604062115.4004200-5-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250604062115.4004200-1-zhenzhong.duan@intel.com> References: <20250604062115.4004200-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=198.175.65.9; envelope-from=zhenzhong.duan@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.128, 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_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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: 1749018419473116600 Content-Type: text/plain; charset="utf-8" Some device information returned by ioctl(IOMMU_GET_HW_INFO) are vendor specific. Save them as raw data in a union supporting different vendors, then vendor IOMMU can query the raw data with its fixed format for capability directly. Because IOMMU_GET_HW_INFO is only supported in linux, so declare those capability related structures with CONFIG_LINUX. Suggested-by: Eric Auger Suggested-by: Nicolin Chen Signed-off-by: Zhenzhong Duan Reviewed-by: Nicolin Chen Reviewed-by: Eric Auger --- include/system/host_iommu_device.h | 15 +++++++++++++++ hw/vfio/iommufd.c | 8 +++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/system/host_iommu_device.h b/include/system/host_iommu= _device.h index 809cced4ba..ab849a4a82 100644 --- a/include/system/host_iommu_device.h +++ b/include/system/host_iommu_device.h @@ -14,6 +14,13 @@ =20 #include "qom/object.h" #include "qapi/error.h" +#ifdef CONFIG_LINUX +#include "linux/iommufd.h" + +typedef union VendorCaps { + struct iommu_hw_info_vtd vtd; + struct iommu_hw_info_arm_smmuv3 smmuv3; +} VendorCaps; =20 /** * struct HostIOMMUDeviceCaps - Define host IOMMU device capabilities. @@ -22,11 +29,17 @@ * * @hw_caps: host platform IOMMU capabilities (e.g. on IOMMUFD this repres= ents * the @out_capabilities value returned from IOMMU_GET_HW_INFO i= octl) + * + * @vendor_caps: host platform IOMMU vendor specific capabilities (e.g. on + * IOMMUFD this represents a user-space buffer filled by ker= nel + * with host IOMMU @type specific hardware information data) */ typedef struct HostIOMMUDeviceCaps { uint32_t type; uint64_t hw_caps; + VendorCaps vendor_caps; } HostIOMMUDeviceCaps; +#endif =20 #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device" OBJECT_DECLARE_TYPE(HostIOMMUDevice, HostIOMMUDeviceClass, HOST_IOMMU_DEVI= CE) @@ -38,7 +51,9 @@ struct HostIOMMUDevice { void *agent; /* pointer to agent device, ie. VFIO or VDPA device */ PCIBus *aliased_bus; int aliased_devfn; +#ifdef CONFIG_LINUX HostIOMMUDeviceCaps caps; +#endif }; =20 /** diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index 3910b4b2b9..d3efef71af 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -839,16 +839,14 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice= *hiod, void *opaque, VFIODevice *vdev =3D opaque; HostIOMMUDeviceIOMMUFD *idev; HostIOMMUDeviceCaps *caps =3D &hiod->caps; + VendorCaps *vendor_caps =3D &caps->vendor_caps; enum iommu_hw_info_type type; - union { - struct iommu_hw_info_vtd vtd; - } data; uint64_t hw_caps; =20 hiod->agent =3D opaque; =20 - if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, - &type, &data, sizeof(data), + if (!iommufd_backend_get_device_info(vdev->iommufd, vdev->devid, &type, + vendor_caps, sizeof(*vendor_caps), &hw_caps, errp)) { return false; } --=20 2.34.1