Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2141808rdb; Thu, 7 Dec 2023 22:02:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRHgDBBhEeM8Bfr2TfKKBGqQKA/D2bU5TJfUTrrWiBnal0pmVtkxVnBitv9NyOgaH8gyfC X-Received: by 2002:a17:902:d48b:b0:1d0:c3cc:376f with SMTP id c11-20020a170902d48b00b001d0c3cc376fmr4127816plg.46.1702015361767; Thu, 07 Dec 2023 22:02:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702015361; cv=none; d=google.com; s=arc-20160816; b=bDURg0sVO0Izrc4O3Hh9+5p/C5blpcMDcfvuhkCX9xxie+MEr73vXUp1mhxAOmlDNP cfysTgMPX7lsNpp7mH2tUeEfHlGW1jg/PFtQB6AjFADm//rfGyhHqCSv0jhUBC1NWqtr L/8xWoqHIgWZBbMBSRf6K3nRpJoF6QWuLblM3n9B9yiuBN5gk8IvBQxl5dd1W34A1rta f9wXU5//56J5/YkGuE5jphDMRGxtabxT9ui6f11jMBT+kf3m1iPcV35Qg3xd7GDRQbXO ocGHI3/8cTM5/LuC8F1M50ypEczPEGUqIqtG4lHRDVBaY9asuM73uNvem+V5kcaT53Ih 7IQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=PV9XBLuSPqxFqlQRSp7/oejr6qbtc1w4nYICi8qmtp4=; fh=CHF6icUB8BkFux9PDqkpqFGX84EaHzyqwt6q0oBm+fk=; b=0MuQqzJT+gz+2dvWuNpidz+T89XJQC2tGN3lqMH/+pRzxAp5+o3NXnWth5tc3Y+sIE m8QCNcExD9Xrx714SbQZ7wha6N9CFtcRi953PoU25xp/lAt7RxoTSr9s0Ee+YA3+ikEO CzmhlcKT/VdbMlg23xIBBoTlzdWGNqSNVtb/uGMJAGp3JaLrZoJ5Kgr4Wbr7wQxBhkHe 7LWCycC1afptZc794Uovuayz3dD19nK8GVuayV6tCfHl25U2Jqu//Z/f0Tnw1vCOcy/7 vu34dO3zDefIsD4xof5rUNnAlqh/RI/alYpuuy3HNQ3C3PXXeaFwLP+pRcs2P9cy/n5I Sgzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d7N+kUK+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d1-20020a170902aa8100b001d0568f3a6dsi968715plr.630.2023.12.07.22.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 22:02:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d7N+kUK+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 78B6380FCBDB; Thu, 7 Dec 2023 22:02:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232875AbjLHGCC (ORCPT + 99 others); Fri, 8 Dec 2023 01:02:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjLHGCB (ORCPT ); Fri, 8 Dec 2023 01:02:01 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A643171D; Thu, 7 Dec 2023 22:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702015327; x=1733551327; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=8YfUtY53ybfUCrDRuQ3/gMPNDKuhyX3Iq/kRdGPDIQk=; b=d7N+kUK+dYlFennt86EgJxrqa+EhdbnHv78BvCY539AgEoLem6J/3CJo B9Y2dtbNA0MYUXwYdzFXyYb98uFanAqvdk3e4AkLDJlrtDSWRgFeO70AB LFjCAvmPddVAymJy5P7FHjBzLKHbnjiJQwH6Y2t3X9PtQvz7Hf6HuJNlY ylS5cNuajkBpADlukbM22nm/uNhGi8v2WLa/3RV6ASnzPxvY8YgBp5GGi bQuRSVBvt4SWI6sPprqr9OgmFkFd5jwSRwacxwNEqHXPWMcg3FqM8IJpw DblYFl7anZCItjgZgJb4Q28f4t06CZmS1vvPdLydYgmHXtOa9aax4IKAs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="1467163" X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="1467163" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 22:02:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="842486903" X-IronPort-AV: E=Sophos;i="6.04,260,1695711600"; d="scan'208";a="842486903" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by fmsmga004.fm.intel.com with ESMTP; 07 Dec 2023 22:02:03 -0800 Message-ID: <46c80b4e-9f05-4fb2-a31d-7386a41c895a@linux.intel.com> Date: Fri, 8 Dec 2023 13:57:26 +0800 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 , iommu@lists.linux.dev, linux-kselftest@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/6] IOMMUFD: Deliver IO page faults to user space Content-Language: en-US To: Jason Gunthorpe References: <20231026024930.382898-1-baolu.lu@linux.intel.com> <20231201142427.GJ1394392@ziepe.ca> From: Baolu Lu In-Reply-To: <20231201142427.GJ1394392@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 07 Dec 2023 22:02:28 -0800 (PST) On 12/1/23 10:24 PM, Jason Gunthorpe wrote: > On Thu, Oct 26, 2023 at 10:49:24AM +0800, Lu Baolu wrote: >> Hi folks, >> >> This series implements the functionality of delivering IO page faults to >> user space through the IOMMUFD framework for nested translation. Nested >> translation is a hardware feature that supports two-stage translation >> tables for IOMMU. The second-stage translation table is managed by the >> host VMM, while the first-stage translation table is owned by user >> space. This allows user space to control the IOMMU mappings for its >> devices. >> >> When an IO page fault occurs on the first-stage translation table, the >> IOMMU hardware can deliver the page fault to user space through the >> IOMMUFD framework. User space can then handle the page fault and respond >> to the device top-down through the IOMMUFD. This allows user space to >> implement its own IO page fault handling policies. >> >> User space indicates its capability of handling IO page faults by >> setting the IOMMU_HWPT_ALLOC_IOPF_CAPABLE flag when allocating a >> hardware page table (HWPT). IOMMUFD will then set up its infrastructure >> for page fault delivery. On a successful return of HWPT allocation, the >> user can retrieve and respond to page faults by reading and writing to >> the file descriptor (FD) returned in out_fault_fd. > > This is probably backwards, userspace should allocate the FD with a > dedicated ioctl and provide it during domain allocation. Introducing a dedicated fault FD for fault handling seems promising. It decouples the fault handling from any specific domain. I suppose we need different fault fd for recoverable faults (a.k.a. IO page fault) and unrecoverable faults. Do I understand you correctly? > If the userspace wants a fd per domain then it should do that. If it > wants to share fds between domains that should work too. Yes, it's more flexible. The fault message contains the hwpt obj id, so user space can recognize the hwpt on which the fault happened. Best regards, baolu