Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp562006lqb; Thu, 14 Mar 2024 22:22:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWo8xfKqKAjUWkcA/2ld1Vij0G+69NTtU7zKCpqx4tyoLUUk+Ur8SLBuoMuBKXU19Y77rQsO3Dj0+Ki1fvc1kkPQsfSjuMvyRoR26G6yw== X-Google-Smtp-Source: AGHT+IEmxvv2Xu8Ke8mgbyma9swle3zMc9k57EjMhJrMneC1RfDIYL4QBJ0YfkB9YLocSNMqAi1X X-Received: by 2002:a05:6808:15a5:b0:3c3:633e:6e5f with SMTP id t37-20020a05680815a500b003c3633e6e5fmr3290127oiw.42.1710480158733; Thu, 14 Mar 2024 22:22:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710480158; cv=pass; d=google.com; s=arc-20160816; b=r34jUm6D9KKKZbLYwhUvj32KWNXDDWvT+9Vv4QDe6vkfquFn1xyk8IfkoeiHCxGfVV rvo8VuH9+QvH7yxnC+JSAw8ZVlY8D6+XauVErqTqezQ1g9j8ctBHuoCFfUIzPeQLrrjo UPg9NZ+p+tKfqIo37iYr6kjTCQzk3F5UydYLMdxExFlmW99QXCYo/UCbFKvvpRz00II8 Vbu3dKorpM48nT6I3mRZaCJHnfhKe773G7uvxS4EJqGpwzcOgBaKwQ1HZs/MYc0loqNO AsnoLV4zPrMuzVi7RV+/4gitamKCITYK7CG5h6gu3Y424tDNMls2bt2IatF28+4DLOGn UM1g== 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=yzxlKNcXX+B20y3/BIbufykZ6uFMiLhgKbMSqdI9Ri0=; fh=r4CFKIoF+br4bdFEHkcrhZjrjWdGMvoP0L0rJCwgB7s=; b=MgqhDtFe26tVzsUR2ITvCIbjJAK9DMwGY3xQAO0ZX2yfwLhZzSHLG6WtLcx7U2944w B36UZ33jJiFw9lE90xLyIL9ZVGZ0N1+vqVrEzJbRfepNLXMnEvxmoe/xdYIf5GbMlNO9 A07yl2QTrge4HyAIQ/Hha2ZNZOYciO8wz1h8z2g+uKRb+3WlJeuhsTlZSLV3WM1IY/f2 lqK8qxYJHvoOpXduR8Trxc+J9J+bBa/ZQEoof1SfwvIzxWODeFJEH5tmbpEyfEa6QbI6 L4WLOks28LeyfjSWhXEl5nFjfNQugCAzdpyIUMb1TZWrE6HpZDGXZueVt27UY89jeNxO hsEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MeAC9nCE; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103960-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g19-20020aa78753000000b006e6adf25702si2846967pfo.48.2024.03.14.22.22.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 22:22:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MeAC9nCE; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-103960-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103960-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 E8BBD2818DD for ; Fri, 15 Mar 2024 01:17:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D48A63D9; Fri, 15 Mar 2024 01:17:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="MeAC9nCE" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 AD6AA17C8 for ; Fri, 15 Mar 2024 01:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710465447; cv=none; b=kuiX9jrLqBeRYXQ9KaAfvjkMNcElYo34Je75smbfUsneFKDtYhLogjW/7hlKZAeaQFCjf0iIh1S6yrp2yNY39l0+MMg7NvXhqfSTjVNMwCANx+fGDLQwdax+HlvSW4pV+jEPm73QIUjvG/0SKCNFC/VbiZb/S+yA0qnKnYOIP4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710465447; c=relaxed/simple; bh=RINii3wGGnlUbE3ZLF3vQV3MCY+kCa38spzuhHObNjs=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=iYSdae/M/TjW+M9tpOH5w3ueyYfFxCtZutA7+5fd6+/NYW9UcArfaYkj3vEGRTMwf/cUoalcFrvzH1sLJh8AQVFaDfdeTC/8T/cW5wX5FaB4ATjRdELu7px+sHReHIbkYF1uJPMtCfKvn7WrUlr9HkJQpjRiByVdLe6L6bD/HHQ= 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=MeAC9nCE; arc=none smtp.client-ip=192.198.163.19 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=1710465446; x=1742001446; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=RINii3wGGnlUbE3ZLF3vQV3MCY+kCa38spzuhHObNjs=; b=MeAC9nCECWlGJBKO4FZmZNb2/k2ImDeJ95+EULFVo1+NdDbidkVtOpmx IaVnTBv5CVhfcklNLJS5YeUN1wl5rt1Mclge/5+2ld0NundhS5NxJYdNJ /mcWZIH+6o1PcaIGIGIDz8uOJn5102HUkFJkXfIRjELHfkl3KnhRevdKD ZraYlxrjieKFWB7d3gpxwK5e/t2khbW+yb9oSWiqOCSAgLMtMlHXuECOe KFWYEicfkag2zFLANHRwmPr6CY1tB+laq3JGPP7rzbWx0Ov7B2/ndO7rw v4AXdy2bJQUhL1fhJJ5ah2BjDuHb88mJMzZhQ+6OvuoPzk6nDBVhEAl9n Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="5175577" X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="5175577" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 18:17:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="12947095" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orviesa007.jf.intel.com with ESMTP; 14 Mar 2024 18:17:21 -0700 Message-ID: <7a6ac83b-3165-4abe-91be-a58f69656f8a@linux.intel.com> Date: Fri, 15 Mar 2024 09:16:43 +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> Content-Language: en-US From: Baolu Lu In-Reply-To: <20240308190539.GY9225@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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? > >> + 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? Best regards, baolu