Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2272376lqo; Sun, 19 May 2024 23:42:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVLHufn7aNuGkERvBz09Vgv320gbPUqYgy132/yOOD6ONXp1Zxt7nosNMaFhi1KvUUCeYymWYPwTNrJYeRLykmHOI5PTz74v6gvLi+2+A== X-Google-Smtp-Source: AGHT+IH/TwdnLgDrxrmZS8RX8Jo9S1b7MJvmYDXSPGF1jcU2VLWuVov8VCNTLY5E46ULruqjExlX X-Received: by 2002:a05:6359:4c09:b0:192:4634:b1db with SMTP id e5c5f4694b2df-193bb517d7dmr3010101455d.11.1716187348826; Sun, 19 May 2024 23:42:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716187348; cv=pass; d=google.com; s=arc-20160816; b=DMP25/Nr6hTk6vcyxamqRzZ9eiQfoH3qruF3s67MLOsvIi3uYD2SsXN4eMh6oL8q4C fQ0arfeevu+bjLu1LzCuv515oqxf+uvDg8E1cau+hceB2iD7vf3AO3EjPPTpuGMgEWr/ Shd0cxRxu5ZHEcq73ib64YwZzNHVFbK8OvCo1ZIDtf1WJU2Q4tjMigVweQBqiR3h3Bs9 9qlIn1qqBH41PMBLKjcul8oO5knePmVo0HDDGFPdD/KYnTWVare+MGakjHY2A03d0uwD yxSFO+nsItxsWSEC6/vpYTI+L1J9DC4mNf4RcSDbnoyzH14EkGZXYdVqG0iMHGKOm+XK 0Wyw== 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=CFnF0rwKqy8qvjUsfBGkkDedpg7XGclDAVE39s/B0sU=; fh=oj0MC99jJmXr9VOxYru8PCxqsxVpffpkkk/RjcP5DFo=; b=mfOd6KpzNk+urT5rsVg5V8kO5+dBLQjMjFZ5yXaHUf5LY45YF2FwbL0msu1f8/v/E4 55PXtYl2BKi680ouklFA1KZv8gQZh3BtrPbxPxqk2mQE9xI2wgZPkOjcG+mvSJ8XczDp HLyeipQV53e/qla+xq3mBZsxEcg3uirQt8IuASLIARAvSv8rLEYHJcdBo+R7o6OdIIB6 vTkq6MaLT8nrhbV/w/vXPOzI4hdMQFN6X7gpI8shLEePWQhETUga8YNfZUQQy6wDG5Ck cHdWQkCLnp9VZ+DAccbAteXGm5gJpXFjFqKI1AoAux6mX4gZ4N2F+7fywk4kw9ggSEiv 1AhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XRbfCxVh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-183405-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183405-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 41be03b00d2f7-6341171934fsi1749642a12.480.2024.05.19.23.42.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 23:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183405-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=XRbfCxVh; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-183405-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183405-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 A037CB221C5 for ; Mon, 20 May 2024 04:02:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 188B911CAB; Mon, 20 May 2024 04:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XRbfCxVh" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 C8E7733D1 for ; Mon, 20 May 2024 04:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716177757; cv=none; b=aRgD1WRwCfYWLljsfGwtP8r4Do0MoLIwiEcramaeCcpSjgzPZPX0whkjQweVrYEsGdbwGi/hVbFKQp1MGW+bGbWwOFjeN/JyZBnQ04S3CC77gDuaV3IiibWmbyAskXU0PQDaGA6V7sZe9KmW01GQD5Aei64Z+Ri5a068DLAkR0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716177757; c=relaxed/simple; bh=fgm8MnasUfp5gUQywE3WLZ8eiovWbEY/6L/UNSu7+ho=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=eTQtnRGpx5/Bd6NAX7niVVTzSv0j5fAZGo2Tjve8KXCpsMlQOfkXlZ3nYisxtwP+A7+DAhiitSSoN2idNCkR+pWAOHHMHuK/ZLGEyN3plsNgl8rLiFBLhsT2fkT43mW4VkUfKcCnnxag9ASOTvyjdkev/M6MfU7178J/oJR+u9w= 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=XRbfCxVh; arc=none smtp.client-ip=192.198.163.17 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=1716177756; x=1747713756; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=fgm8MnasUfp5gUQywE3WLZ8eiovWbEY/6L/UNSu7+ho=; b=XRbfCxVhAx7P4gr1ITgll5aqSiE/7XTGAn0sNcpKZvI2NWlmOWh3o7x0 R4ky3JOBxQ5k47y2APUYjUc5/Yoe/S5ccgXKqu8uBnDJRlU0QjN/nbKW7 I4+3iQB7kiITtaZ2+TDaxT2+7uaaXaoM68AMvjBsNn1fJt+ivifmkdcKd HRKP71XKDBFc/kH2PRiCshwH8SbJ+m1NRr8/A5oDsO5xPjsOU4TuH0aCv LMNRDuyP9RXAObXLBCsQGJR/sogLbYo2sgZYcyI22O9T92cWOKKC1dymc QMO7PurmhSCnoHmBx3mtuexkKAV+M1DZi760zfv0VYAou6R/DYxIJTb1I w==; X-CSE-ConnectionGUID: HyfT1RE1TvKxviYJbQREbg== X-CSE-MsgGUID: +QHx5HzXTfqp1aXdIqKmxA== X-IronPort-AV: E=McAfee;i="6600,9927,11077"; a="12157798" X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208";a="12157798" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2024 21:02:34 -0700 X-CSE-ConnectionGUID: B4dH7KHrSO+UmnIsYcfqLw== X-CSE-MsgGUID: zsu2PH6MSoeFiiHI3qWQRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208";a="36912098" Received: from unknown (HELO [10.239.159.127]) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 19 May 2024 21:02:31 -0700 Message-ID: Date: Mon, 20 May 2024 12:00:39 +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, "iommu@lists.linux.dev" , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 7/9] iommufd: Associate fault object with iommufd_hw_pgtable To: "Tian, Kevin" , Jason Gunthorpe , Joerg Roedel , Will Deacon , Robin Murphy , Jean-Philippe Brucker , Nicolin Chen , "Liu, Yi L" , Jacob Pan , Joel Granados References: <20240430145710.68112-1-baolu.lu@linux.intel.com> <20240430145710.68112-8-baolu.lu@linux.intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/20/24 11:39 AM, Tian, Kevin wrote: >> From: Baolu Lu >> Sent: Monday, May 20, 2024 10:19 AM >> >> On 5/15/24 4:50 PM, Tian, Kevin wrote: >>>> From: Lu Baolu >>>> Sent: Tuesday, April 30, 2024 10:57 PM >>>> >>>> @@ -308,6 +314,19 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd >>>> *ucmd) >>>> goto out_put_pt; >>>> } >>>> >>>> + 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; >>>> + } >>> >>> this is nesting specific. why not moving it to the nested_alloc()? >> >> Nesting is currently a use case for userspace I/O page faults, but this >> design should be general enough to support other scenarios as well. >> > > Do we allow user page table w/o nesting? > > What would be a scenario in which the user doesn't manage the > page table but still want to handle the I/O page fault? The fault > should always be delivered to the owner managing the page table... I am not sure. But if nesting is the only case for user page table, it's fine to move above code to the nested_alloc helper. Best regards, baolu