Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jul 2012 14:45:32 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        Kim Culhan <w8hdkim@gmail.com>, freebsd-current@freebsd.org, David Chisnall <theraven@freebsd.org>
Subject:   Re: -current build failure
Message-ID:  <20120721114532.GZ2676@deviant.kiev.zoral.com.ua>
In-Reply-To: <20120721114316.GY2676@deviant.kiev.zoral.com.ua>
References:  <CAKZxVQV5xhFDN_WbTk-EMoQ18N8u1f4YhqKSJQFUzbX4NZxhUA@mail.gmail.com> <50097BF0.9010103@FreeBSD.org> <20120720163352.GS2676@deviant.kiev.zoral.com.ua> <9EBB4101-3117-4FE0-AD08-1053423BECD6@FreeBSD.org> <20120720231604.GT2676@deviant.kiev.zoral.com.ua> <500A93FE.1080700@FreeBSD.org> <20120721114316.GY2676@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--EJQo4LVzGuCx5O0O
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jul 21, 2012 at 02:43:16PM +0300, Konstantin Belousov wrote:
> On Sat, Jul 21, 2012 at 01:35:26PM +0200, Dimitry Andric wrote:
> > On 2012-07-21 01:16, Konstantin Belousov wrote:
> > > On Fri, Jul 20, 2012 at 10:07:05PM +0100, David Chisnall wrote:
> > >> On 20 Jul 2012, at 17:33, Konstantin Belousov wrote:
> > >>
> > >>> It is not related to dtrace at all, and indeed OFFSETOF_CURTHREAD i=
s 0.
> > >>> This is a bug in clang, we compile our kernel in freestanding envir=
onment.
> > >>
> > >> The copies of the C spec that I have do not differentiate between
> > >> freestanding and hosted environments for the validity of dereferenci=
ng
> > >> a pointer value of 0. Doing so is undefined in all cases and any
> > >> standards-compliant compiler is quite at liberty to eat your dog in
> > >> such situations - it is explicitly not guaranteed to read the memory=
 at
> > >> linear address 0 (this is undefined for at least two reasons that I =
can
> > >> think of from the C spec, and probably more).
> > >=20
> > > Ok, I stand corrected. But the standard does not say what you claim
> > > either. It only specifies that NULL pointer is unequal to any pointer
> > > to object or function (implicitely saying that you can create a C obj=
ect
> > > or function pointer to which is equal to NULL).
> > >=20
> > > So, lets reformulate it other way: freestanding implementation in cla=
ng
> > > has no use, at least for general purpose kernel. Especially ridiculous
> > > is the fact that clang throws it hands for asm inline wanting to get
> > > null address, on the machine with linearly addressable memory.
> >=20
> > Oh come on, that's just hyperbole.  Everybody understands that directly
> > dereferencing a NULL pointer is very unusual, in any environment.  It's
> > perfectly sane to warn about it.  Is it such a big problem to simply
> > insert a cast to tell the compiler you really want to do this, even if
> > it is highly unusual?
Oh, just for record. I forgot to note this first time, and almost missed it
now in response. The code in question _does not_ dereference NULL pointer.
It is artificial quirk in the GNU inline asm syntax that rvalue is needed
when I am passing memory _address_ to the asm.

>=20
> The point of existence of the inline __pure2 __curthread() is to allow
> a compiler to cache the result of the call. Basically, the curthread
> dereference uses %gs basing, which typically adds a measurable penalty
> on the frontend and sometimes on the execution as well.
>=20
> Putting a volatile somewhere prevents the caching, right ? I am probably
> fine with something along the lines of
> #ifdef CLANG /* XXX what to put there */
> #define VOLATILE volatile
> #else
> #define VOLATILE
> #endif
> and then use VOLATILE in the cast.
>=20
> Could you recomment the best #if test ?
>=20
> How to test the change ? Is CC=3Dclang make buildkernel enough ?
>=20



--EJQo4LVzGuCx5O0O
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAlAKllwACgkQC3+MBN1Mb4izJwCg9fKUNEB3UhDuXB6An0ROjbfK
wMkAn2gJ8tZ78pt+1DdYlm/khRFkhpUO
=Al1c
-----END PGP SIGNATURE-----

--EJQo4LVzGuCx5O0O--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120721114532.GZ2676>