Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp865597rwd; Thu, 8 Jun 2023 08:45:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5uJjkKmEasyPyEZYFNyqD5r5NN1ejp6vT0SvVNuXrysqWmfTbvy5po2dpKty7fGzC457Aw X-Received: by 2002:a17:90a:3c8f:b0:24e:6a6:cd6 with SMTP id g15-20020a17090a3c8f00b0024e06a60cd6mr4508527pjc.29.1686239117761; Thu, 08 Jun 2023 08:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686239117; cv=none; d=google.com; s=arc-20160816; b=sKhq2UoFlItvw2VQ38xjIR8mOgPa6z5PDSxMZooXAHBypCj0twvFKdpL+CPbj4BEtV ExlwKt9mdyobOaLkRgSIbqDP482FGNsu7k0Yl9f8MbuaJV6wex1mPw+Eh3CP8uLz0zgN hmr6HHXnRmB/bubF3vp4c2Icj/iFx4BlYVQgsVwku1Wg/nDPTwUZE71ZIdFrGGGumG8q PJGt9e6GmdtB9E3sXFgiWp/hBM4kfK1bvYmF16uZicsB4taylemGpYXcFfMfRDrnfFij bh0zgprXWB9+d5TcKKFV75IZZ7ru5cYfp6zd16qO4sHAXkWycANfmXlgPw8k4SioCN/J jV5g== 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 :content-language:references:to:subject:user-agent:mime-version:date :message-id; bh=icMANqwPUnR0amNezat7sR3Un/JI74TaPNZRvVD6ZuQ=; b=jYyj218dcHi5wj+qz2RFgbIk4yNU0DZfrVTrKxxZv2nF40YMyGy7J8I+R7zZ1Cdk2u sjl+5vW+Gs8rkAIudzgSZPpujkIZMYb8MtvKiMGyHOVgeMzpBt3ZXVTCT0wY1nn86vOB IURMUAW6udXpER6L5B669X8H8pCK8L3CwEMqoIAp3mBf778jWxwVg/rfQhYujE0Yo0m8 Wo/d2HuXLdQYzX3uk/XmmgHQRKIsdYgJ7Qa/tFyjHk4A0zNKaKOR7lSjumiwXT9+jveX Akn9Cn1MCCtO5XLZB0qDtDASnkuWpjPfqyZ9qgSyJZqOeQUusPYVGCte5ixysNrYSLTR awWQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020a17090abb9700b00255d8dda719si1197517pjr.148.2023.06.08.08.45.03; Thu, 08 Jun 2023 08:45:17 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235100AbjFHP2s (ORCPT + 99 others); Thu, 8 Jun 2023 11:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235704AbjFHP2p (ORCPT ); Thu, 8 Jun 2023 11:28:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3CAF2D70; Thu, 8 Jun 2023 08:28:36 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 32679AB6; Thu, 8 Jun 2023 08:29:22 -0700 (PDT) Received: from [10.57.83.198] (unknown [10.57.83.198]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CB8B53F6C4; Thu, 8 Jun 2023 08:28:35 -0700 (PDT) Message-ID: Date: Thu, 8 Jun 2023 16:28:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: Question about reserved_regions w/ Intel IOMMU To: Baolu Lu , Alexander Duyck , LKML , linux-pci , iommu@lists.linux.dev References: Content-Language: en-GB From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 2023-06-08 04:03, 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. Right, in general the IOMMU driver cannot be held responsible for whatever might happen upstream of the IOMMU input. The DMA layer carves PCI windows out of its IOVA space unconditionally because we know that they *might* be problematic, and we don't have any specific constraints on our IOVA layout so it's no big deal to just sacrifice some space for simplicity. We don't want to have to go digging any further into bus-specific code to reason about whether the right ACS capabilities are present and enabled everywhere to prevent direct P2P or not. Other use-cases may have different requirements, though, so it's up to them what they want to do. It's conceptually pretty much the same as the case where the device (or indeed a PCI host bridge or other interconnect segment in-between) has a constrained DMA address width - the device may not be able to access all of the address space that the IOMMU provides, but the IOMMU itself can't tell you that. Thanks, Robin.