[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20100226155553.GD16335@basil.fritz.box>
Date: Fri, 26 Feb 2010 16:55:53 +0100
From: Andi Kleen <andi@...stfloor.org>
To: Mikael Pettersson <mikpe@...uu.se>
Cc: Andi Kleen <andi@...stfloor.org>,
roel kluin <roel.kluin@...il.com>,
David Miller <davem@...emloft.net>,
herbert@...dor.apana.org.au, linux-crypto@...r.kernel.org,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sha: prevent removal of memset as dead store in
sha1_update()
> Instead of barrier(), this works with gcc-3.2.3 up to gcc-4.4.3
> for the purpose of making the memset() not disappear:
>
> {
> struct s { char c[n]; };
> asm("" : : "m"(*(struct s *)p));
> }
>
> Every byte in the [p,p+n[ range must be used. If you only use the
> first byte, via e.g. asm("" :: "m"(*(char*)p)), then the compiler
> _will_ skip scrubbing bytes beyond the first.
>
> An explicit loop that uses each byte individually also works, but
> results in awful code with older compilers.
I suspect it would be worth asking for a __builtin for this.
iirc Visual C already has one.
BTW I remember finding a few more such cases in random user space
code in past code review.
-Andi
--
ak@...ux.intel.com -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists