Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp865982rwd; Thu, 8 Jun 2023 08:45:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KymsDdM8fhLA3JxFvyiRLMpO1329HQ9PMI1ejW9laRfQNVcEnKDJvYtzw880UkpHnYfVc X-Received: by 2002:a05:6a21:6801:b0:10c:2fce:96cc with SMTP id wr1-20020a056a21680100b0010c2fce96ccmr2970796pzb.34.1686239136300; Thu, 08 Jun 2023 08:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686239136; cv=none; d=google.com; s=arc-20160816; b=Acppy4hgp0JMxhXwbtgZW3qNSfZhj848bJnZT9qq9MsJD+c9UcQr0wFpci6P854Z8b hmEkKHrSGiBpjOpi/udO4mNzJp+gz2CN4MKfLwfDB2ysl5N9U0/Sw0jmLONnfT/LoQAV oIWVxFOR1bw1Kja6jfTrlGmGOWskFdG8zPcnWQNBS/APrYmn1wjzlnj59xdbZfM8AXmb m0HT+KvheuSQkY6zwpxfXAhsStcVA+wWPeXH+iItgpkx5j6l4DJzhKaCKcY+DBIfFUpN wxr1yTt8b1yfQKgFpfCMHf6yA1A0G7SHBbXm7KsUEJfdOxGUC/+bv8aCGb322b9V9Roo vY7Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3iuGeQQyuOHjoeSnblBZiJIG1TOJKc2320XfKldAmPw=; b=I8dlTqBTJTl4dZiw0Bd/t7ln2VGtsNDGmFuM0/l7clHTkGuyx85CUxy/Dw0oOyyTaP 8RM+/GMPbPlsN/jWOovpc3PDOX4fwmzL8OZPRk1/gRgHPJBhboEhC2aKAEXgnV++3eYl 5Aqq/LCla4K3p2QC23zSZ2c9oc75NM5OBg/xLSoFjqi8gdMdCHCB+pZl1jcG0Ia9d3yu C0IipiR98sD5oBBjaS2J47w1Qe3x0eIO+bQz6PZGABTulKvsn0aOA5wdO0PthuePqY9+ QbL65j8z7gm3l55OZDtnLusvQBFcTnFYe1VzEIHmr8B+fzwD5QaZS5T6HOi4ktloqEWB w59g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FmerjxWo; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020aa79685000000b006436618b22bsi977351pfk.155.2023.06.08.08.45.21; Thu, 08 Jun 2023 08:45:36 -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=FmerjxWo; 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 S237064AbjFHPk3 (ORCPT + 99 others); Thu, 8 Jun 2023 11:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237007AbjFHPk2 (ORCPT ); Thu, 8 Jun 2023 11:40:28 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53B072D47; Thu, 8 Jun 2023 08:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686238826; x=1717774826; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=76q0pz9uYJGQjyuhbeXuJKxSn4Jgx8OqTCzaDPYghZk=; b=FmerjxWosD8uQ3FdESqOHQEwz2tT1IHt3VcI7bhtrdjwwMEwINabg2CR 5ojulD+DUIqI+HahI9e/Kfb/WrC6plmQ0zAhqKLaTyGPoZ70OUK9mqPRG nNXsEMOyvT8F6540ZdrJcJgczq1n5Dj8G5HnDAquF3X1umrZwDFnUJ3Ys GEau0FxRyMbnOWf4dorTH2JFvIB+HrX4UPfzlPMetIoT9GPlnBoQWxXfo ZJd8xK/64pQp3ZuE5gUYaNZkskRwTO101oNdoAZBfo23fgmV5JyoYCb51 cCXHD0Oa0SXuab66ODXyxtTdVVb8HcMYzNSuRJ8u/hVkKta75ivlmdwAr g==; X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="354830428" X-IronPort-AV: E=Sophos;i="6.00,227,1681196400"; d="scan'208";a="354830428" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 08:40:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10735"; a="884244181" X-IronPort-AV: E=Sophos;i="6.00,227,1681196400"; d="scan'208";a="884244181" Received: from araj-dh-work.jf.intel.com (HELO araj-dh-work) ([10.165.157.158]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 08:40:08 -0700 Date: Thu, 8 Jun 2023 08:38:37 -0700 From: Ashok Raj To: Alexander Duyck Cc: Baolu Lu , LKML , linux-pci , iommu@lists.linux.dev, Ashok Raj Subject: Re: Question about reserved_regions w/ Intel IOMMU Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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,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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 08, 2023 at 07:33:31AM -0700, Alexander Duyck wrote: > On Wed, Jun 7, 2023 at 8:05 PM Baolu Lu wrote: > > > > On 6/8/23 7:03 AM, Alexander Duyck wrote: > > > On Wed, Jun 7, 2023 at 3:40 PM Alexander Duyck > > > wrote: > > >> > > >> I am running into a DMA issue that appears to be a conflict between > > >> ACS and IOMMU. As per the documentation I can find, the IOMMU is > > >> supposed to create reserved regions for MSI and the memory window > > >> behind the root port. However looking at reserved_regions I am not > > >> seeing that. I only see the reservation for the MSI. > > >> > > >> So for example with an enabled NIC and iommu enabled w/o passthru I am seeing: > > >> # cat /sys/bus/pci/devices/0000\:83\:00.0/iommu_group/reserved_regions > > >> 0x00000000fee00000 0x00000000feefffff msi > > >> > > >> Shouldn't there also be a memory window for the region behind the root > > >> port to prevent any possible peer-to-peer access? > > > > > > Since the iommu portion of the email bounced I figured I would fix > > > that and provide some additional info. > > > > > > I added some instrumentation to the kernel to dump the resources found > > > in iova_reserve_pci_windows. From what I can tell it is finding the > > > correct resources for the Memory and Prefetchable regions behind the > > > root port. It seems to be calling reserve_iova which is successfully > > > allocating an iova to reserve the region. > > > > > > However still no luck on why it isn't showing up in reserved_regions. > > > > Perhaps I can ask the opposite question, why it should show up in > > reserve_regions? Why does the iommu subsystem block any possible peer- > > to-peer DMA access? Isn't that a decision of the device driver. > > > > The iova_reserve_pci_windows() you've seen is for kernel DMA interfaces > > which is not related to peer-to-peer accesses. > > The problem is if the IOVA overlaps with the physical addresses of > other devices that can be routed to via ACS redirect. As such if ACS > redirect is enabled a host IOVA could be directed to another device on > the switch instead. To prevent that we need to reserve those addresses > to avoid address space collisions. Any untranslated address from a device must be forwarded to the IOMMU when ACS is enabled correct? I guess if you want true p2p, then you would need to map so that the hpa turns into the peer address.. but its always a round trip to IOMMU. > > From what I can tell it looks like the IOVA should be reserved, but I > don't see it showing up anywhere in reserved_regions. What I am > wondering is if iova_reserve_pci_windows() should be taking some steps > so that it will appear, or if intel_iommu_get_resv_regions() needs to > have some code similar to iova_reserve_pci_windows() to get the ranges > and verify they are reserved in the IOVA. >