Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2344917rdb; Fri, 8 Dec 2023 05:43:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFC+XX0nx2Op9fnDP/2ppxlJMfCZAac4AoSUqNJ+Cxo8QRWETtas/Uu8dwkLi/vNWjp8kBu X-Received: by 2002:a05:6a00:1143:b0:6ce:51ec:5fb7 with SMTP id b3-20020a056a00114300b006ce51ec5fb7mr23577pfm.28.1702043011418; Fri, 08 Dec 2023 05:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702043011; cv=none; d=google.com; s=arc-20160816; b=RbfyxpMojgNWl0SiCTbCtsBeb/oM47KOt/h6wpLjAPs+uwTIYhizcKoZbbFnSprGDu 6+LFfbrgdtf3ryrsJ/mFdBbu5vUw/S6uDVXuE0Evha4jn6Gk0C85gJU37QxhphOiFDBU OAOvc+MWVHdFBGtvQ70oUO0Tpy8jg9fu7fC/wGjlLzYWgEfa+2lAI3PFNu7DReiIL0fo BmfsukxliotBevXDaku1qzOsGB1YaXwmzcr2Nj4YUqT+plSwqPJ86S9d2HlMQnftq5GD oDJtMvrgJ2WeNkps9M58wp3Wg0V4T15rGF8RlQa3gA1Tjv/ev8e2ElynqtyNv2eHfhEP wfXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5aDtOWyPfn3w5tEvf3D6QXjzQ1IFO5OBYuP3/lTcT5U=; fh=CBWCtb4GSMytm7XSoUsnrCdGk/s7UeLePfh8sKtI1BE=; b=R+jfaaWP5vhgrTSwKhjQnt7saloNRacdb9sskEWs14SWDmrBxFv5GL4UlwZJhAbdMd K0aw1zXB/CNl6EXX2tN/fZsO31Ps9AWJpjQ0yu7zB5PdReujIH/SzL9nMxB0X1inDKuN AtVSSHyI6rOzrd54rzWusS88RtrHt9kWA2ebIpIYWwBaLkotZxt7h7nx4XpXSOv+xoAh fl6hXlsRMvWWrVoka0ojHbItkEOBxNqYuoPa0IM8yBIb/Xbx3NV8Nh/Mwcx/ho3bk6vJ lpAZhjNhxNZWzOJQRUvb1ywZu+o+9i09kHRRiR9x6vcGjKHSTyPbnXMvh9vbROVGij+v kHDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=buHJY8oh; 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 Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id g11-20020a056a0023cb00b006b9fd40d6cfsi1616620pfc.216.2023.12.08.05.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 05:43:31 -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=@ziepe.ca header.s=google header.b=buHJY8oh; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id CB54D8116E66; Fri, 8 Dec 2023 05:43: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 S233654AbjLHNnP (ORCPT + 99 others); Fri, 8 Dec 2023 08:43:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233490AbjLHNnO (ORCPT ); Fri, 8 Dec 2023 08:43:14 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58CE1706 for ; Fri, 8 Dec 2023 05:43:19 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-77f58040770so11153385a.2 for ; Fri, 08 Dec 2023 05:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1702042999; x=1702647799; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=5aDtOWyPfn3w5tEvf3D6QXjzQ1IFO5OBYuP3/lTcT5U=; b=buHJY8oh4o30WT7yJj3SYmfBZOvDI5bJAtBVecTIrLoPix3EQS6TLd1gXN01teIcio NCjQFIfykBI1s51YxHg6OmEETgYnJX3Aoju7zvI4WH6d3Ux3tcvZDOqSKQ7Qp5Q8YKPE 7Ogn9ZGGJ/EWuJcZ4mF0QQg32oJ8eqqhzG5tXyqos+MtDrPIGCwCla7vPR5r1/ADaw+2 QZRhhCnlNj44IUbA3v9//jeXhlje0UmmgZCWqOCo4nVFWOrCfSsjhBKC7hXVV323YUiw Ru1ZjQAYklygru4p0k3i83VP+T0PszDF8Puc+CiZmzEntbA6ER2Exsf7fvyxki938iHK iH9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702042999; x=1702647799; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5aDtOWyPfn3w5tEvf3D6QXjzQ1IFO5OBYuP3/lTcT5U=; b=l7Oywm8liyJWNxaWODhyzE9EGz3t1K6bQUwgXp8nNjkkFiNIU00dMsuqdTL0pQ6z3a SlxvLoXRjZ+UU/i+zETndXZiKYArlHI+R26jn/H02+/+Yv1RO/POooeKHdV3zbEdvMER F8jeTpSUlP3hA6RY9KyOhelSzuMft3hmkjVbcNxXs8FRm09Uz6cUP0S6wIxjvti9mr0H w76uvC1weBseQ07OjJm1kddsKsJBVqTR3+wxp2zC/Gdw+n1xb74NK62RmPxewOcU2Zu4 FeFQgVT2YhT/E1D77UgV+dl0IoEDnYKoCd3gFU5EGANllcf04sv0Wkeds9g3i/cHzOFJ UzKg== X-Gm-Message-State: AOJu0Yyb75lPnizqiTr5iDYD3DLilFjT22sZ+XtaL96c4nt7JN0DbxLx iPynXlJDd227UobQ7aaYdZcifA== X-Received: by 2002:a05:6214:e87:b0:67a:a721:b1be with SMTP id hf7-20020a0562140e8700b0067aa721b1bemr5609000qvb.121.1702042998853; Fri, 08 Dec 2023 05:43:18 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-134-23-187.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.134.23.187]) by smtp.gmail.com with ESMTPSA id a19-20020a0cefd3000000b0067abb3f1ad0sm804745qvt.92.2023.12.08.05.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 05:43:18 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rBb8P-00C89F-TH; Fri, 08 Dec 2023 09:43:17 -0400 Date: Fri, 8 Dec 2023 09:43:17 -0400 From: Jason Gunthorpe To: Baolu Lu Cc: 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 Message-ID: <20231208134317.GX1489931@ziepe.ca> References: <20231026024930.382898-1-baolu.lu@linux.intel.com> <20231201142427.GJ1394392@ziepe.ca> <46c80b4e-9f05-4fb2-a31d-7386a41c895a@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46c80b4e-9f05-4fb2-a31d-7386a41c895a@linux.intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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]); Fri, 08 Dec 2023 05:43:28 -0800 (PST) On Fri, Dec 08, 2023 at 01:57:26PM +0800, Baolu Lu wrote: > 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? I haven't thought that far ahead :) Once you have a generic fault FD concept it can be sliced in different ways. If there is a technical need to seperate recoverable/unrecoverable then the FD flavour should be specified during FD creation. Otherwise just let userspace do whatever it wants. Jason