public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* asm-x86/byteorder.h: clean up for userspace
@ 2007-12-31 18:12 Mike Frysinger
  2008-01-01 15:22 ` Ingo Molnar
  2008-01-01 17:47 ` Christoph Hellwig
  0 siblings, 2 replies; 7+ messages in thread
From: Mike Frysinger @ 2007-12-31 18:12 UTC (permalink / raw)
  To: tglx, mingo, hpa, Andi Kleen; +Cc: LKML

Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather than
asm in its code.

Signed-Off-By: Mike Frysinger <vapier@gentoo.org>
---
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h
index 1f2d6d5..fe2f2e5 100644
--- a/include/asm-x86/byteorder.h
+++ b/include/asm-x86/byteorder.h
@@ -30,13 +30,13 @@ static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
 	} v;
 	v.u = val;
 #ifdef CONFIG_X86_BSWAP
-	asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
+	__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
 	    : "=r" (v.s.a), "=r" (v.s.b)
 	    : "0" (v.s.a), "1" (v.s.b));
 #else
 	v.s.a = ___arch__swab32(v.s.a);
 	v.s.b = ___arch__swab32(v.s.b);
-	asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
+	__asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
 #endif
 	return v.u;
 }

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

* Re: asm-x86/byteorder.h: clean up for userspace
  2007-12-31 18:12 asm-x86/byteorder.h: clean up for userspace Mike Frysinger
@ 2008-01-01 15:22 ` Ingo Molnar
  2008-01-01 17:47 ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Ingo Molnar @ 2008-01-01 15:22 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: tglx, mingo, hpa, Andi Kleen, LKML


* Mike Frysinger <vapier@gentoo.org> wrote:

> Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather 
> than asm in its code.

thanks Mike, i have applied your patch to x86.git - as a fix to be 
pushed into 2.6.24.

	Ingo

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

* Re: asm-x86/byteorder.h: clean up for userspace
  2007-12-31 18:12 asm-x86/byteorder.h: clean up for userspace Mike Frysinger
  2008-01-01 15:22 ` Ingo Molnar
@ 2008-01-01 17:47 ` Christoph Hellwig
  2008-01-01 18:17   ` Mike Frysinger
  2008-01-01 21:19   ` H. Peter Anvin
  1 sibling, 2 replies; 7+ messages in thread
From: Christoph Hellwig @ 2008-01-01 17:47 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: tglx, mingo, hpa, Andi Kleen, LKML

On Mon, Dec 31, 2007 at 01:12:45PM -0500, Mike Frysinger wrote:
> Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather than
> asm in its code.

The correct fix is to not export it to userspace.


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

* Re: asm-x86/byteorder.h: clean up for userspace
  2008-01-01 17:47 ` Christoph Hellwig
@ 2008-01-01 18:17   ` Mike Frysinger
  2008-01-01 21:19   ` H. Peter Anvin
  1 sibling, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2008-01-01 18:17 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: tglx, mingo, hpa, Andi Kleen, LKML

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

On Tuesday 01 January 2008, Christoph Hellwig wrote:
> On Mon, Dec 31, 2007 at 01:12:45PM -0500, Mike Frysinger wrote:
> > Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather
> > than asm in its code.
>
> The correct fix is to not export it to userspace.

which is what people complained last time and upon further investigation, it 
isnt trivial to remove.  so until then, it should be made clean.  especially 
considering the proposed changes are perfectly fine when used inside and 
outside of the kernel.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: asm-x86/byteorder.h: clean up for userspace
  2008-01-01 17:47 ` Christoph Hellwig
  2008-01-01 18:17   ` Mike Frysinger
@ 2008-01-01 21:19   ` H. Peter Anvin
  2008-01-02  1:31     ` Adrian Bunk
  1 sibling, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2008-01-01 21:19 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Mike Frysinger, tglx, mingo, Andi Kleen, LKML

Christoph Hellwig wrote:
> On Mon, Dec 31, 2007 at 01:12:45PM -0500, Mike Frysinger wrote:
>> Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather than
>> asm in its code.
> 
> The correct fix is to not export it to userspace.

Unfortunately, it's historically been provided, for over 15 years.  It's 
also trivial to export, without funnies, and it's *useful* to userspace, 
as it provides an interface sorely lacking from the stock libc interfaces.

So please do provide it, even though it's arguably the wrong thing.  The 
downside is worse.

	-hpa

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

* Re: asm-x86/byteorder.h: clean up for userspace
  2008-01-01 21:19   ` H. Peter Anvin
@ 2008-01-02  1:31     ` Adrian Bunk
  2008-01-02  2:22       ` H. Peter Anvin
  0 siblings, 1 reply; 7+ messages in thread
From: Adrian Bunk @ 2008-01-02  1:31 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Christoph Hellwig, Mike Frysinger, tglx, mingo, Andi Kleen, LKML

On Tue, Jan 01, 2008 at 01:19:42PM -0800, H. Peter Anvin wrote:
> Christoph Hellwig wrote:
>> On Mon, Dec 31, 2007 at 01:12:45PM -0500, Mike Frysinger wrote:
>>> Since asm-x86/byteorder.h is exported to userspace, use __asm__ rather than
>>> asm in its code.
>>
>> The correct fix is to not export it to userspace.
>
> Unfortunately, it's historically been provided, for over 15 years.  It's 
> also trivial to export, without funnies, and it's *useful* to userspace, as 
> it provides an interface sorely lacking from the stock libc interfaces.
>...

Userspace either has to #define CONFIG_X86_BSWAP or it'll get the slow 
versions of these functions...

Leaking CONFIG_ variables to userspace is not really funny - I remember 
e.g. what tricks MySQL does (did?) for (ab)using asm-i386/atomic.h in 
userspace.

> 	-hpa

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

* Re: asm-x86/byteorder.h: clean up for userspace
  2008-01-02  1:31     ` Adrian Bunk
@ 2008-01-02  2:22       ` H. Peter Anvin
  0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2008-01-02  2:22 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Christoph Hellwig, Mike Frysinger, tglx, mingo, Andi Kleen, LKML

Adrian Bunk wrote:
> 
> Userspace either has to #define CONFIG_X86_BSWAP or it'll get the slow 
> versions of these functions...
> 
> Leaking CONFIG_ variables to userspace is not really funny - I remember 
> e.g. what tricks MySQL does (did?) for (ab)using asm-i386/atomic.h in 
> userspace.
> 

True.  CONFIG_X86_BSWAP isn't appropriate for userspace anyway, 
userspace needs to use the appropriate gcc intrinsics for 486+.

	-hpa

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

end of thread, other threads:[~2008-01-02  2:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-31 18:12 asm-x86/byteorder.h: clean up for userspace Mike Frysinger
2008-01-01 15:22 ` Ingo Molnar
2008-01-01 17:47 ` Christoph Hellwig
2008-01-01 18:17   ` Mike Frysinger
2008-01-01 21:19   ` H. Peter Anvin
2008-01-02  1:31     ` Adrian Bunk
2008-01-02  2:22       ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox