Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2655496lqp; Mon, 25 Mar 2024 05:54:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFwbz8E0irPKqAa50qnoMR8jhhI1q58alvfd0gDggZ9vllZ0X1yeIHCw0Udo1MNb8/eP1jE98PwT/e/MYx3VSKs5P4yVQho4otNcyfRg== X-Google-Smtp-Source: AGHT+IGVPOnscU1eC5n3NjupyMK/W+al6nRjxXR29kmjuzdysAMtv6cvJ4bfKT2LUfPidh1dnxhm X-Received: by 2002:a05:6870:1492:b0:221:be6c:3434 with SMTP id k18-20020a056870149200b00221be6c3434mr8597350oab.10.1711371256432; Mon, 25 Mar 2024 05:54:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711371256; cv=pass; d=google.com; s=arc-20160816; b=kvlNGYEQqRA3dZkRFuq6cMXFTRvJ3mmiwHrZUSoiCRM15pysBVEOQwqbuQnZoI0tJD MoUFEoOseXbr+/CEhfzLaMSvxPn0h3c2nL+wSIb3qyLTABplIAntcIkCiMS2vQy84BrB 7PuaPmWsZD5R5hh9HVatXHGseP68KtAOcatZgYtCB4VP7RZX8UivyI2d5LWkGAmA+OeA 3LEfGAFQqDSuU6ez2HV06ASk7eDILaKhCJ+NKpX8TA+p0xqPydme7DLloagPeBk3fMWb EiW/HVukbVgFTfCer7RGDQQwG0MxH7V9VxAbW74XSjPHyIBMcKVPlnU1kU/btJDIpAY9 sOGQ== 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:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=cckNBFVgixm0Fkus0hK1o+2HH8LiVeIBlpQ3hTBjLEI=; fh=r4CFKIoF+br4bdFEHkcrhZjrjWdGMvoP0L0rJCwgB7s=; b=C+obNw62paA03bgKeoxLx6aMcrFlOM0ZqfKDa541aSJuYYd2Fcmo17xXPlswSDFyU+ ooVHlyG2HSAL0lJB3eJcGAYeQiSV5LjY1HDZB2UMmYcu8lSIwCJYMNj7kjfOcEBel1me JydyaoBUgjf6h0v21Oh+8rO3wjT4LXGl32GKPfJ2cvv2uiSGfZ7pc++Dd0ZS8Ixas6DS eM2hdL7td/cn3v3iOwEGo0Jr06S9YizMO+A6jKpjqveXsROAt01jXIjEQ3hS9+m1Cd/z owCBMa1RxzeNRyEfGmfNclnbR3hoJYOiHMWes35Xdk2w4/zZRYPte7/mp9Qxeox73tJZ rJtw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fwGChg5O; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116530-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r32-20020a635d20000000b005dc96417b0fsi7365425pgb.161.2024.03.25.05.54.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116530-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fwGChg5O; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116530-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116530-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 294DE2C2972 for ; Mon, 25 Mar 2024 12:54:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 137DD7EF05; Mon, 25 Mar 2024 07:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fwGChg5O" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 92C1F1C68BB for ; Mon, 25 Mar 2024 04:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711342798; cv=none; b=ZyewnyGCb8K4IjwZkDL7A+UPkAKn0ioLOryzEmrbU0ohKbLhGmCP02EmfyRfWvEJeiKmMvfGFeKDZ6//e3Ad9oH/pGtSfjM5N/j/Q5xsRAgx34FhsmvA/kNQOPEripPwLme62BuWhXGwoMRp2jtQHDCzG851nNZID69k5EqKv4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711342798; c=relaxed/simple; bh=JPIFdOVVVlbXRwS1CVptMVqz9h//vSxocpBlOd35dic=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=X78m6AffaSwVdFimbVWmM7jgTIPD/dO5HgqaCwVH84K/7hmCS/KR0cPK2CslnlOcB8GOQkf5FkltR28VRsZQPV1n4BteLqVrUAd+qBZkAsJ4w0mEjkvWh5TzHxeRaA7LcH0O/cIWqnH8Y/Aa58um0zKcqUp9/sOTy9Yw1vNA3A4= 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=fwGChg5O; arc=none smtp.client-ip=198.175.65.21 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=1711342796; x=1742878796; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=JPIFdOVVVlbXRwS1CVptMVqz9h//vSxocpBlOd35dic=; b=fwGChg5OGovLLmVajgibfdupHyEr0bDtD2YkZ5tp2Vq1RyUG2YSapcJ8 M7A1KvZRxbkvtzqtXEmblCJ5O9xngRtx2wDhi87kxTINxAFMQtvMKtsk/ 18LPxBkyNDCHV9a+hOWT6iIvE++uBy9u2vfkfaqXL3PpXL9j/TiYLACkV /1KBAlRzB1sIkq2QaWeZiX+kcp208h4adEQDTA/rV1UeJq96vGYaWy70x 1HVt729isZ+ce+3fEJaXMDuQv+8j+h+d0SUNulsTNPVX1sSdmWm3dPQkm bFwarBh99bWJJRQiHYq4UlCEylVrnTkINLi3YzH7e3U9llNkj+PMN5fBx A==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6259981" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="6259981" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2024 21:59:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="46493985" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.254.209.86]) ([10.254.209.86]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2024 21:59:49 -0700 Message-ID: Date: Mon, 25 Mar 2024 12:59:46 +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 5/8] iommufd: Associate fault object with iommufd_hw_pgtable To: Jason Gunthorpe References: <20240122073903.24406-1-baolu.lu@linux.intel.com> <20240122073903.24406-6-baolu.lu@linux.intel.com> <20240308190539.GY9225@ziepe.ca> <7a6ac83b-3165-4abe-91be-a58f69656f8a@linux.intel.com> <20240322170613.GI66976@ziepe.ca> Content-Language: en-US From: Baolu Lu In-Reply-To: <20240322170613.GI66976@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/3/23 1:06, Jason Gunthorpe wrote: > On Fri, Mar 15, 2024 at 09:16:43AM +0800, Baolu Lu wrote: >> On 3/9/24 3:05 AM, Jason Gunthorpe wrote: >>> On Mon, Jan 22, 2024 at 03:39:00PM +0800, Lu Baolu wrote: >>> >>>> @@ -411,6 +414,8 @@ enum iommu_hwpt_data_type { >>>> * @__reserved: Must be 0 >>>> * @data_type: One of enum iommu_hwpt_data_type >>>> * @data_len: Length of the type specific data >>>> + * @fault_id: The ID of IOMMUFD_FAULT object. Valid only if flags field of >>>> + * IOMMU_HWPT_FAULT_ID_VALID is set. >>>> * @data_uptr: User pointer to the type specific data >>>> * >>>> * Explicitly allocate a hardware page table object. This is the same object >>>> @@ -441,6 +446,7 @@ struct iommu_hwpt_alloc { >>>> __u32 __reserved; >>>> __u32 data_type; >>>> __u32 data_len; >>>> + __u32 fault_id; >>>> __aligned_u64 data_uptr; >>>> }; >>> >>> ?? We can't add fault_id in the middle of the struct?? >> >> Yes. I should add the new field at the end. >> >> By the way, with a __u32 added, this data structure is not 64-byte- >> aligned anymore. Do we need to add another unused u32 entry, or just let >> the compiler handle it? > > Yes, add a reserved u32 to ensure the structs is always without > implicit padding. Sure. > >>> >>>> + if (cmd->flags & IOMMU_HWPT_FAULT_ID_VALID) { >>>> + struct iommufd_fault *fault; >>>> + >>>> + fault = iommufd_get_fault(ucmd, cmd->fault_id); >>>> + if (IS_ERR(fault)) { >>>> + rc = PTR_ERR(fault); >>>> + goto out_hwpt; >>>> + } >>>> + hwpt->fault = fault; >>>> + hwpt->domain->iopf_handler = iommufd_fault_iopf_handler; >>>> + hwpt->domain->fault_data = hwpt; >>>> + hwpt->fault_capable = true; >>> >>> I wonder if there should be an iommu API to make a domain fault >>> capable? >> >> The iommu core identifies a fault-capable domain by checking its >> domain->iopf_handler. Anyway, what's the difference between a fault or >> non-fault capable domain from iommu core's point of view? > > From the core? Nothing. I'm just wondering from an API perspective if > we should have a little inline to indicate it. I have no objection if there's a consumer for it. Best regards, baolu