Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp180637rdb; Tue, 31 Oct 2023 04:47:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUnkhwPnWrX496AOLWvfaKnTbguosvxFmszoDDemDJXPJbmXZG0Ic9CkmnKracWImz3p/E X-Received: by 2002:a05:6a20:da88:b0:174:af85:954b with SMTP id iy8-20020a056a20da8800b00174af85954bmr13876323pzb.22.1698752836226; Tue, 31 Oct 2023 04:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698752836; cv=none; d=google.com; s=arc-20160816; b=yAWKNGLq7Sg8R3Aid8xtQwKmH98FK3vLXsHTMxCUUlmQqkE+oxsjtLL9aXjTj4G+78 VZ67q44l6u+O9nYVzSRyncTebfXiRDweNq+lM/Zw0DbxdNeugLIWxhFd6FwJT6QhV/Sa RalXtJQf3GKM+oIT6mz0NK79MKjG/nOw/Ta1Q4OzfzwmPmZcahSw4gI20Dv6n5yl2MXl bNGtVqp2PgC75sVB68tCGFqMhmp4tryJ6wqO+uk4rglGhZrdOh4JrcuBXdRCvxtj/LgR oCFiPP6uicBktwHMlMLRvz99WmJMzta1IbyPAzxJaqQxcWEst13FHw05nv7ix855sZhK x7vQ== 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:cc:to:subject:user-agent:mime-version :date:message-id; bh=fkoF/zN8tehC+24mewHz3zUl3V012dXwKUePrztCxfo=; fh=pJueioYhnQTj6/EnT2FNlMxqnrxyQIujIDTTEf1wuaA=; b=QF3F/i3p5m14pNHqLWv0L78zdqHtb/UUw6taSer6UP1elBnFH9SU+LGGksCwPNru6K fiy4WxsXCCca2GGpXG07RdoofkkYPIrWaJ2KWpSOgEvWpgo0hQDYQtzXEqA0gAngyEuP W+Myjk+NHgfgQGjgeWY9+Car1lfvDWo0psmjjvV4yso7aG3A259ZGl8+YkEM79WtdHt0 PijpX6VI2G38S2GkMh2FoMl6WmZK9UKOea1HWXwYnNHaQsWrAlscWi0Q3OGVrqsJbm9B rWW/b11M1i5w46TM3Zg1CsJfhYh+7U2pWXtrO62CVd9jUcT5GeZCit12lhlnsde7SHCQ VmOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id lp12-20020a17090b4a8c00b00271ae22eea7si878322pjb.117.2023.10.31.04.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 04:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2F93880232BA; Tue, 31 Oct 2023 04:47:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344059AbjJaLq5 (ORCPT + 99 others); Tue, 31 Oct 2023 07:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344042AbjJaLq5 (ORCPT ); Tue, 31 Oct 2023 07:46:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9AE2591; Tue, 31 Oct 2023 04:46:54 -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 E613EC15; Tue, 31 Oct 2023 04:47:35 -0700 (PDT) Received: from [192.168.1.102] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B92C33F64C; Tue, 31 Oct 2023 04:46:52 -0700 (PDT) Message-ID: <3fc50cc1-e4b1-49f9-a0f3-cc527d942e00@arm.com> Date: Tue, 31 Oct 2023 11:46:47 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: IOVA address range To: Bjorn Helgaas , Eric Pilmore Cc: linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, Joerg Roedel , Will Deacon , iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20231030181622.GA1878727@bhelgaas> Content-Language: en-GB From: Robin Murphy In-Reply-To: <20231030181622.GA1878727@bhelgaas> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=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]); Tue, 31 Oct 2023 04:47:11 -0700 (PDT) On 2023-10-30 6:19 pm, Bjorn Helgaas wrote: > [+cc folks from ./scripts/get_maintainer.pl -f drivers/iommu] > > On Fri, Oct 27, 2023 at 12:17:17PM -0700, Eric Pilmore wrote: >> Need a little IOVA/IOMMU help. >> >> Is it correct that the IOVA address range for a device goes from >> address 0x0 up to the dma-mask of the respective device? >> >> Is it correct to assume that the base of the IOVA address space for a >> device will always be zero (0x0)? Is there any reason to think that >> this has changed in some newer iteration of the kernel, perhaps 5.10, >> and that the base could be non-zero? >> >> I realize an IOVA itself can be non-zero. I'm trying to verify what >> the base address is of the IOVA space as a whole on a per device >> basis. In short, "No." In detail, it depends on the architecture, since there are still a number of different IOMMU-based DMA API backends. Off-hand I do know that 32-bit Arm allocates upwards from 0, since there are some drivers annoyingly relying on that behaviour. I've never looked too closely at what the likes of Alpha, Sparc and PowerPC do. The generic IOVA allocator used by iommu-dma on x86, arm64, and soon s390, allocates top-down, but for historical reasons has a special behaviour for PCI devices where it tries to stay below the 32-bit boundary and only goes up to the full DMA mask (if larger) once that space is full. iommu-dma also always reserves 0 as an invalid IOVA - initially this was more of a convenience measure to help catch certain potential bugs, but it's long since also been relied upon as a special value in the internal caching mechanism. Note also that any device may have holes reserved anywhere in its otherwise-usable address space, and/or its entire notion of usable ranges constrained as described by firmware (e.g. a devicetree "dma-ranges" property or ACPI "_DMA" method). Thanks, Robin.