Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4048297rdb; Mon, 11 Dec 2023 07:31:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfGgFxvpBiE4RTQg95XjHigLNPjG4vTmqB32xYq2lnR8iJ+IS5T3NZmDbrm5AzMbenwxHZ X-Received: by 2002:a17:90a:c7cf:b0:286:b8a1:f1a2 with SMTP id gf15-20020a17090ac7cf00b00286b8a1f1a2mr1810739pjb.44.1702308678790; Mon, 11 Dec 2023 07:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702308678; cv=none; d=google.com; s=arc-20160816; b=OUIitAMWmvugeJI6S9INs1cegYRWXUUnj1MagegWBqvVxvptdTWXNcZYJ+KGJ5yuYa ExJ4i1vsqF+PLZtnn5/5l3qUdcU+uOThneTav99f5DeF+Wv9CGPeFeKiIgyCsFJpHfmf JV3slNRI0ok0PPJj5eOSCYMIsCBfCts/qsL/kWHYtPF7mtjXgLgGgY/BxCcnZZCKlCDb v7Rsp9n9zFhL/0Qu2o2wIMvTnUCwBfBcukAqKTn6lMDDxoayzvuXNjlmsdZilOOMmDN3 Ju5Qmdk9mZVYiplhHUF6u4BYK35Fp13gn+HaJk3uD4+BypBhcU4Y8IMC9kGyihNY6hzg wXpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8xi/xGVh/2X/SVAicynMli3zcHVtzGXW5YkyKFa3kaY=; fh=zEh6gcAvF6cu7Bgh8fftLetNLrvvqAqYFTVkhunBPrs=; b=ZinZQj7V3w/rszeJmEBC0NXczywe0d7zycGlgFdHQtwH9da4igxbhYz/S7Ovwjdjc5 8hHe1kAzWHIDseuT/ewur7FgwvhgJfE8dNAygxlRlDT0V80wYUgtYcqE+GfUlCkOQu8X aNY9ATW53B0THUQ+U2RAhIZbFdaCu4LlVQ70YpyO/d1fPLVr1PUhJq1jwBdQI27WI+7J rHbLcJ79GQ5fWMNrRh8ERuFKQfBCywQZ02X86oA9+b6wREgATnK6W+3uf/SQu0Z1T1yc 25gHomkczKsIZUkyvKJ59dRaHbtwrau9Dz6p0f08vozUqIiXW/RsRc21mouSzxQNBg6Y S4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KYfQtKQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id gx6-20020a17090b124600b0028a1ee84596si6297331pjb.186.2023.12.11.07.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 07:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KYfQtKQq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E128C807C856; Mon, 11 Dec 2023 07:30:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343922AbjLKPa3 (ORCPT + 99 others); Mon, 11 Dec 2023 10:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234938AbjLKPa1 (ORCPT ); Mon, 11 Dec 2023 10:30:27 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB5CED for ; Mon, 11 Dec 2023 07:30:34 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0802C433C8; Mon, 11 Dec 2023 15:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702308633; bh=/Q/CO2qks8dFDHzFLXjWAPDdN+fTVkPHlrET0acGnpo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KYfQtKQqfbt28442XHv+EFC1AIN9ykQs7HiHfK60S/GFWPuNrPR21RFeG3odtUkj1 PQdLGeQ7Dj9r9gomv7Y96bzm6rEEb67gBL2swNErG64/tjOWml+uGFCNDutqFUuWYs bKBc92oC+gJTZ0cfo7pFXmwpv39v4hvlCtH6EU8vp21o/fwt1yuuSsG9ltmFSw8owj pjY2vBqTtpgm49TFlcShfsiAXfzygLabIQUSGpeLeOaEHtxso6Pa10H7OrmwC9fNMf 3KGgA+dzYMGZmEjxO0FYuwqeOOiSuZv9xx39lZD6s2m40mGFrGCHxmzsic+6dFyIe0 ymi88cjfcV9Ng== Date: Mon, 11 Dec 2023 15:30:24 +0000 From: Will Deacon To: Robin Murphy Cc: Joerg Roedel , Christoph Hellwig , Vineet Gupta , Russell King , Catalin Marinas , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Suravee Suthikulpanit , David Woodhouse , Lu Baolu , Niklas Schnelle , Matthew Rosato , Gerald Schaefer , Jean-Philippe Brucker , Rob Herring , Frank Rowand , Marek Szyprowski , Jason Gunthorpe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org Subject: Re: [PATCH 3/7] ACPI/IORT: Handle memory address size limits as limits Message-ID: <20231211153023.GA26048@willie-the-truck> References: <2ae6199a9cf035c1defd42e48675b827f41cdc95.1701268753.git.robin.murphy@arm.com> <20231211132757.GE25681@willie-the-truck> <91b22090-485f-49c9-a536-849fd7f92f8e@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <91b22090-485f-49c9-a536-849fd7f92f8e@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 11 Dec 2023 07:30:42 -0800 (PST) On Mon, Dec 11, 2023 at 03:01:27PM +0000, Robin Murphy wrote: > On 2023-12-11 1:27 pm, Will Deacon wrote: > > On Wed, Nov 29, 2023 at 05:43:00PM +0000, Robin Murphy wrote: > > > Return the Root Complex/Named Component memory address size limit as an > > > inclusive limit value, rather than an exclusive size. This saves us > > > having to special-case 64-bit overflow, and simplifies our caller too. > > > > > > Signed-off-by: Robin Murphy > > > --- > > > drivers/acpi/arm64/dma.c | 9 +++------ > > > drivers/acpi/arm64/iort.c | 18 ++++++++---------- > > > include/linux/acpi_iort.h | 4 ++-- > > > 3 files changed, 13 insertions(+), 18 deletions(-) > > > > [...] > > > > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > > > index 6496ff5a6ba2..eb64d8e17dd1 100644 > > > --- a/drivers/acpi/arm64/iort.c > > > +++ b/drivers/acpi/arm64/iort.c > > > @@ -1367,7 +1367,7 @@ int iort_iommu_configure_id(struct device *dev, const u32 *input_id) > > > { return -ENODEV; } > > > #endif > > > -static int nc_dma_get_range(struct device *dev, u64 *size) > > > +static int nc_dma_get_range(struct device *dev, u64 *limit) > > > { > > > struct acpi_iort_node *node; > > > struct acpi_iort_named_component *ncomp; > > > @@ -1384,13 +1384,12 @@ static int nc_dma_get_range(struct device *dev, u64 *size) > > > return -EINVAL; > > > } > > > - *size = ncomp->memory_address_limit >= 64 ? U64_MAX : > > > - 1ULL<memory_address_limit; > > > + *limit = (1ULL << ncomp->memory_address_limit) - 1; > > > > The old code handled 'ncomp->memory_address_limit >= 64' -- why is it safe > > to drop that? You mention it in the cover letter, so clearly I'm missing > > something! > > Because an unsigned shift by 64 or more generates 0 (modulo 2^64), thus > subtracting 1 results in the correct all-bits-set value for an inclusive > 64-bit limit. Oh, I'd have thought you'd have gotten one of those "left shift count >= width of type" warnings if you did that. Will