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: <CAH1PCMYWWkThMosDMW=wZZWZ8d_c4_zQWhJOJPKe354LPiV1bA@mail.gmail.com>
Date: Thu, 4 Sep 2025 15:38:21 +0800
From: Guodong Xu <guodong@...cstar.com>
To: Nathan Chancellor <nathan@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, Naresh Kamboju <naresh.kamboju@...aro.org>, 
	clang-built-linux <llvm@...ts.linux.dev>, open list <linux-kernel@...r.kernel.org>, 
	dmaengine@...r.kernel.org, lkft-triage@...ts.linaro.org, 
	Linux Regressions <regressions@...ts.linux.dev>, Vinod Koul <vkoul@...nel.org>, 
	Anders Roxell <anders.roxell@...aro.org>, Dan Carpenter <dan.carpenter@...aro.org>, 
	Benjamin Copeland <benjamin.copeland@...aro.org>
Subject: Re: next-20250903 x86_64 clang-20 allyesconfig mmp_pdma.c:1188:14:
 error: shift count >= width of type [-Werror,-Wshift-count-overflow]

On Thu, Sep 4, 2025 at 12:59 AM Nathan Chancellor <nathan@...nel.org> wrote:
>
> On Wed, Sep 03, 2025 at 02:04:10PM +0200, Arnd Bergmann wrote:
> > On Wed, Sep 3, 2025, at 12:08, Naresh Kamboju wrote:
> >
> > > Build error:
> > > drivers/dma/mmp_pdma.c:1188:14: error: shift count >= width of type
> > > [-Werror,-Wshift-count-overflow]
> > >  1188 |         .dma_mask = DMA_BIT_MASK(64),   /* force 64-bit DMA
> > > addr capability */
> > >       |                     ^~~~~~~~~~~~~~~~
> > > include/linux/dma-mapping.h:73:54: note: expanded from macro 'DMA_BIT_MASK'
> > >    73 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> > >       |                                                      ^ ~~~
> >
> > I see two separate issues:
> >
> > 1. The current DMA_BIT_MASK() definition seems unfortunate, as the
> > '(n) == 64' check is meant to avoid this problem, but I think this
> > only works inside of a function, not in a static structure definition.
>
> Right, this is one of our longest outstanding issues :/
>
> https://github.com/ClangBuiltLinux/linux/issues/92
> https://github.com/llvm/llvm-project/issues/38137
>
> This only happens at global scope.
>
> > This could perhaps be avoided by replacing the ?: operator with
> > __builtin_choose_expr(), but that likely causes other build failures.
>
> Yeah, that makes the problem worse somehow even though GCC says the
> non-taken option should not be evaluated...
>
>   drivers/dma/mmp_pdma.c:1188:14: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
>    1188 |         .dma_mask = DMA_BIT_MASK(64),   /* force 64-bit DMA addr capability */
>         |                     ^~~~~~~~~~~~~~~~
>   include/linux/dma-mapping.h:73:70: note: expanded from macro 'DMA_BIT_MASK'
>      73 | #define DMA_BIT_MASK(n) __builtin_choose_expr((n) == 64, ~0ULL, (1ULL<<(n))-1)
>         |                                                                      ^ ~~~
>   drivers/dma/mmp_pdma.c:1323:27: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
>    1323 |                 dma_set_mask(pdev->dev, DMA_BIT_MASK(64));
>         |                                         ^~~~~~~~~~~~~~~~
>   include/linux/dma-mapping.h:73:70: note: expanded from macro 'DMA_BIT_MASK'
>      73 | #define DMA_BIT_MASK(n) __builtin_choose_expr((n) == 64, ~0ULL, (1ULL<<(n))-1)
>         |                                                                      ^ ~~~
>

Thanks Nathan for the information here and above.

> > Guodong, how about a patch to drop all the custom dma_mask handling
> > and instead just use dma_set_mask_and_coherent(DMA_BIT_MASK(64))
> > or dma_set_mask_and_coherent(DMA_BIT_MASK(32)) here? Instead of
> > passing the mask in the mmp_pdma_ops, you can replace it e.g. with
> > a 'bool addr64' flag, or an 'int dma_width' number that
> > gets passed into the DMA_MASK_MASK().
>

Thanks, Arnd. I'll send a patch to clean up and simplify the logic.

> If this works, I think it is worth pursuing to avoid this bogus
> warning/error.
>
> Cheers,
> Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ