From: Sowmini Varadhan <sowmini.varadhan@oracle.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
benh@kernel.crashing.org, davem@davemloft.net,
jose.marchesi@oracle.com, sowmini.varadhan@oracle.com,
dave.kleikamp@oracle.com
Subject: Re: [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask
Date: Mon, 20 Jul 2015 16:44:05 +0200 [thread overview]
Message-ID: <20150720144405.GA2175@oracle.com> (raw)
In-Reply-To: <20150719152724.GB3729@roeck-us.net>
On (07/19/15 08:27), Guenter Roeck wrote:
> > - align_mask = 0xffffffffffffffffl >> (64 - align_order);
> > + align_mask = ~0l >> (64 - align_order);
> >
> Wonder if this just hides the real problem. Unless align_order
> is very large, the resulting mask on 32 bit systems may be 0.
> Is this really the idea ?
<subsequent example code deleted>
> So either case ~0l appears to be wrong; it should be ~0ul.
> I don't know if ~0ull makes a difference for some architectures.
I agree about the unsigned part. However, regarding the arch specific
twists..
I checked into this.. even though I have a test program on
x86_64 that "does the right thing" for both of
align_mask = ~0ul >> (64 - align_order);
align_mask = ~0ul >> (BITS_PER_LONG - align_order);
when I compiled with -m32 and without (I tried align_order == 1 and 31
for edge cases), I think there are some gcc/arch specific variations
possible based on undefined behavior, so that the second variant
is safer.
I'll send out a patch with that version soon.
--Sowmini
prev parent reply other threads:[~2015-07-20 14:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-19 12:20 [PATCH] iommu-common: Do not use 64 bit constant 0xffffffffffffffffl for computing align_mask Sowmini Varadhan
2015-07-19 15:27 ` Guenter Roeck
2015-07-19 20:25 ` Rasmus Villemoes
2015-07-19 20:41 ` Sowmini Varadhan
2015-07-20 1:58 ` Guenter Roeck
2015-07-20 17:57 ` Rasmus Villemoes
2015-07-20 19:25 ` Sowmini Varadhan
2015-07-20 23:28 ` Andrew Morton
2015-07-21 0:26 ` Guenter Roeck
2015-07-20 14:44 ` Sowmini Varadhan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150720144405.GA2175@oracle.com \
--to=sowmini.varadhan@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=dave.kleikamp@oracle.com \
--cc=davem@davemloft.net \
--cc=jose.marchesi@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.