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]
Date:   Thu, 7 Mar 2019 09:43:06 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Christoph Hellwig <hch@....de>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Jesper Dangaard Brouer <brouer@...hat.com>,
        Paul Burton <paul.burton@...s.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        "open list:IOMMU DRIVERS" <iommu@...ts.linux-foundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] [v2] dma-mapping: work around clang bug

On 2019-03-07 9:28 am, Arnd Bergmann wrote:
> On Thu, Mar 7, 2019 at 10:17 AM Robin Murphy <robin.murphy@....com> wrote:
>> On 2019-03-07 8:52 am, Arnd Bergmann wrote:
>>>
>>> -#define DMA_BIT_MASK(n)      (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
>>> +/* double shift to work around https://bugs.llvm.org/show_bug.cgi?id=38789 */
>>> +#define DMA_BIT_MASK(n)      (((n) == 64) ? ~0ULL : ((1ULL<<((n)-1))<<1)-1)
>>
>> I think that now makes DMA_BIT_MASK(0) undefined - that shouldn't matter
>> in most cases, but it could potentially happen at runtime where callers
>> use a non-constant argument. However, it also means we don't need to
>> special-case 64 any more (since that's there to avoid the same thing
>> anyway), so we could simply flip that to handle 0 instead.
> 
> Yes, good idea.
> 
>> FWIW I'd be very tempted to fold in the second shift as "2ULL<<((n)-1)",
>> but that may not be to everyone's taste.
> 
> I like that. So shall we do this?
> 
> /*
>   * Shifting '2' instead of '1' because of
>   * https://bugs.llvm.org/show_bug.cgi?id=38789
>   */
> #define DMA_BIT_MASK(n)    (((n) == 0) ? 0ULL : ((2ULL<<((n)-1)))-1)

Neat - it was too early in the morning for me to think of a succinct way 
to comment it, but that's great. I suspect there may be a redundant set 
of parentheses around the shift still, but other than that,

Reviewed-by: Robin Murphy <robin.murphy@....com>

Cheers,
Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ