lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ae76317f-6ea2-4413-adf9-2260db49b658@samsung.com>
Date: Wed, 5 Nov 2025 13:45:23 +0100
From: Marek Szyprowski <m.szyprowski@...sung.com>
To: James Clark <james.clark@...aro.org>, Robin Murphy
	<robin.murphy@....com>, Nathan Chancellor <nathan@...nel.org>, Nick
	Desaulniers <nick.desaulniers+lkml@...il.com>, Bill Wendling
	<morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, Stephen Rothwell
	<sfr@...b.auug.org.au>, Mark Brown <broonie@...nel.org>, Vinod Koul
	<vkoul@...nel.org>, Arnd Bergmann <arnd@...db.de>, Guodong Xu
	<guodong@...cstar.com>
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
	llvm@...ts.linux.dev
Subject: Re: [PATCH] dma-mapping: Allow use of DMA_BIT_MASK(64) in global
 scope

On 30.10.2025 15:05, James Clark wrote:
> Clang doesn't like that (1ULL<<(64)) overflows when initializing a
> global scope variable, even if that part of the ternary isn't used when
> n = 64. The same initialization can be done without warnings in function
> scopes, and GCC doesn't mind either way.
>
> The build failure that highlighted this was already fixed in a different
> way [1], which also has detailed links to the Clang issues. However it's
> not going to be long before the same thing happens again, so it's better
> to fix the root cause.
>
> Fix it by using GENMASK_ULL() which does exactly the same thing, is much
> more readable anyway, and doesn't have a shift that overflows.
>
> [1]: https://lore.kernel.org/all/20250918-mmp-pdma-simplify-dma-addressing-v1-1-5c2be2b85696@riscstar.com/
>
> Signed-off-by: James Clark <james.clark@...aro.org>

Thanks, applied to dma-mapping-fixes branch.

> ---
>   include/linux/dma-mapping.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 8248ff9363ee..2ceda49c609f 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -90,7 +90,7 @@
>    */
>   #define DMA_MAPPING_ERROR		(~(dma_addr_t)0)
>   
> -#define DMA_BIT_MASK(n)	(((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> +#define DMA_BIT_MASK(n)	GENMASK_ULL(n - 1, 0)
>   
>   struct dma_iova_state {
>   	dma_addr_t addr;
>
> ---
> base-commit: e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6
> change-id: 20251030-james-fix-dma_bit_mask-624dbeb89afa
>
> Best regards,

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ