Skip to contentSkip to conversation

What happened with NPTL/TLS support?

Qemu-devel Felipe Contreras 4 participants 7 messages Oct 12, 2007 – Nov 2, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

qemu: Unsupported syscall: 983045

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

Best regards.

[1] http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00128.html

Signature · 1 line
Felipe Contreras
#1 lore raw
Quoted 6 lines · Felipe Contreras

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

qemu: Unsupported syscall: 983045

Yep, I've seen that before.

Quoted 9 lines

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

Best regards.

[1] http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00128.html

I've been using this patch, as well as other NPTL/TLS patches as well as some of my own work and have a set of patches for NPTL/TLS that works reasonably well for arm and i386. The patches don't apply cleanly to CVS current, but I'm more than happy to rework them so that they will if someone is serious about getting NPTL/TLS/futex stuff working for linux-user. I haven't submitted my patches because I kept expecting the other patches to be accepted.

#6 lore raw
In reply to Felipe Contreras
Quoted 5 lines · Felipe Contreras

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

Quoted 7 lines

qemu: Unsupported syscall: 983045

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

It needs someone to care enough to make the implementation not suck.

Paul

#2 lore raw
In reply to Thayne Harbaugh
Quoted 22 lines · Thayne Harbaugh
Quoted 6 lines · Felipe Contreras

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

qemu: Unsupported syscall: 983045

Yep, I've seen that before.

Quoted 9 lines

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

Best regards.

[1] http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00128.html

Quoted 7 lines

I've been using this patch, as well as other NPTL/TLS patches as well as some of my own work and have a set of patches for NPTL/TLS that works reasonably well for arm and i386. The patches don't apply cleanly to CVS current, but I'm more than happy to rework them so that they will if someone is serious about getting NPTL/TLS/futex stuff working for linux-user. I haven't submitted my patches because I kept expecting the other patches to be accepted.

Please submit this patch (and resend what you think was missed).

Thiemo

#3 lore raw
Quoted 31 lines · Thiemo Seufer
Quoted 22 lines · Thayne Harbaugh
Quoted 6 lines · Felipe Contreras

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

qemu: Unsupported syscall: 983045

Yep, I've seen that before.

Quoted 9 lines

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

Best regards.

[1] http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00128.html

Quoted 7 lines

I've been using this patch, as well as other NPTL/TLS patches as well as some of my own work and have a set of patches for NPTL/TLS that works reasonably well for arm and i386. The patches don't apply cleanly to CVS current, but I'm more than happy to rework them so that they will if someone is serious about getting NPTL/TLS/futex stuff working for linux-user. I haven't submitted my patches because I kept expecting the other patches to be accepted.

Quoted 1 line

Please submit this patch (and resend what you think was missed).

I'll get them reworked and re-sent soon.

Thanks for the interest.

#4 lore raw
Quoted 33 lines · Thayne Harbaugh
Quoted 31 lines · Thiemo Seufer
Quoted 29 lines · Thayne Harbaugh
Quoted 6 lines · Felipe Contreras

Hi,

When I try to use codesourcery's toolchain arm-2006q3-27 in my Fedora 7 box I always have the following issue:

qemu: Unsupported syscall: 983045

Yep, I've seen that before.

Quoted 9 lines

I guess it's a problem of NPTL incompatibility. Anyway, the patch that Paul Brook sent a while ago solves it [1].

I wonder if it can be integrated or what would be the right way to solve this issue. Am I the only one having it?

Best regards.

[1] http://lists.gnu.org/archive/html/qemu-devel/2005-08/msg00128.html

I've been using this patch, as well as other NPTL/TLS patches as well as some of my own work and have a set of patches for NPTL/TLS that works reasonably well for arm and i386. The patches don't apply cleanly to CVS current, but I'm more than happy to rework them so that they will if someone is serious about getting NPTL/TLS/futex stuff working for linux-user. I haven't submitted my patches because I kept expecting the other patches to be accepted.

Quoted 5 lines
Quoted 1 line

Please submit this patch (and resend what you think was missed).

I'll get them reworked and re-sent soon.

Thanks for the interest.

Do you have anything that can be tried out already?

Best regards.

Signature · 1 line
Felipe Contreras
#5 lore raw
Quoted 3 lines · Felipe Contreras
Quoted 2 lines · Thayne Harbaugh

On Sat, 2007-10-20 at 21:34 +0100, Thiemo Seufer wrote:

<SNIP>

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Please submit this patch (and resend what you think was missed).

I'll get them reworked and re-sent soon.

Thanks for the interest.

Do you have anything that can be tried out already?

Try these:

09_arm_eabitls.patch: This is for TLS on arm. We have used it extensively and it appears quite solid. It should apply to a stock CVS tree - although we use it on top of about 15 other patches so YMMV.

40_tls.patch: This is more for i386. It works mostly, but I don't trust it. It doesn't apply to a stock CVS tree.

There are a few things that should be reworked on both of these patches. I haven't sent them up-stream because I'm working to get foundational patches accepted first. The sooner I can get the EFAULT patches accepted then the sooner I can rework these patches and make them more acceptable to be committed. Right now I don't think either of them should be committed (although 09_arm_eabitls.patch is better than 40_tls.patch).

Good luck!

configure +30 -0
Index: qemu/configure
===================================================================
@@ -102,6 +102,7 @@
 darwin_user="no"
 build_docs="no"
 uname_release=""
+nptl="yes"
 
 # OS specific
 targetos=`uname -s`
@@ -303,6 +304,8 @@
         *)     echo "undefined SPARC architecture. Exiting";exit 1;;
       esac
   ;;
+  --disable-nptl) nptl="no"
+  ;;
   esac
 done
 
@@ -388,6 +391,7 @@
 echo "  --disable-linux-user     disable all linux usermode emulation targets"
 echo "  --enable-darwin-user     enable all darwin usermode emulation targets"
 echo "  --disable-darwin-user    disable all darwin usermode emulation targets"
+echo "  --disable-nptl           disable usermode NPTL guest support"
 echo "  --fmod-lib               path to FMOD library"
 echo "  --fmod-inc               path to FMOD includes"
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
@@ -554,6 +558,23 @@
 }
 EOF
 
+# check NPTL support
+cat > $TMPC <<EOF
+#include <sched.h>
+void foo()
+{
+#ifndef CLONE_SETTLS
+#error bork
+#endif
+}
+EOF
+
+if $cc -c -o $TMPO $TMPC 2> /dev/null ; then
+  :
+else
+   nptl="no"
+fi
+
 ##########################################
 # SDL probe
 
@@ -717,6 +738,7 @@
 echo "Documentation     $build_docs"
 [ ! -z "$uname_release" ] && \
 echo "uname -r          $uname_release"
+echo "NPTL support      $nptl"
 
 if test $sdl_too_old = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1122,6 +1144,14 @@
             echo "SDL_CFLAGS=`$sdl_config --cflags`" >> $config_mak
         fi
     fi
+else
+    if test "$nptl" = "yes" ; then
+        case "$target_cpu" in
+          arm | armeb | ppc | ppc64)
+            echo "#define USE_NPTL 1" >> $config_h
+          ;;
+        esac
+    fi
 fi
 
 if test "$cocoa" = "yes" ; then
exec-all.h +1 -164

171 lines not on this page · raw message

linux-user/arm/syscall.h +3 -1
Index: qemu/linux-user/arm/syscall.h
===================================================================
@@ -28,7 +28,9 @@
 #define ARM_SYSCALL_BASE	0x900000
 #define ARM_THUMB_SYSCALL	0
 
-#define ARM_NR_cacheflush (ARM_SYSCALL_BASE + 0xf0000 + 2)
+#define ARM_NR_BASE       0xf0000
+#define ARM_NR_cacheflush (ARM_NR_BASE + 2)
+#define ARM_NR_set_tls    (ARM_NR_BASE + 5)
 
 #define ARM_NR_semihosting	  0x123456
 #define ARM_NR_thumb_semihosting  0xAB
linux-user/main.c +76 -4

117 lines not on this page · raw message

linux-user/qemu.h +3 -0
Index: qemu/linux-user/qemu.h
===================================================================
@@ -84,6 +84,9 @@
 #endif
     int used; /* non zero if used */
     struct image_info *info;
+#ifdef USE_NPTL
+    uint32_t *child_tidptr;
+#endif
     uint8_t stack[0];
 } __attribute__((aligned(16))) TaskState;
 
linux-user/syscall.c +82 -5

148 lines not on this page · raw message

spinlock.h new file +188 -0

188 lines not on this page · raw message

target-arm/cpu.h +16 -1
Index: qemu/target-arm/cpu.h
===================================================================
@@ -37,6 +37,7 @@
 #define EXCP_IRQ             5
 #define EXCP_FIQ             6
 #define EXCP_BKPT            7
+#define EXCP_KERNEL_TRAP     8   /* Jumped to kernel code page.  */
 
 typedef void ARMWriteCPFunc(void *opaque, int cp_info,
                             int srcreg, int operand, uint32_t value);
@@ -98,6 +99,7 @@
         uint32_t c9_data;
         uint32_t c13_fcse; /* FCSE PID.  */
         uint32_t c13_context; /* Context ID.  */
+        uint32_t c13_tls; /* Thread ID */
         uint32_t c15_cpar; /* XScale Coprocessor Access Register */
         uint32_t c15_ticonfig; /* TI925T configuration byte.  */
         uint32_t c15_i_max; /* Maximum D-cache dirty line index.  */
@@ -174,6 +176,15 @@
 int cpu_arm_signal_handler(int host_signum, void *pinfo,
                            void *puc);
 
+void cpu_lock(void);
+void cpu_unlock(void);
+#if defined(USE_NPTL)
+static inline void cpu_set_tls(CPUARMState *env, void *newtls)
+{
+  env->cp15.c13_tls = (uint32_t)(long)newtls;
+}
+#endif
+
 #define CPSR_M (0x1f)
 #define CPSR_T (1 << 5)
 #define CPSR_F (1 << 6)
@@ -185,7 +196,11 @@
 #define CPSR_J (1 << 24)
 #define CPSR_IT_0_1 (3 << 25)
 #define CPSR_Q (1 << 27)
-#define CPSR_NZCV (0xf << 28)
+#define CPSR_V (1 << 28)
+#define CPSR_C (1 << 29)
+#define CPSR_Z (1 << 30)
+#define CPSR_N (1 << 31)
+#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)
 
 #define CACHED_CPSR_BITS (CPSR_T | CPSR_Q | CPSR_NZCV)
 /* Return the current CPSR value.  */
target-arm/exec.h +0 -2
Index: qemu/target-arm/exec.h
===================================================================
@@ -68,8 +68,6 @@
 
 /* In op_helper.c */
 
-void cpu_lock(void);
-void cpu_unlock(void);
 void helper_set_cp(CPUState *, uint32_t, uint32_t);
 uint32_t helper_get_cp(CPUState *, uint32_t);
 void helper_set_cp15(CPUState *, uint32_t, uint32_t);
target-arm/op.c +6 -0
Index: qemu/target-arm/op.c
===================================================================
@@ -891,6 +891,12 @@
     cpu_loop_exit();
 }
 
+void OPPROTO op_kernel_trap(void)
+{
+    env->exception_index = EXCP_KERNEL_TRAP;
+    cpu_loop_exit();
+}
+
 /* VFP support.  We follow the convention used for VFP instrunctions:
    Single precition routines have a "s" suffix, double precision a
    "d" suffix.  */
target-arm/op_mem.h +1 -0
Index: qemu/target-arm/op_mem.h
===================================================================
@@ -1,5 +1,6 @@
 /* ARM memory operations.  */
 
+void helper_ld(uint32_t);
 /* Load from address T1 into T0.  */
 #define MEM_LD_OP(name) \
 void OPPROTO glue(op_ld##name,MEMSUFFIX)(void) \
target-arm/translate.c +9 -0
Index: qemu/target-arm/translate.c
===================================================================
@@ -3555,6 +3555,15 @@
     nb_gen_labels = 0;
     lj = -1;
     do {
+#ifdef CONFIG_USER_ONLY
+        /* Intercept jump to the magic kernel page.  */
+        if (dc->pc > 0xffff0000) {
+            gen_op_kernel_trap();
+            dc->is_jmp = DISAS_UPDATE;
+            break;
+        }
+#endif
+
         if (env->nb_breakpoints > 0) {
             for(j = 0; j < env->nb_breakpoints; j++) {
                 if (env->breakpoints[j] == dc->pc) {
arm.ld +4 -0
Index: qemu/arm.ld
===================================================================
@@ -26,6 +26,10 @@
     { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
   .rela.rodata   :
     { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+  .rel.tdata     : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
+  .rela.tdata    : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
+  .rel.tbss      : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
+  .rela.tbss     : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
   .rel.got       : { *(.rel.got)		}
   .rela.got      : { *(.rela.got)		}
   .rel.ctors     : { *(.rel.ctors)	}
target-ppc/cpu.h +6 -0
Index: qemu/target-ppc/cpu.h
===================================================================
@@ -589,6 +589,12 @@
 void do_interrupt (CPUPPCState *env);
 void ppc_hw_interrupt (CPUPPCState *env);
 void cpu_loop_exit (void);
+#if defined(USE_NPTL)
+static inline void cpu_set_tls(CPUPPCState *env, void *newtls)
+{
+  env->gpr[2] = (uint32_t)(long)newtls;
+}
+#endif
 
 void dump_stack (CPUPPCState *env);
 
linux-user/main.c +1 -1
Index: qemu/linux-user/main.c
===================================================================
@@ -156,7 +156,7 @@
     p[1] = tswapl(e2);
 }
 
-uint64_t gdt_table[6];
+uint64_t gdt_table[9];
 uint64_t idt_table[256];
 
 /* only dpl matters as we do only user space emulation */
linux-user/syscall.c +159 -24

283 lines not on this page · raw message

configure +1 -1
Index: qemu/configure
===================================================================
@@ -1153,7 +1153,7 @@
 else
     if test "$nptl" = "yes" ; then
         case "$target_cpu" in
-          arm | armeb | ppc | ppc64)
+          arm | armeb | i386 | ppc | ppc64)
             echo "#define USE_NPTL 1" >> $config_h
           ;;
         esac
target-i386/cpu.h +3 -0
Index: qemu/target-i386/cpu.h
===================================================================
@@ -567,6 +567,9 @@
 int cpu_get_pic_interrupt(CPUX86State *s);
 /* MSDOS compatibility mode FPU exception support */
 void cpu_set_ferr(CPUX86State *s);
+#if defined(USE_NPTL)
+#define cpu_set_tls(...) do {} while(0)
+#endif
 
 /* this function must always be used to load data in the segment
    cache: it synchronizes the hflags with the segment cache values */