Package: libc6
Version: 2.7-6
Tags: patch

Hi,

the R10000 needs an LL/SC Workaround. If not applied all R10k before
rev 3.0 misbehave on atomic ops and rev 2.6 and lower (e.g. SGI IP28)
die after very few seconds with a deadlock due to even more erratas.
To quote the CPU Erratas workaround:

        Workaround: The basic idea is to inhibit the four instructions
        from simultaneously becoming active in R10000. Padding all
        ll/sc sequences with nops or changing the looping branch in the
        routines to a branch likely (which is always predicted taken
        by R10000) will work. The nops should go after the loop, and the
        number of them should be 28. This number could be decremented for
        each additional instruction in the ll/sc loop such as the lock
        modifier(s) between the ll and sc, the looping branch and its
        delay slot. For typical short routines with one ll/sc loop, any
        instructions after the loop could also count as a decrement. The
        nop workaround pollutes the cache more but would be a few cycles
        faster if all the code is in the cache and the looping branch
        is predicted not taken.

The kernels way in e.g. arch/mips/kernel/scall32-o32.S

        204 #ifdef CONFIG_CPU_HAS_LLSC
        205         /* Ok, this is the ll/sc case.  World is sane :-)  */
        206 1:      ll      v0, (a1)
        207         move    a0, a2
        208 2:      sc      a0, (a1)
        209 #if R10000_LLSC_WAR
        210         beqzl   a0, 1b
        211 #else
        212         beqz    a0, 1b
        213 #endif

This is the patch i successfully build a working libc6 for my SGI IP28 with:

diff -Nur glibc-2.7.orig/ports/sysdeps/mips/bits/atomic.h 
glibc-2.7/ports/sysdeps/mips/bits/atomic.h
--- ports/sysdeps/mips/bits/atomic.h.orig       2005-03-28 09:14:59.000000000 
+0000
+++ ports/sysdeps/mips/bits/atomic.h    2008-01-18 11:17:14.000000000 +0000
@@ -74,7 +74,7 @@
      "bne      %0,%2,2f\n\t"                                                 \
      "move     %1,%3\n\t"                                                    \
      "sc       %1,%4\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \
@@ -98,7 +98,7 @@
      "bne      %0,%2,2f\n\t"                                                 \
      "move     %1,%3\n\t"                                                    \
      "scd      %1,%4\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \
@@ -192,7 +192,7 @@
      "ll       %0,%3\n\t"                                                    \
      "move     %1,%2\n\t"                                                    \
      "sc       %1,%3\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \
@@ -216,7 +216,7 @@
      "lld      %0,%3\n\t"                                                    \
      "move     %1,%2\n\t"                                                    \
      "scd      %1,%3\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \
@@ -251,7 +251,7 @@
      "ll       %0,%3\n\t"                                                    \
      "addu     %1,%0,%2\n\t"                                                 \
      "sc       %1,%3\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \
@@ -275,7 +275,7 @@
      "lld      %0,%3\n\t"                                                    \
      "daddu    %1,%0,%2\n\t"                                                 \
      "scd      %1,%3\n\t"                                                    \
-     "beqz     %1,1b\n"                                                      \
+     "beqzl    %1,1b\n"                                                      \
      acq       "\n\t"                                                        \
      ".set     pop\n"                                                        \
      "2:\n\t"                                                                \

Flo
-- 
Florian Lohoff                  [EMAIL PROTECTED]             +49-171-2280134
        Those who would give up a little freedom to get a little 
          security shall soon have neither - Benjamin Franklin

Attachment: signature.asc
Description: Digital signature

Reply via email to