Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp618674rdg; Thu, 10 Aug 2023 13:39:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrOfX0yJJZkVO1o+8GXFWGxR1U9dYMPFaPizXK4wtYdyJCH7UL3mPDLTioY6aNx9LAGmqj X-Received: by 2002:a17:902:ce8d:b0:1b0:307c:e6fe with SMTP id f13-20020a170902ce8d00b001b0307ce6femr4472621plg.10.1691699999399; Thu, 10 Aug 2023 13:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691699999; cv=none; d=google.com; s=arc-20160816; b=tcH0FC/Gn4fWVF6yzTNFeN253Qg6wD2h4EYDHhR4PJgxgt6Am8GeIlKcsIumXAswso 7nx1SjCn+vG68mwVUrGtriYVW843PUDls1jzPMpGKlpn07ZHvLIasJD065PCKvJSod7H 1fInFJGLv6ndiwPSZyeEVguc+SZ4wLple1y8dHfukDviaZAQVwa5zwAKNrXKs9KAtHg6 oMZO8suP8f+I1ERnpSQOBZheIKVicu91dozqKvg4/XNW2Z7OszSDeQ/mzcyZdxhTaqSM qxtihN0Vkxd2a97/vG9qKWstN1yXr83rQHv6nIUimjdEL4CTKdk/iZ5r9LSMr4t8Z/vz EHqQ== 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=6nK40dlXSEtV9j+1clrTX2RCnnQWiTsk3pHmbVPkUwY=; fh=xltAmSPd/yLdUi9FHi45DAi3RH3y0htPE7VC5DZecA8=; b=mhjn98zuzEz9F3bBM4pbSdOzS5vXlO34JIbikX4y+HV2RPLAFaFU3JszMg0OZB4zPq zBU/gyPj/lgTKF8Inn5lCjLXQb3H2QSAErrHmXNGxB+L21RFfDOoMX644j9xJIGiOniu VnJGDWN+TjiRBDGZYQY5x/25hz18OPi0KR2DTPHyhTuz2nUCJYypLefAYO0yo2ErnVFV d2OTlVXcH2499XNFcHmwJWVP9W8jxRa4VVVb+f4PAmdwo/W5LMO2P4H3y/nt1u70nNrm PFhbKpX8avgDYNYz5ScHg3BDYznA8cEt9i7FKRFd6YEY+Td1+x6eayQ5ec/8wBW3PiTD FkcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VmBkafl1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a1709028bcb00b001b7f492469dsi1901940plo.434.2023.08.10.13.39.47; Thu, 10 Aug 2023 13:39:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=VmBkafl1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235390AbjHJTTJ (ORCPT + 99 others); Thu, 10 Aug 2023 15:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjHJTS4 (ORCPT ); Thu, 10 Aug 2023 15:18:56 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 530A42723 for ; Thu, 10 Aug 2023 12:18:56 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id 6a1803df08f44-64189860374so3499586d6.0 for ; Thu, 10 Aug 2023 12:18:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1691695135; x=1692299935; 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=6nK40dlXSEtV9j+1clrTX2RCnnQWiTsk3pHmbVPkUwY=; b=VmBkafl1u25d2ecLyUc29ulrsvOSkhhEKJzuIU93CMtsoCspLy4ihE6XAu6q0FKV7H 7LnJGstvlp0byYFZseM2BaVUeXnNZLL+R2jOlaxU4o1Ud/nwJDZ3AlwHHAWddr1hdDAg 8Alv1t72xMjHMEMMtHU9bWogP2hPkCqxEH22qnX5LDAMnjcCIdacsNJpfbyNjw80iyd3 0Xa721kMEsJQYgnTNhLDNMaDAoCHiSoBnKuy0rN8Z+NmXMYhiCdRQJSBHOdZ5K2x7LBG 538LpY5D5oj+OGHc81pQ5kls8HpXumbdw5zvGYkIXTJUyb1xkQ++ypNWCPge9FRsMSvh zm7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691695135; x=1692299935; 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=6nK40dlXSEtV9j+1clrTX2RCnnQWiTsk3pHmbVPkUwY=; b=Qyl6wT9mywITYwAXWrsDiEOpTlxU4koYJFw0JgXxUNhH2qnNqjsL3X4d2nTKBHsnKG oMMRvBuxQhTeoFPsDY2veOAlsLUR/NZEUHlK/5ubbZU+nti9+cZYSCZdG922bciHUBpM NPiMYcZYHbBSokSD6HOfAmJKJ+qozyqv36veDX0kp7dTVSpug+qPN+9hEsr1k4djDVqm CAPyyMSCjTuXESc9dKG77s5xMtjikDY2kAXQuL2uKFAZ1+XcTAc/NwmH98E58L05I8X3 BYAPpQf9JBX5ihZqPg+yRcWTyYL8WbRaWahctKsR/uShXSA4sYj7Lw1OqOT35sGrLOlq oQvg== X-Gm-Message-State: AOJu0YxYNmTVsprHt9Tg+aF0nqPt8iqM7dDlwA+acn/hqv5NqAA5vjhR NG5/GAKkXHE7dSXLVYoMLQgoPKJ1kYci4c6an7Y= X-Received: by 2002:a05:6214:15c3:b0:635:e528:5213 with SMTP id p3-20020a05621415c300b00635e5285213mr3435331qvz.23.1691695135500; Thu, 10 Aug 2023 12:18:55 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id i9-20020a0cab49000000b0063d316af55csm694456qvb.3.2023.08.10.12.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 12:18:54 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1qUBBO-005Ips-5n; Thu, 10 Aug 2023 16:18:54 -0300 Date: Thu, 10 Aug 2023 16:18:54 -0300 From: Jason Gunthorpe To: Lu Baolu Cc: Joerg Roedel , Will Deacon , Robin Murphy , Kevin Tian , Jean-Philippe Brucker , Nicolin Chen , Yi Liu , Jacob Pan , iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 12/12] iommu: Add helper to set iopf handler for domain Message-ID: References: <20230727054837.147050-1-baolu.lu@linux.intel.com> <20230727054837.147050-13-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727054837.147050-13-baolu.lu@linux.intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 27, 2023 at 01:48:37PM +0800, Lu Baolu wrote: > To avoid open code everywhere. > > Signed-off-by: Lu Baolu > --- > include/linux/iommu.h | 11 ++++++++++- > drivers/iommu/iommu.c | 20 ++++++++++++++++++-- > 2 files changed, 28 insertions(+), 3 deletions(-) Seems like overkill at this point.. Also, I think this is probably upside down. We want to create the domains as fault enabled in the first place. A fault enabled domain should never be attached to something that cannot support faults. It should also not support changing the fault handler while it exists. Thus at the creation point would be the time to supply the fault handler as part of requesting faulting. Taking an existing domain and making it faulting enabled is going to be really messy in all the corner cases. My advice (and Robin will probably hate me), is to define a new op: struct domain_alloc_paging_args { struct fault_handler *fault_handler; void *fault_data }; struct iommu_domain *domain_alloc_paging2(struct device *dev, struct domain_alloc_paging_args *args) The point would be to leave the majority of drivers using the simplified, core assisted, domain_alloc_paging() interface and they just don't have to touch any of this stuff at all. Obviously if handler is given then the domain will be initialized as faulting. Jason