lkml.org 
[lkml]   [2015]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask
On Mon, 20 Jul 2015 19:57:18 +0200 Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> On Mon, Jul 20 2015, Guenter Roeck <linux@roeck-us.net> wrote:
>
> > So either case ~0l appears to be wrong; it should be ~0ul.
>
> Yes, right-shifting -1 of any type is probably always wrong, as it will
> always give -1 again.

Not for unsigned types.

The kernel uses "-1UL" and "-1ULL" quite a lot - it's a convenient way
of saying "all ones, regardless of size". Also, assigning plain old
"-1" to an unsigned variable will make that variable all-ones
regardless of size.

In this case I expect we could do

align_mask = -1UL >> (64 - align_order);

but I don't know about that 64. Maybe it should be BITS_PER_LONG?


\
 
 \ /
  Last update: 2015-07-21 01:41    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog