Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4052143rdb; Mon, 11 Dec 2023 07:36:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH9a15m/rvzP7+dH7McpCRp3B7gOtLg/ZZNnsZ6AGRSOj6zUptTTXkEfkZ/rqNF30/06U6 X-Received: by 2002:a05:6a20:8423:b0:18f:97c:8246 with SMTP id c35-20020a056a20842300b0018f097c8246mr2549221pzd.80.1702309015991; Mon, 11 Dec 2023 07:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702309015; cv=none; d=google.com; s=arc-20160816; b=p7NOHBkRM8t7y1KjDlzoq52VuQamuaFiIybccpOjcqdVI5YQWut2HP8LwAql1M1JEe bgGzGblwNkEmuVngZPvcSx4VpvXWhscoDH4M/cwX2aoFSMQuRxNbVryiLyBCrC9/jZmd j+QqMo+NSHuPxCNbtJSOVLU4SwhOIHyduORvfky5m9Y8w8DTj04HxtuAEsoi5ZY1QmDS 7bxR30rszfWTKJpF01bPyB/+apLilz5yr6bEMhfvp4vSIg28r8/B5QvqDeg7I5BERxwf +EWX5dskRj1M//VS20bbN3OyLT0U1Mqs95+kWR7ZNPb7k1I78Fe81S42ZK7fb0uE51zX jWrw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=h1q90IyUaHdLCptoKkTSBnvLA7N8/ZWOhYeli5kaqA4=; fh=KT4M/EUYOM5KzQDSXPwnzf4A4PZA/Gt0SMkU/hyP07Y=; b=UQdLNDp4H1aFIbctMPilCzMWOLWotnT+2YDODryXIbGUlg/4XWLGb8V0ftelMbrMni ntBh5v0XxUNWkkqYZPe7jQnZAHvw5cIXL0FFXxLJX/sNcQK+SESj+h7KB9YHaxkeMhLb IDUdrpWLRvt0BOQuCluAwnwrNRGUBM4Wa1cJSq8qdTd1sKtWgSTHSbZYJkA4lqkxqrly ehJSaPcaEO8rvPf4ZBW9zHe7aB2yh6D3ChVAM5N6Leq9w2yq5xRYFU8ZhVTJpVnBfqMB jDFIn7YiWE2OhFPx1nTOwn0+O+95AVVFr16ZvYvvH1txykGxrNalSh++sWATy9MzPbcw l9EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Kd6WeysL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t15-20020a6564cf000000b005be09b723b7si6071903pgv.636.2023.12.11.07.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 07:36:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=Kd6WeysL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A3CF48089843; Mon, 11 Dec 2023 07:36:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344158AbjLKPgg (ORCPT + 99 others); Mon, 11 Dec 2023 10:36:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344125AbjLKPga (ORCPT ); Mon, 11 Dec 2023 10:36:30 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2048E5 for ; Mon, 11 Dec 2023 07:36:35 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-67ad277a06bso30064376d6.1 for ; Mon, 11 Dec 2023 07:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1702308995; x=1702913795; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=h1q90IyUaHdLCptoKkTSBnvLA7N8/ZWOhYeli5kaqA4=; b=Kd6WeysLupP/7Ajdb+oLoJYeErg+1AyWELbof8xQpToPzW0tzf2R/xKDDmgy1XjGKt HCrYIWl8mxLWrPTNhUHjTAftXwheT2qHvkgdG6AX5cNl6IOoaWoNVAAdRn/FhxukcGbF Gfr/8uijIjWY68zll/7HfwzVvSlGRiIg3o+PqNvZyrLDgPMXyA2t9nmIasp6PFZARViZ Ae8OLgjHR4pdnT0tVANBcdHd52mT3enV5K5YddwlpvuwgAhUC0lSH1/1yhosT5ylkpGk QWdfUQRhyaXH0jlq7/h4kFgHsJfp4npTkoWPHF0ESG9MGgQ/Kjhoi+L7hoorSbFDgXV7 dz3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702308995; x=1702913795; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=h1q90IyUaHdLCptoKkTSBnvLA7N8/ZWOhYeli5kaqA4=; b=L66aOWqFafHPkRXT+eHvMP/Q8vljHNZiL67Q7yS6rwGeJ/Jx5My1V+4M2P7BmfKUc8 2+HDwX8N+F2g48HMt+ZzILGsj0MVGU+PcxSnFdtuEBgl58XbzW6DXFLZeNPf5BFn8krU 8T9mSkSK4WUN9um/NSjDuEx77K+peUnvjvgsgGhfdClfD8h6R0wxn7u5wpqxMi47VVSz Jo51OQULtGFs08Hnq0fOR+kK6hGatqP7p4b79zpSYXt0qSzJ0Tso91QxZ3IiTZBMx3j3 vyZ6G96wH4F9Kap58xU06hzE04ZCMzzJOoEdOpaYNL3xhiwnAeSSoBwWCeUDpLq/p4mf KETg== X-Gm-Message-State: AOJu0YyNd1MvcHt2UjXzcJvQe530/S9Sl31Or1KAG+IIqHQGYup+HC6u G0Mx8yiiRI4KGEYWQyZj2SEEww== X-Received: by 2002:a0c:ee47:0:b0:67a:b99e:4228 with SMTP id m7-20020a0cee47000000b0067ab99e4228mr4459026qvs.52.1702308994824; Mon, 11 Dec 2023 07:36:34 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-134-23-187.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.134.23.187]) by smtp.gmail.com with ESMTPSA id g2-20020ad45102000000b0067a1e5ef6b1sm3324868qvp.106.2023.12.11.07.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 07:36:34 -0800 (PST) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rCiKf-00Ccc2-Kg; Mon, 11 Dec 2023 11:36:33 -0400 Date: Mon, 11 Dec 2023 11:36:33 -0400 From: Jason Gunthorpe To: Will Deacon Cc: Robin Murphy , 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 , 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: <20231211153633.GD1489931@ziepe.ca> References: <2ae6199a9cf035c1defd42e48675b827f41cdc95.1701268753.git.robin.murphy@arm.com> <20231211132757.GE25681@willie-the-truck> <91b22090-485f-49c9-a536-849fd7f92f8e@arm.com> <20231211153023.GA26048@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231211153023.GA26048@willie-the-truck> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 11 Dec 2023 07:36:52 -0800 (PST) On Mon, Dec 11, 2023 at 03:30:24PM +0000, Will Deacon wrote: > 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. Yes, UBSAN generates warnings for these cases. I'm not sure if it is actually undefined C behavior or just "suspicious", but such is what it is.. Jason