From: Russ Anderson <rja@sgi.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Dimitri Sivanich <sivanich@sgi.com>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, Russ Anderson <rja@sgi.com>
Subject: Re: [patch] x86, UV: integer wrap bug in uv_hub_ipi_value()
Date: Tue, 20 Nov 2012 16:27:07 +0000 [thread overview]
Message-ID: <20121120162706.GB11150@sgi.com> (raw)
In-Reply-To: <20121120111055.64845785@pyramind.ukuu.org.uk>
On Tue, Nov 20, 2012 at 11:10:55AM +0000, Alan Cox wrote:
> On Tue, 20 Nov 2012 07:28:56 +0300 Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Mon, Nov 19, 2012 at 06:48:34PM -0600, Russ Anderson wrote:
> > > On Sat, Nov 17, 2012 at 06:16:11PM +0300, Dan Carpenter wrote:
> > > > This is a static checker fix. The problem is that we store the bits
> > > > from "uv_apicid_hibits" into "apicid" (the high 16 bits) but then we
> > > > shift it 16 bit to the left. "apicid" is an int so it wraps and we lose
> > > > them.
> > >
> > > Is this the complete patch? phys_apicid is an int, but gets
> > > cast as unsigned long. Doesn't phys_apicid also have to be
> > > changed to unsigned long? And why ulong instead of uint (on x86_64)?
> >
> > Uint is 32bit across all arches in linux and unix, according to
> > wikipedia.
>
> For Linux yes, if Wackypedia claims it for "unix" it's wrong 8) and varies
> between 16 and 36bits that I can think of.
64 bit int on old Cray cpus (unicos). :-)
> If you specifically want 32bits use "u32", it's not going to make any
> actual difference to unsigned int but it makes the requirement explicit.
I very much agree. I prefer u32, u64 (etc) because they are
unambiguous. It removes all doubt as to the actual meaning.
Conversly, the fact that "long" has different meanings makes
it at best problematic. Was the code written assuming "long"
was 32 or 64 bits? Having data types that can have different
sizes is just asking for trouble.
--
Russ Anderson, OS RAS/Partitioning Project Lead
SGI - Silicon Graphics Inc rja@sgi.com
WARNING: multiple messages have this Message-ID (diff)
From: Russ Anderson <rja@sgi.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Dimitri Sivanich <sivanich@sgi.com>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org, Russ Anderson <rja@sgi.com>
Subject: Re: [patch] x86, UV: integer wrap bug in uv_hub_ipi_value()
Date: Tue, 20 Nov 2012 10:27:07 -0600 [thread overview]
Message-ID: <20121120162706.GB11150@sgi.com> (raw)
In-Reply-To: <20121120111055.64845785@pyramind.ukuu.org.uk>
On Tue, Nov 20, 2012 at 11:10:55AM +0000, Alan Cox wrote:
> On Tue, 20 Nov 2012 07:28:56 +0300 Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Mon, Nov 19, 2012 at 06:48:34PM -0600, Russ Anderson wrote:
> > > On Sat, Nov 17, 2012 at 06:16:11PM +0300, Dan Carpenter wrote:
> > > > This is a static checker fix. The problem is that we store the bits
> > > > from "uv_apicid_hibits" into "apicid" (the high 16 bits) but then we
> > > > shift it 16 bit to the left. "apicid" is an int so it wraps and we lose
> > > > them.
> > >
> > > Is this the complete patch? phys_apicid is an int, but gets
> > > cast as unsigned long. Doesn't phys_apicid also have to be
> > > changed to unsigned long? And why ulong instead of uint (on x86_64)?
> >
> > Uint is 32bit across all arches in linux and unix, according to
> > wikipedia.
>
> For Linux yes, if Wackypedia claims it for "unix" it's wrong 8) and varies
> between 16 and 36bits that I can think of.
64 bit int on old Cray cpus (unicos). :-)
> If you specifically want 32bits use "u32", it's not going to make any
> actual difference to unsigned int but it makes the requirement explicit.
I very much agree. I prefer u32, u64 (etc) because they are
unambiguous. It removes all doubt as to the actual meaning.
Conversly, the fact that "long" has different meanings makes
it at best problematic. Was the code written assuming "long"
was 32 or 64 bits? Having data types that can have different
sizes is just asking for trouble.
--
Russ Anderson, OS RAS/Partitioning Project Lead
SGI - Silicon Graphics Inc rja@sgi.com
next prev parent reply other threads:[~2012-11-20 16:27 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-17 15:16 [patch] x86, UV: integer wrap bug in uv_hub_ipi_value() Dan Carpenter
2012-11-17 15:16 ` Dan Carpenter
2012-11-20 0:48 ` Russ Anderson
2012-11-20 0:48 ` Russ Anderson
2012-11-20 4:28 ` Dan Carpenter
2012-11-20 4:28 ` Dan Carpenter
2012-11-20 4:55 ` H. Peter Anvin
2012-11-20 4:55 ` H. Peter Anvin
2012-11-20 11:10 ` Alan Cox
2012-11-20 16:27 ` Russ Anderson [this message]
2012-11-20 16:27 ` Russ Anderson
2012-11-20 17:09 ` H. Peter Anvin
2012-11-20 17:09 ` H. Peter Anvin
2012-11-20 17:07 ` Russ Anderson
2012-11-20 17:07 ` Russ Anderson
2012-11-21 7:39 ` Dan Carpenter
2012-11-21 7:39 ` Dan Carpenter
2012-12-02 10:44 ` [patch v2] " Dan Carpenter
2012-12-02 10:44 ` Dan Carpenter
2012-12-02 15:33 ` walter harms
2012-12-02 15:33 ` walter harms
2012-12-02 17:28 ` [patch v3] " Dan Carpenter
2012-12-02 17:28 ` Dan Carpenter
2012-12-02 17:35 ` Dan Carpenter
2012-12-02 17:35 ` Dan Carpenter
2012-12-03 7:58 ` [patch v4] " Dan Carpenter
2012-12-03 7:58 ` Dan Carpenter
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=20121120162706.GB11150@sgi.com \
--to=rja@sgi.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dan.carpenter@oracle.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sivanich@sgi.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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.