Message ID | 20230727054837.147050-4-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp919133vqo; Thu, 27 Jul 2023 00:32:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFRjXgMsf/AztWAITBjxjMLYJQTdpBLdzGkZ4mBEr7E0pal0ecfigl8ydADMDYZuFiP8Gib X-Received: by 2002:a05:6358:341f:b0:134:c384:59dd with SMTP id h31-20020a056358341f00b00134c38459ddmr1926407rwd.23.1690443170183; Thu, 27 Jul 2023 00:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690443170; cv=none; d=google.com; s=arc-20160816; b=KXg2AvEPyAnd6PdwrvG+WvzY142p9mqMjQvCYtK/I0U5zrtPhlQzo/4crMo2P6etrN cwgUDRMVLS1RipcmePUOySQ4WgZe3dl3v9wGzeflYXWJGP4whssdrg1/m1IXHpFExyIp Fnlc8jnUioIL0LP7bGrSiCqll8B7V+cdqeGzv5zzPDT0c7dZuDDFfWmNBjVXBYZjWABh l8YL6bUsLoxpwSOCvOW+ruLmxsjaSa3A22kZkGn8EZhWC2Pbr6gzD0duSbGu7C2BIhsG 2PRbmxv322OhLtlrSvjBJGN+3VU2JaOZAXy7xoLl0TMbwJ5lbXNgpv6kTYYug7+xwmhJ 8Z7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sKntUxEAzGSEAVF55elSO5cPTFo23J1paIU+HKNw3j4=; fh=5v0QJkujOnxKSzhmeWiMX/0q9X35NwMz+SRMkKa4moc=; b=zZM8TWBCyYkozsCSHDxJnyQ33nDFk1f5nrwVpWRRNxEvtuR+sadRSWHlFsB9XV0mJT I7uU4jJZ6FlWYDLOPyZZv+4LGYYj/Jroicocn7Dk357bhYVRa9BA7xaKZf5ZyQVHZjfS lpN5De2GR9Jp1BI70V1YzCf1Ap3IZYCoA+WrR5iHabSCsUVEjZCT3bOg0eAWSqAE/doe E0C7KDhKlfm8HB9dr0t+gn8Hz/peClRZOcA0MmR04Bc3ZjWjWniBSuyaX9lCdBS8uyy4 /eDLcMg8BfCaaAuLCy94QAL+7lzSLdZVdcDcNm1we3bq6YftghnimNFPBW0fYbqs/UyE 9iPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OoLgFOKh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i62-20020a638741000000b005572b2f6ea2si825768pge.272.2023.07.27.00.32.17; Thu, 27 Jul 2023 00:32:50 -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=@intel.com header.s=Intel header.b=OoLgFOKh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbjG0FwB (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Thu, 27 Jul 2023 01:52:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232557AbjG0Fvu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Jul 2023 01:51:50 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B032D67; Wed, 26 Jul 2023 22:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690437084; x=1721973084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+30pZB6ZPoSheBWZc+jWeqUw2NgcW/Yd0m8xdMKPZyM=; b=OoLgFOKhCXF5oBPDSciBGj3Qhn+8xQmemJZtPAczCvXvJeIqXacvzF0n bq9TTn6H7vMihWATj8m3ICiUJ/Q5Qsw/s+u3EJ/YVYgsLjNfoTMQ8ASaZ hI7J52Ph54jmoWtYGPYhnCv3zaO6W+CTiSKJwY99Lp3JNo7PGCkSqoMVx clc8AVL7krgAQUuyddrNRzMlVT6BGF+TTV9AF/YdKMRVmmO8wngaS4GT2 xewphWzV0UJGVPtAQXT+LJZRiVbZJCBW5ZPBEyWWLy7wjryYT7Rydj7Fo rMQHdMkWGbZ3deI20I49KfKjmA8phWV43g4bQJtRTv/6HbneAMpWzrMvH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="399152507" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="399152507" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2023 22:50:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="840585273" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="840585273" Received: from allen-box.sh.intel.com ([10.239.159.127]) by fmsmga002.fm.intel.com with ESMTP; 26 Jul 2023 22:50:56 -0700 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, Jason Gunthorpe <jgg@ziepe.ca>, Kevin Tian <kevin.tian@intel.com>, Jean-Philippe Brucker <jean-philippe@linaro.org>, Nicolin Chen <nicolinc@nvidia.com> Cc: Yi Liu <yi.l.liu@intel.com>, Jacob Pan <jacob.jun.pan@linux.intel.com>, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com> Subject: [PATCH v2 03/12] iommu: Remove unrecoverable fault data Date: Thu, 27 Jul 2023 13:48:28 +0800 Message-Id: <20230727054837.147050-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230727054837.147050-1-baolu.lu@linux.intel.com> References: <20230727054837.147050-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772558137617849286 X-GMAIL-MSGID: 1772558137617849286 |
Series |
iommu: Prepare to deliver page faults to user space
|
|
Commit Message
Baolu Lu
July 27, 2023, 5:48 a.m. UTC
The unrecoverable fault data is not used anywhere. Remove it to avoid
dead code.
Suggested-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
include/linux/iommu.h | 70 +------------------------------------------
1 file changed, 1 insertion(+), 69 deletions(-)
Comments
> From: Lu Baolu <baolu.lu@linux.intel.com> > Sent: Thursday, July 27, 2023 1:48 PM > > struct iommu_fault { > __u32 type; > - __u32 padding; this padding should be kept. > - union { > - struct iommu_fault_unrecoverable event; > - struct iommu_fault_page_request prm; > - __u8 padding2[56]; > - }; > + struct iommu_fault_page_request prm; > };
On 2023/8/3 15:54, Tian, Kevin wrote: >> From: Lu Baolu<baolu.lu@linux.intel.com> >> Sent: Thursday, July 27, 2023 1:48 PM >> >> struct iommu_fault { >> __u32 type; >> - __u32 padding; > this padding should be kept. > To keep above 64-bit aligned, right? I can't think of any other reason to keep it. Best regards, baolu
> From: Baolu Lu <baolu.lu@linux.intel.com> > Sent: Friday, August 4, 2023 10:59 AM > > On 2023/8/3 15:54, Tian, Kevin wrote: > >> From: Lu Baolu<baolu.lu@linux.intel.com> > >> Sent: Thursday, July 27, 2023 1:48 PM > >> > >> struct iommu_fault { > >> __u32 type; > >> - __u32 padding; > > this padding should be kept. > > > > To keep above 64-bit aligned, right? > yes
On 8/4/23 11:51 AM, Tian, Kevin wrote: >> From: Baolu Lu <baolu.lu@linux.intel.com> >> Sent: Friday, August 4, 2023 10:59 AM >> >> On 2023/8/3 15:54, Tian, Kevin wrote: >>>> From: Lu Baolu<baolu.lu@linux.intel.com> >>>> Sent: Thursday, July 27, 2023 1:48 PM >>>> >>>> struct iommu_fault { >>>> __u32 type; >>>> - __u32 padding; >>> this padding should be kept. >>> >> >> To keep above 64-bit aligned, right? >> > > yes Okay, thanks! Best regards, baolu
On Fri, Aug 04, 2023 at 03:51:30AM +0000, Tian, Kevin wrote: > > From: Baolu Lu <baolu.lu@linux.intel.com> > > Sent: Friday, August 4, 2023 10:59 AM > > > > On 2023/8/3 15:54, Tian, Kevin wrote: > > >> From: Lu Baolu<baolu.lu@linux.intel.com> > > >> Sent: Thursday, July 27, 2023 1:48 PM > > >> > > >> struct iommu_fault { > > >> __u32 type; > > >> - __u32 padding; > > > this padding should be kept. > > > > > > > To keep above 64-bit aligned, right? > > > > yes If it is not uapi we should not explicitly document padding (and __u32 should be u32). The compiler will add it if it is necessary. If the compiler isn't right for some reason then something else has gone wrong. Jason
> From: Jason Gunthorpe <jgg@ziepe.ca> > Sent: Wednesday, August 9, 2023 2:40 AM > > On Fri, Aug 04, 2023 at 03:51:30AM +0000, Tian, Kevin wrote: > > > From: Baolu Lu <baolu.lu@linux.intel.com> > > > Sent: Friday, August 4, 2023 10:59 AM > > > > > > On 2023/8/3 15:54, Tian, Kevin wrote: > > > >> From: Lu Baolu<baolu.lu@linux.intel.com> > > > >> Sent: Thursday, July 27, 2023 1:48 PM > > > >> > > > >> struct iommu_fault { > > > >> __u32 type; > > > >> - __u32 padding; > > > > this padding should be kept. > > > > > > > > > > To keep above 64-bit aligned, right? > > > > > > > yes > > If it is not uapi we should not explicitly document padding (and __u32 > should be u32). The compiler will add it if it is necessary. > > If the compiler isn't right for some reason then something else has > gone wrong. > I thought this will be used as uAPI later. I'm fine to leave it be and add the padding when the uAPI is introduced.
On Wed, Aug 09, 2023 at 12:01:52AM +0000, Tian, Kevin wrote: > > From: Jason Gunthorpe <jgg@ziepe.ca> > > Sent: Wednesday, August 9, 2023 2:40 AM > > > > On Fri, Aug 04, 2023 at 03:51:30AM +0000, Tian, Kevin wrote: > > > > From: Baolu Lu <baolu.lu@linux.intel.com> > > > > Sent: Friday, August 4, 2023 10:59 AM > > > > > > > > On 2023/8/3 15:54, Tian, Kevin wrote: > > > > >> From: Lu Baolu<baolu.lu@linux.intel.com> > > > > >> Sent: Thursday, July 27, 2023 1:48 PM > > > > >> > > > > >> struct iommu_fault { > > > > >> __u32 type; > > > > >> - __u32 padding; > > > > > this padding should be kept. > > > > > > > > > > > > > To keep above 64-bit aligned, right? > > > > > > > > > > yes > > > > If it is not uapi we should not explicitly document padding (and __u32 > > should be u32). The compiler will add it if it is necessary. > > > > If the compiler isn't right for some reason then something else has > > gone wrong. > > > > I thought this will be used as uAPI later. I'm fine to leave it be and > add the padding when the uAPI is introduced. Yes Jason
On Thu, Jul 27, 2023 at 01:48:28PM +0800, Lu Baolu wrote: > The unrecoverable fault data is not used anywhere. Remove it to avoid > dead code. > > Suggested-by: Kevin Tian <kevin.tian@intel.com> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> > --- > include/linux/iommu.h | 70 +------------------------------------------ > 1 file changed, 1 insertion(+), 69 deletions(-) Do we plan to bring this back in some form? A driver specific fault report via iommufd? Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Jason
On 2023/8/10 0:59, Jason Gunthorpe wrote: > On Thu, Jul 27, 2023 at 01:48:28PM +0800, Lu Baolu wrote: >> The unrecoverable fault data is not used anywhere. Remove it to avoid >> dead code. >> >> Suggested-by: Kevin Tian<kevin.tian@intel.com> >> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com> >> --- >> include/linux/iommu.h | 70 +------------------------------------------ >> 1 file changed, 1 insertion(+), 69 deletions(-) > Do we plan to bring this back in some form? A driver specific fault > report via iommufd? I can hardly see the possibility. The only necessary dma fault messages are the offending address and the permissions. With these, the user space device model software knows that "a DMA fault was generated when the IOMMU hardware tried to translate the offending address with the given permissions". And then, the device model software will walk the page table and figure out what is missed before injecting the vendor-specific fault messages to the VM guest. Best regards, baolu
On Thu, Aug 10, 2023 at 10:27:21AM +0800, Baolu Lu wrote: > On 2023/8/10 0:59, Jason Gunthorpe wrote: > > On Thu, Jul 27, 2023 at 01:48:28PM +0800, Lu Baolu wrote: > > > The unrecoverable fault data is not used anywhere. Remove it to avoid > > > dead code. > > > > > > Suggested-by: Kevin Tian<kevin.tian@intel.com> > > > Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com> > > > --- > > > include/linux/iommu.h | 70 +------------------------------------------ > > > 1 file changed, 1 insertion(+), 69 deletions(-) > > Do we plan to bring this back in some form? A driver specific fault > > report via iommufd? > > I can hardly see the possibility. > > The only necessary dma fault messages are the offending address and the > permissions. With these, the user space device model software knows that > "a DMA fault was generated when the IOMMU hardware tried to translate > the offending address with the given permissions". > > And then, the device model software will walk the page table and figure > out what is missed before injecting the vendor-specific fault messages > to the VM guest. Avoiding walking the page table sounds like a pretty big win if we could manage it by forwarding more event data.. Jason
On 2023/8/11 0:46, Jason Gunthorpe wrote: > On Thu, Aug 10, 2023 at 10:27:21AM +0800, Baolu Lu wrote: >> On 2023/8/10 0:59, Jason Gunthorpe wrote: >>> On Thu, Jul 27, 2023 at 01:48:28PM +0800, Lu Baolu wrote: >>>> The unrecoverable fault data is not used anywhere. Remove it to avoid >>>> dead code. >>>> >>>> Suggested-by: Kevin Tian<kevin.tian@intel.com> >>>> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com> >>>> --- >>>> include/linux/iommu.h | 70 +------------------------------------------ >>>> 1 file changed, 1 insertion(+), 69 deletions(-) >>> Do we plan to bring this back in some form? A driver specific fault >>> report via iommufd? >> I can hardly see the possibility. >> >> The only necessary dma fault messages are the offending address and the >> permissions. With these, the user space device model software knows that >> "a DMA fault was generated when the IOMMU hardware tried to translate >> the offending address with the given permissions". >> >> And then, the device model software will walk the page table and figure >> out what is missed before injecting the vendor-specific fault messages >> to the VM guest. > Avoiding walking the page table sounds like a pretty big win if we > could manage it by forwarding more event data.. Fair enough. We can discuss what kind of extra event data could be included later when we have real code for dma fault forwarding support in iommufd. Best regards, baolu
> From: Baolu Lu <baolu.lu@linux.intel.com> > Sent: Friday, August 11, 2023 9:16 AM > > On 2023/8/11 0:46, Jason Gunthorpe wrote: > > On Thu, Aug 10, 2023 at 10:27:21AM +0800, Baolu Lu wrote: > >> On 2023/8/10 0:59, Jason Gunthorpe wrote: > >>> On Thu, Jul 27, 2023 at 01:48:28PM +0800, Lu Baolu wrote: > >>>> The unrecoverable fault data is not used anywhere. Remove it to avoid > >>>> dead code. > >>>> > >>>> Suggested-by: Kevin Tian<kevin.tian@intel.com> > >>>> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com> > >>>> --- > >>>> include/linux/iommu.h | 70 +------------------------------------------ > >>>> 1 file changed, 1 insertion(+), 69 deletions(-) > >>> Do we plan to bring this back in some form? A driver specific fault > >>> report via iommufd? > >> I can hardly see the possibility. > >> > >> The only necessary dma fault messages are the offending address and the > >> permissions. With these, the user space device model software knows > that > >> "a DMA fault was generated when the IOMMU hardware tried to translate > >> the offending address with the given permissions". > >> > >> And then, the device model software will walk the page table and figure > >> out what is missed before injecting the vendor-specific fault messages > >> to the VM guest. > > Avoiding walking the page table sounds like a pretty big win if we > > could manage it by forwarding more event data.. > > Fair enough. We can discuss what kind of extra event data could be > included later when we have real code for dma fault forwarding support > in iommufd. > I'm afraid there might be cases where VMM cannot rely on the hw event data. e.g. if there is a misconfiguation in virtual context entry or ste then vIOMMU may decide to unmap and leave IOAS empty to trigger unrecoverable fault when any DMA comes. Then upon notification vIOMMU needs to check virtual context entry/ste to decide the right error code when injecting unrecoverable fault into the guest. Here the hw event data will be about missing stage-2 mapping hence incorrect. and this is not a performance critical path. 😊
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b3537736f9cb..a1e4390d05a8 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -48,69 +48,9 @@ struct iommu_dma_cookie; /* Generic fault types, can be expanded IRQ remapping fault */ enum iommu_fault_type { - IOMMU_FAULT_DMA_UNRECOV = 1, /* unrecoverable fault */ IOMMU_FAULT_PAGE_REQ, /* page request fault */ }; -enum iommu_fault_reason { - IOMMU_FAULT_REASON_UNKNOWN = 0, - - /* Could not access the PASID table (fetch caused external abort) */ - IOMMU_FAULT_REASON_PASID_FETCH, - - /* PASID entry is invalid or has configuration errors */ - IOMMU_FAULT_REASON_BAD_PASID_ENTRY, - - /* - * PASID is out of range (e.g. exceeds the maximum PASID - * supported by the IOMMU) or disabled. - */ - IOMMU_FAULT_REASON_PASID_INVALID, - - /* - * An external abort occurred fetching (or updating) a translation - * table descriptor - */ - IOMMU_FAULT_REASON_WALK_EABT, - - /* - * Could not access the page table entry (Bad address), - * actual translation fault - */ - IOMMU_FAULT_REASON_PTE_FETCH, - - /* Protection flag check failed */ - IOMMU_FAULT_REASON_PERMISSION, - - /* access flag check failed */ - IOMMU_FAULT_REASON_ACCESS, - - /* Output address of a translation stage caused Address Size fault */ - IOMMU_FAULT_REASON_OOR_ADDRESS, -}; - -/** - * struct iommu_fault_unrecoverable - Unrecoverable fault data - * @reason: reason of the fault, from &enum iommu_fault_reason - * @flags: parameters of this fault (IOMMU_FAULT_UNRECOV_* values) - * @pasid: Process Address Space ID - * @perm: requested permission access using by the incoming transaction - * (IOMMU_FAULT_PERM_* values) - * @addr: offending page address - * @fetch_addr: address that caused a fetch abort, if any - */ -struct iommu_fault_unrecoverable { - __u32 reason; -#define IOMMU_FAULT_UNRECOV_PASID_VALID (1 << 0) -#define IOMMU_FAULT_UNRECOV_ADDR_VALID (1 << 1) -#define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID (1 << 2) - __u32 flags; - __u32 pasid; - __u32 perm; - __u64 addr; - __u64 fetch_addr; -}; - /** * struct iommu_fault_page_request - Page Request data * @flags: encodes whether the corresponding fields are valid and whether this @@ -140,19 +80,11 @@ struct iommu_fault_page_request { /** * struct iommu_fault - Generic fault data * @type: fault type from &enum iommu_fault_type - * @padding: reserved for future use (should be zero) - * @event: fault event, when @type is %IOMMU_FAULT_DMA_UNRECOV * @prm: Page Request message, when @type is %IOMMU_FAULT_PAGE_REQ - * @padding2: sets the fault size to allow for future extensions */ struct iommu_fault { __u32 type; - __u32 padding; - union { - struct iommu_fault_unrecoverable event; - struct iommu_fault_page_request prm; - __u8 padding2[56]; - }; + struct iommu_fault_page_request prm; }; /**