linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Fw: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
       [not found] <20080726013931.bcc4682d.akpm@linux-foundation.org>
@ 2008-07-26 16:40 ` Harvey Harrison
  2008-07-26 16:48   ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Harvey Harrison @ 2008-07-26 16:40 UTC (permalink / raw)
  To: Olaf Hering; +Cc: Andrew Morton, H. Peter Anvin, Ingo Molnar, LKML

On Sat, 2008-07-26 at 01:39 -0700, Andrew Morton wrote:
> 
> Begin forwarded message:
> 
> Date: Mon, 21 Jul 2008 15:18:46 +0200
> From: Olaf Hering <olaf@aepfle.de>
> To: linux-kernel@vger.kernel.org
> Subject: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
> What is the purpose of CONFIG_X86_BSWAP in asm-x86/byteorder.h?
> 
> An undefined CONFIG_foo defaults to 0 (I think), so bswap is never used.
> Is this done on purpose, or can the CONFIG_ foo be moved inside
> __KERNEL__ somehow?

I believe it's there to prevent the bswap instruction from being used on
early x86_32 models (i386/i486).  As this will be 0 in userspace it is
effectively never using the bswap instruction for these routines.

I'm not sure if it's time yet to make the bswap ones be exported, as they
would no longer be usable for those early machines.  X86 guys CC:d.

Harvey


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fw: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
  2008-07-26 16:40 ` Fw: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland Harvey Harrison
@ 2008-07-26 16:48   ` H. Peter Anvin
  2008-07-26 16:59     ` Arjan van de Ven
  2008-07-26 17:00     ` Fw: " Harvey Harrison
  0 siblings, 2 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-07-26 16:48 UTC (permalink / raw)
  To: Harvey Harrison; +Cc: Olaf Hering, Andrew Morton, Ingo Molnar, LKML

Harvey Harrison wrote:
>>
>> An undefined CONFIG_foo defaults to 0 (I think), so bswap is never used.
>> Is this done on purpose, or can the CONFIG_ foo be moved inside
>> __KERNEL__ somehow?
> 
> I believe it's there to prevent the bswap instruction from being used on
> early x86_32 models (i386/i486).  As this will be 0 in userspace it is
> effectively never using the bswap instruction for these routines.
> 

i386, specifically.

However, you shouldn't leak these symbols to userspace; there is a 
warning option in gcc for undefined macros, and it's a *good thing* to 
use it.  Causing warnings in user space is not nice.

> I'm not sure if it's time yet to make the bswap ones be exported, as they
> would no longer be usable for those early machines.  X86 guys CC:d.

On i386 we still default to i386-compatible binaries; I *think* gcc has 
macros telling you if the user has used -march=i486 etc.

	-hpa

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
  2008-07-26 16:48   ` H. Peter Anvin
@ 2008-07-26 16:59     ` Arjan van de Ven
  2008-07-26 18:18       ` H. Peter Anvin
  2008-07-26 17:00     ` Fw: " Harvey Harrison
  1 sibling, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2008-07-26 16:59 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Harvey Harrison, Olaf Hering, Andrew Morton, Ingo Molnar, LKML

On Sat, 26 Jul 2008 12:48:31 -0400
"H. Peter Anvin" <hpa@zytor.com> w
> > I'm not sure if it's time yet to make the bswap ones be exported,
> > as they would no longer be usable for those early machines.  X86
> > guys CC:d.
> 
> On i386 we still default to i386-compatible binaries; I *think* gcc
> has macros telling you if the user has used -march=i486 etc.

It is also not the kernels job to provide this sort of functionality to
userspace programs. At all. This is gcc/glibc/etc's job.

Rule of thumb: the kernel does not provide code for compiling inside
userspace programs.

(As opposed to providing datastructures that userspace programs can use
to talk to the kernel).



-- 
If you want to reach me at my work email, use arjan@linux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Fw: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
  2008-07-26 16:48   ` H. Peter Anvin
  2008-07-26 16:59     ` Arjan van de Ven
@ 2008-07-26 17:00     ` Harvey Harrison
  1 sibling, 0 replies; 5+ messages in thread
From: Harvey Harrison @ 2008-07-26 17:00 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Olaf Hering, Andrew Morton, Ingo Molnar, LKML

On Sat, 2008-07-26 at 12:48 -0400, H. Peter Anvin wrote:
> Harvey Harrison wrote:
> >>
> >> An undefined CONFIG_foo defaults to 0 (I think), so bswap is never used.
> >> Is this done on purpose, or can the CONFIG_ foo be moved inside
> >> __KERNEL__ somehow?
> > 
> > I believe it's there to prevent the bswap instruction from being used on
> > early x86_32 models (i386/i486).  As this will be 0 in userspace it is
> > effectively never using the bswap instruction for these routines.
> > 
> 
> i386, specifically.
> 
> However, you shouldn't leak these symbols to userspace; there is a 
> warning option in gcc for undefined macros, and it's a *good thing* to 
> use it.  Causing warnings in user space is not nice.

True, but the existing header in Linus' tree does exactly this, so unless
you beat me to it, I'll have a look to see what can be done here.

> 
> > I'm not sure if it's time yet to make the bswap ones be exported, as they
> > would no longer be usable for those early machines.  X86 guys CC:d.
> 
> On i386 we still default to i386-compatible binaries; I *think* gcc has 
> macros telling you if the user has used -march=i486 etc.
> 

Hmm, I wasn't aware of that, hopefully google will oblige.

Cheers,

Harvey


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland
  2008-07-26 16:59     ` Arjan van de Ven
@ 2008-07-26 18:18       ` H. Peter Anvin
  0 siblings, 0 replies; 5+ messages in thread
From: H. Peter Anvin @ 2008-07-26 18:18 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Harvey Harrison, Olaf Hering, Andrew Morton, Ingo Molnar, LKML

Arjan van de Ven wrote:
\>
> It is also not the kernels job to provide this sort of functionality to
> userspace programs. At all. This is gcc/glibc/etc's job.
> 
> Rule of thumb: the kernel does not provide code for compiling inside
> userspace programs.
> 
> (As opposed to providing datastructures that userspace programs can use
> to talk to the kernel).
> 

That's a fine rule of thumb, but we have 17 years of legacy to deal with 
here, too.

	-hpa


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-07-26 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20080726013931.bcc4682d.akpm@linux-foundation.org>
2008-07-26 16:40 ` Fw: asm-x86/byteorder.h, CONFIG_X86_BSWAP leaks to userland Harvey Harrison
2008-07-26 16:48   ` H. Peter Anvin
2008-07-26 16:59     ` Arjan van de Ven
2008-07-26 18:18       ` H. Peter Anvin
2008-07-26 17:00     ` Fw: " Harvey Harrison

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).