Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp230020lqb; Thu, 14 Mar 2024 09:41:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIQpy6OIbc2t3bWMdRwMDoQFcy9UDZgGxCTB4KftF6m/ETjADEjMVRjYb2Kgo28SJDMEXPcvJu8pAjC4gZYhcpsWu9pm48qC+UJgee5w== X-Google-Smtp-Source: AGHT+IFzzXu7OUR9KsAPETzc7tr0D/PGgpNmdZqSrCMYIEdxE7i0dnRSR2UyRh7QhTOyhf4ZU04/ X-Received: by 2002:a2e:321a:0:b0:2d3:5020:17e5 with SMTP id y26-20020a2e321a000000b002d3502017e5mr415924ljy.36.1710434510728; Thu, 14 Mar 2024 09:41:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710434510; cv=pass; d=google.com; s=arc-20160816; b=O+IKXBkqMZHook1c+JXJ0r7Wq12m3hDsAvKvAnjeW/O1BwPT35bP2/e2dJSYUn9gpA ZlvJCcvXkFySfiDqhiCPw3ht0EbviRSayO0wRMZX/FxxVuXmiwVg9V5MAq+o7kop06QC ujkLsTAqdId/GuJi/1trCb0WUY4lGzGEL7NPoQhOIealT02wwLiY2JZrNAT+TN8Ykri0 9kqAQfpT2HbPOWxYw+kJaRjRQXjBBGyhgNsedwNwwvS3CciBw8oFGF42RPJZii8GFyaJ ghgLXTr9ZdiGaypTavikNEoVA9qIX5cFTIejqN5YkAAsQ3AfnkdtfAw8QdSTVud5riuP oWdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=BsQqK4qdZZy9HVRIRnS/ugO3XI0o3pIPALjhIzd3a+U=; fh=r4CFKIoF+br4bdFEHkcrhZjrjWdGMvoP0L0rJCwgB7s=; b=byy05HB+4hKwMRjd5bmxFovMhGiBht4KPffIeYy5VfCp5SeS7VtzRavufMCQycSmxh gsOHUpgQvdf3oxq0SlBVTxQLpRjEh4mN4Ddk3cd+HhYKsI0qMCiFFd3mtNTiQHbN8d1f d4U0k8nwpqYtHKprGgJV50L7rBHJqD/YcINdXpJFLgJodsm+ZLcyXxEfbgVuSUn0owyi 8TZdxzoCgJDbeK0IpBoIMqgeqjV0gSlqOibw3IabGJTM1KtjxaUPswqv4DWB8eyiG86X 4IZ5Mo+i7QUfgvVbdfoTFw0XIuls476WWF4PZjYnR7nwXWYKZvcfhYJ/FBS2vpYmZPSz Qmfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q2PLnj96; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103312-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n26-20020a170906089a00b00a43fd9e16a4si844829eje.17.2024.03.14.09.41.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 09:41:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q2PLnj96; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103312-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103312-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4692F1F22647 for ; Thu, 14 Mar 2024 13:42:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3D0E6CDB0; Thu, 14 Mar 2024 13:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q2PLnj96" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 3FF995A4CB for ; Thu, 14 Mar 2024 13:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710423713; cv=none; b=d9Seu7Mwa9lfM/j3AbWmQxL7kcMvMMJwwtXmC3xZyZccCEQyKuW7yz7pXVaK2KXB0MT91YkIe8YWCKvvKjaGsLKOaJlWTe6GaOmL25ms9mKU+2dAPVXoezTuStbNES2uY7BJviGYs4wb+iWK9rIjUn7/XxhN/XPckaVEjXuI7AY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710423713; c=relaxed/simple; bh=FghQcZsR6VC2YmekzMAzZOpVy/lU5ooLVH+PhXP0tmI=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=aKbFZIiRE8/5PSrwlK0DgmRFYe6BB0kt12wqP7sdpb/hZSGH/KjcW5nbBu64xpuuHxInkP8QcKPdn7X78txpqJUUroTDWQWVMpIhOmHaP/elR0JnPdZlQH82UsggoGEkNFx3rfdJVkA1N1sY9DkOYaIho2B04Rw3ORvaV6sNG4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q2PLnj96; arc=none smtp.client-ip=192.198.163.7 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=1710423712; x=1741959712; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=FghQcZsR6VC2YmekzMAzZOpVy/lU5ooLVH+PhXP0tmI=; b=Q2PLnj96YYqO42GlxFsrx197PlPgiVvvL+KKeoWO+l8FqKBHIt0ovjxO SbX7s1xbqSdRlOF7uP21x2Oqj/ykLM0Io5NTcPuXmBTrCo74qSLuH4ERf W47Mmi4a3pxN/Z+1K+EglNF72vLSa32xKSKhR8JNPvpbhiWeiw6VtVo6i 8J9ajefeGt4eSoPz/idtEsZKNOXUe8xNtCDCTkQkRzVul+iqnl1UesNma slrf1Ngz2NAeYKEj+vZx58Xq6jdlBvHCrecjTdY+IX78hK6vIa8zFYWvR S6irw1G/DBmkaDeQZyFC6TPsDaRbOW7kkRbTL6YKict1Og0IQ4sBdHy6d Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="30679638" X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="30679638" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 06:41:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,125,1708416000"; d="scan'208";a="17023702" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.255.29.38]) ([10.255.29.38]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 06:41:48 -0700 Message-ID: <43ef5e3f-8a8e-4765-8025-b8207fd05f91@linux.intel.com> Date: Thu, 14 Mar 2024 21:41:45 +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 Cc: baolu.lu@linux.intel.com, Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , Joel Granados , iommu@lists.linux.dev, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/8] iommufd: Add fault and response message definitions Content-Language: en-US To: Jason Gunthorpe References: <20240122073903.24406-1-baolu.lu@linux.intel.com> <20240122073903.24406-4-baolu.lu@linux.intel.com> <20240308175007.GW9225@ziepe.ca> From: Baolu Lu In-Reply-To: <20240308175007.GW9225@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/3/9 1:50, Jason Gunthorpe wrote: > On Mon, Jan 22, 2024 at 03:38:58PM +0800, Lu Baolu wrote: > >> +/** >> + * enum iommu_hwpt_pgfault_flags - flags for struct iommu_hwpt_pgfault >> + * @IOMMU_PGFAULT_FLAGS_PASID_VALID: The pasid field of the fault data is >> + * valid. >> + * @IOMMU_PGFAULT_FLAGS_LAST_PAGE: It's the last fault of a fault group. >> + */ >> +enum iommu_hwpt_pgfault_flags { >> + IOMMU_PGFAULT_FLAGS_PASID_VALID = (1 << 0), >> + IOMMU_PGFAULT_FLAGS_LAST_PAGE = (1 << 1), >> +}; >> + >> +/** >> + * enum iommu_hwpt_pgfault_perm - perm bits for struct iommu_hwpt_pgfault >> + * @IOMMU_PGFAULT_PERM_READ: request for read permission >> + * @IOMMU_PGFAULT_PERM_WRITE: request for write permission >> + * @IOMMU_PGFAULT_PERM_EXEC: request for execute permission >> + * @IOMMU_PGFAULT_PERM_PRIV: request for privileged permission > > You are going to have to elaborate what PRIV is for.. We don't have > any concept of this in the UAPI for iommufd so what is a userspace > supposed to do if it hits this? EXEC is similar, we can't actually > enable exec permissions from userspace IIRC.. The PCIe spec, section "10.4.1 Page Request Message" and "6.20.2 PASID Information Layout": The PCI PASID TLP Prefix defines "Execute Requested" and "Privileged Mode Requested" bits. PERM_EXEC indicates a page request with a PASID that has the "Execute Requested" bit set. Similarly, PERM_PRIV indicates a page request with a PASID that has "Privileged Mode Requested" bit set. > >> +enum iommu_hwpt_pgfault_perm { >> + IOMMU_PGFAULT_PERM_READ = (1 << 0), >> + IOMMU_PGFAULT_PERM_WRITE = (1 << 1), >> + IOMMU_PGFAULT_PERM_EXEC = (1 << 2), >> + IOMMU_PGFAULT_PERM_PRIV = (1 << 3), >> +}; >> + >> +/** >> + * struct iommu_hwpt_pgfault - iommu page fault data >> + * @size: sizeof(struct iommu_hwpt_pgfault) >> + * @flags: Combination of enum iommu_hwpt_pgfault_flags >> + * @dev_id: id of the originated device >> + * @pasid: Process Address Space ID >> + * @grpid: Page Request Group Index >> + * @perm: Combination of enum iommu_hwpt_pgfault_perm >> + * @addr: page address >> + */ >> +struct iommu_hwpt_pgfault { >> + __u32 size; >> + __u32 flags; >> + __u32 dev_id; >> + __u32 pasid; >> + __u32 grpid; >> + __u32 perm; >> + __u64 addr; >> +}; > > Do we need an addr + size here? I've seen a few things where I wonder > if that might become an enhancment someday. I am not sure. The page size is not part of ATS/PRI. Can you please elaborate a bit about how the size could be used? Perhaps I misunderstood here? > >> +/** >> + * struct iommu_hwpt_page_response - IOMMU page fault response >> + * @size: sizeof(struct iommu_hwpt_page_response) >> + * @flags: Must be set to 0 >> + * @dev_id: device ID of target device for the response >> + * @pasid: Process Address Space ID >> + * @grpid: Page Request Group Index >> + * @code: response code. The supported codes include: >> + * 0: Successful; 1: Response Failure; 2: Invalid Request. > > This should be an enum Sure. > >> + * @addr: The fault address. Must match the addr field of the >> + * last iommu_hwpt_pgfault of a reported iopf group. >> + */ >> +struct iommu_hwpt_page_response { >> + __u32 size; >> + __u32 flags; >> + __u32 dev_id; >> + __u32 pasid; >> + __u32 grpid; >> + __u32 code; >> + __u64 addr; >> +}; > > Do we want some kind of opaque ID value from the kernel here to match > request with response exactly? Or is the plan to search on the addr? I am using the "addr" as the opaque data to search request in this series. Is it enough? Best regards, baolu