Skip to contentSkip to conversation

Opteron bug

DISCUSSION R. J. Wysocki 5 participants 8 messages Jun 19, 2004 – Jul 12, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi,

I hope everyone interested in the development for Opteron is aware of the bug described here:

http://www.3dchips.net/content/story.php?id=3927

Yours,
rjw

Signature · 7 lines
Rafael J. Wysocki,
SiSK
[tel. (+48) 605 053 693]
----------------------------
For a successful technology, reality must take precedence over public 
relations, for nature cannot be fooled.
					-- Richard P. Feynman
#2 lore raw
Quoted 11 lines · Andi Kleen

On Sat, 19 Jun 2004 22:29:14 +0200

Quoted 6 lines · R. J. Wysocki

Hi,

I hope everyone interested in the development for Opteron is aware of the bug described here:

http://www.3dchips.net/content/story.php?id=3927

The kernel never uses backwards REP prefixes.

So it doesn't matter. :-)

Well, is there any case in which the gcc can produce such stuff?

rjw

#3 lore raw
Quoted 6 lines · On Sun, 20 Jun 2004 13:47:17 +0200 "R. J. Wysocki" <[email protected]> wrote:
Quoted 5 lines · Andi Kleen

On Sat, 19 Jun 2004 22:29:14 +0200

Quoted 2 lines · R. J. Wysocki

Hi,

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I hope everyone interested in the development for Opteron is aware of the bug described here:

http://www.3dchips.net/content/story.php?id=3927

The kernel never uses backwards REP prefixes.

So it doesn't matter. :-)

Some user space program could still use it.

You'll have to live with that. CPUs like all other complex systems have bugs.

Quoted 1 line

Well, is there any case in which the gcc can produce such stuff?

With inline assembly only I guess.

-Andi

#4 lore raw
In reply to R. J. Wysocki
Quoted 1 line · R. J. Wysocki

Well, is there any case in which the gcc can produce such stuff?

GCC doesn't ever generate std instruction (only cld), though users can use it in inline assembly or assembly source file. AFAIK x86_64 glibc doesn't use it at all either.

Jakub

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 28 lines · Denis Vlasenko
Quoted 6 lines · Jakub Jelinek
Quoted 1 line · R. J. Wysocki

Well, is there any case in which the gcc can produce such stuff?

GCC doesn't ever generate std instruction (only cld), though users can use it in inline assembly or assembly source file. AFAIK x86_64 glibc doesn't use it at all either.

glibc-2.3/sysdeps/i386/memcopy.h:

#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes)                                 \
  do                                                                          \
    {                                                                         \
      int __d0;                                                               \
      asm volatile(/* Set the direction flag, so copying goes backwards.  */  \
                   "std\n"                                                    \
                   /* Copy bytes.  */                                         \
                   "rep\n"                                                    \
                   "movsb\n"                                                  \
                   /* Clear the dir flag.  Convention says it should be 0. */ \
                   "cld" :                                                    \
                   "=D" (dst_ep), "=S" (src_ep), "=c" (__d0) :                \
                   "0" (dst_ep - 1), "1" (src_ep - 1), "2" (nbytes) :         \
                   "memory");                                                 \
      dst_ep += 1;                                                            \
      src_ep += 1;                                                            \
    } while (0)
Quoted 1 line

WORD_COPY_BWD also does this

I know, but I said x86_64 glibc, which doesn't do this.

Jakub

#8 lore raw
Quoted 9 lines · H. Peter Anvin
Quoted 3 lines · Andi Kleen

The kernel never uses backwards REP prefixes.

Not even for memmove()?

-hpa

One can't assume that 'cld' is not required because a user can execute 'std'. Such a user, calling a kernel function in its context, could really make a mess by executing 'std' before.

You definitely need a 'cld' inside any copy_to/from_user code. memmove(), can copy overlapping buffers. It does this by copying backwards when necessary. If it uses ix86 string primatives, it executes 'std' for the backwards repeat counts.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.