LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] x86: add missed clobber for 32-bit memmove
@ 2008-10-17 13:15 Jike Song
  2008-10-17 13:15 ` Jike Song
  0 siblings, 1 reply; 5+ messages in thread
From: Jike Song @ 2008-10-17 13:15 UTC (permalink / raw)
  To: hpa; +Cc: linux-kernel



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

* [PATCH] x86: add missed clobber for 32-bit memmove
  2008-10-17 13:15 [PATCH] x86: add missed clobber for 32-bit memmove Jike Song
@ 2008-10-17 13:15 ` Jike Song
  2008-10-17 15:55   ` Jeremy Fitzhardinge
  2008-10-17 16:35   ` H. Peter Anvin
  0 siblings, 2 replies; 5+ messages in thread
From: Jike Song @ 2008-10-17 13:15 UTC (permalink / raw)
  To: hpa; +Cc: linux-kernel, Jike Song

memmove() is implemented by inline assembly. It calls std at first
and cld at last, but EFLAGS still should be clobbered.

Signed-off-by: Jike Song <albcamus@gmail.com>
---
 arch/x86/lib/memcpy_32.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/memcpy_32.c b/arch/x86/lib/memcpy_32.c
index 5415a9d..99a8240 100644
--- a/arch/x86/lib/memcpy_32.c
+++ b/arch/x86/lib/memcpy_32.c
@@ -36,7 +36,7 @@ void *memmove(void *dest, const void *src, size_t n)
 			:"0" (n),
 			 "1" (n-1+src),
 			 "2" (n-1+dest)
-			:"memory");
+			:"cc", "memory");
 	}
 	return dest;
 }
-- 
1.6.0.1


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

* Re: [PATCH] x86: add missed clobber for 32-bit memmove
  2008-10-17 13:15 ` Jike Song
@ 2008-10-17 15:55   ` Jeremy Fitzhardinge
  2008-10-17 16:35   ` H. Peter Anvin
  1 sibling, 0 replies; 5+ messages in thread
From: Jeremy Fitzhardinge @ 2008-10-17 15:55 UTC (permalink / raw)
  To: Jike Song; +Cc: hpa, linux-kernel

Jike Song wrote:
> memmove() is implemented by inline assembly. It calls std at first
> and cld at last, but EFLAGS still should be clobbered.
>   

I think x86 gcc assumes "cc" is always clobbered by asms.  Otherwise 
there'll need to be a lot more "cc" clobbers than this...

    J

> Signed-off-by: Jike Song <albcamus@gmail.com>
> ---
>  arch/x86/lib/memcpy_32.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/lib/memcpy_32.c b/arch/x86/lib/memcpy_32.c
> index 5415a9d..99a8240 100644
> --- a/arch/x86/lib/memcpy_32.c
> +++ b/arch/x86/lib/memcpy_32.c
> @@ -36,7 +36,7 @@ void *memmove(void *dest, const void *src, size_t n)
>  			:"0" (n),
>  			 "1" (n-1+src),
>  			 "2" (n-1+dest)
> -			:"memory");
> +			:"cc", "memory");
>  	}
>  	return dest;
>  }
>   


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

* Re: [PATCH] x86: add missed clobber for 32-bit memmove
  2008-10-17 13:15 ` Jike Song
  2008-10-17 15:55   ` Jeremy Fitzhardinge
@ 2008-10-17 16:35   ` H. Peter Anvin
  2008-10-20  6:44     ` Jike Song
  1 sibling, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2008-10-17 16:35 UTC (permalink / raw)
  To: Jike Song; +Cc: linux-kernel

Jike Song wrote:
> memmove() is implemented by inline assembly. It calls std at first
> and cld at last, but EFLAGS still should be clobbered.

gcc always treats EFLAGS as clobbered on x86.  The "cc" clobber is 
needed on some platforms, but is a noop on x86.

	-hpa

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

* Re: [PATCH] x86: add missed clobber for 32-bit memmove
  2008-10-17 16:35   ` H. Peter Anvin
@ 2008-10-20  6:44     ` Jike Song
  0 siblings, 0 replies; 5+ messages in thread
From: Jike Song @ 2008-10-20  6:44 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

On Sat, Oct 18, 2008 at 12:35 AM, H. Peter Anvin <hpa@zytor.com> wrote:
> Jike Song wrote:
>>
>> memmove() is implemented by inline assembly. It calls std at first
>> and cld at last, but EFLAGS still should be clobbered.
>
> gcc always treats EFLAGS as clobbered on x86.  The "cc" clobber is needed on
> some platforms, but is a noop on x86.

No wonder there are inline asms that clobbered eflags/rflags but
without declaring them as clobbered. Thanks for your information.

It turns out that I need to read through the gcc x86 back-end as long
as I want to be a Linux/x86 developer, right? That sounds
discouraging:)

-- 
Thanks,
Jike

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

end of thread, other threads:[~2008-10-20  6:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17 13:15 [PATCH] x86: add missed clobber for 32-bit memmove Jike Song
2008-10-17 13:15 ` Jike Song
2008-10-17 15:55   ` Jeremy Fitzhardinge
2008-10-17 16:35   ` H. Peter Anvin
2008-10-20  6:44     ` Jike Song

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).