Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1499726rdb; Mon, 8 Jan 2024 00:38:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEW/B7Jkko7AngnQ8YbDsp4n3ALVPW6HUd+hDorfou6lt3iE4Zd54UyIXwBplxNL/sizD9M X-Received: by 2002:a17:90a:f285:b0:28c:d8d:e05d with SMTP id fs5-20020a17090af28500b0028c0d8de05dmr1485239pjb.39.1704703081516; Mon, 08 Jan 2024 00:38:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704703081; cv=none; d=google.com; s=arc-20160816; b=JNoXyXpkI7GmYl6/1gJeIOisGJck9esieN8aHXBxUHaeYosBTbbbwOAYlzO5O0ZLDQ zA6CJfVaDUx1ovkfUoIPz/fXH0tkMOoqYQ0M+F7ydQq2zWQIyZVO5YQ7m6Ec0PBhr5Eh Gp6lX1UY7VcLDmXidBBB/Elwta26kMnn1PyPkW036K5HQkSQOtfyfMZvm0HeBnHPCcwm zs2gbYVFV/EmnkiO2YhEOl8zOxdWtxn5Lm7xyEKNf8AqGPNsF1Scf+t0lfD1813FOT7R ROVuO2YZocK3pDgVzblpQIHi+SFl7DIrZleTyoIjtrk+GrLs27aMawV+VOUFPxzAY08e rxPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=UmcfGaWpp8A2m5gPAf+XPJ+HW+RVp5b65Qm6yg0j8ws=; fh=VI3lusHnoYmAUssX/lMdLWGpdXMarreLGnKhJX5yWAo=; b=ADPK97vkYNYVXpFYhx+Sp+hG2ESDkWvng8w1gQdYy3GZLjU4BpECaJu2AznPP7Ff2E KayeXMZlyc0SHHRnLd5DHwsnD6FHcKzQ2mEpbuTH/NJCFbnK8UBknYIaQje2qjUDe1/e 26KnmESeM5mdxHfTtSAClsFYUWecUVba9IzIsVMq/RatvAdSwB9SVtfRMwAJZ0qGY+VG nCeTlV7vo29biYHDg3TrisaN9zOzLF9AZEv8Hy+dE42C+UawNuuwi0/0cA96AFTx3lvj 6Hn6XJDdj+OCqPFoCqe5/PUbJhfYTJrJBmWJQOpGSziVM9eWBoO6L+hKy49FeoIyOyql grmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RVxK++d9; spf=pass (google.com: domain of linux-kernel+bounces-19193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x17-20020a17090ab01100b0028ba37adbfasi5237102pjq.55.2024.01.08.00.38.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 00:38:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RVxK++d9; spf=pass (google.com: domain of linux-kernel+bounces-19193-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19193-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C7E01B2144A for ; Mon, 8 Jan 2024 08:37:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C3EBBE7F; Mon, 8 Jan 2024 08:37:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RVxK++d9" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57B2ABA4B; Mon, 8 Jan 2024 08:37:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704703065; x=1736239065; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=GncR5FdB7gQF27APfP3bULtZ1spPn60JzQ0JnmY5Xrw=; b=RVxK++d9OgRnMQcfPLeMPN+fahS2Qeklrk7RyNP1uwuj3SAcfaPhyyY7 oUd+aoI20EI7QW6Adl2Xethn/xOEjqAa213aQKYkzOL6NazJeg9IaJzCb XC7p9AgNOiBlfnhrDxIh0aHiHB2UAN6GNXeZ08PkOa5T1Z18VcBn58ipi i/jKj+VpAwanGg+EgnG09KzgB1/lrHBiuyZLOGfssJOcakfCdRft6jgbo 7bLVuikuT09uhKhD1MyAmksDoc+QS/HCOQz/Y2zk4417aliytwzJZYLgO I/Qris/N49H0XtmtHD3LwtgdGojcTJB4nDxoUJ+NW0k04v/aBsDCENLHu w==; X-IronPort-AV: E=McAfee;i="6600,9927,10946"; a="400583126" X-IronPort-AV: E=Sophos;i="6.04,340,1695711600"; d="scan'208";a="400583126" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 00:37:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10946"; a="731042280" X-IronPort-AV: E=Sophos;i="6.04,340,1695711600"; d="scan'208";a="731042280" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.2.99]) ([10.238.2.99]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 00:37:37 -0800 Message-ID: <272782f8-e17f-4f92-9d20-cbee790b4c7f@linux.intel.com> Date: Mon, 8 Jan 2024 16:37:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 3/6] iommu: Add iommu_copy_struct_from_user_array helper To: Yi Liu Cc: alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com, joro@8bytes.org, cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com, xin.zeng@intel.com, yan.y.zhao@intel.com References: <20231117130717.19875-1-yi.l.liu@intel.com> <20231117130717.19875-4-yi.l.liu@intel.com> From: Binbin Wu In-Reply-To: <20231117130717.19875-4-yi.l.liu@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/17/2023 9:07 PM, Yi Liu wrote: > + > +/** > + * iommu_copy_struct_from_user_array - Copy iommu driver specific user space > + * data from an iommu_user_data_array > + * @kdst: Pointer to an iommu driver specific user data that is defined in > + * include/uapi/linux/iommufd.h > + * @user_array: Pointer to a struct iommu_user_data_array for a user space array > + * @data_type: The data type of the @kdst. Must match with @user_array->type > + * @index: Index to offset the location in the array to copy user data from > + * @min_last: The last memember of the data structure @kdst points in the s/memember/member/ > + * initial version. > + * Return 0 for success, otherwise -error. > + */ > +#define iommu_copy_struct_from_user_array(kdst, user_array, data_type, \ > + index, min_last) \ > + __iommu_copy_struct_from_user_array(kdst, user_array, data_type, \ > + index, sizeof(*kdst), \ > + offsetofend(typeof(*kdst), \ > + min_last)) > + > /** > * struct iommu_ops - iommu ops and capabilities > * @capable: check capability