From patchwork Fri Feb 12 18:31:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Castet X-Patchwork-Id: 45206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 82870B7BFA for ; Sat, 13 Feb 2010 05:33:49 +1100 (EST) Received: from localhost ([127.0.0.1]:36341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ng0Ko-00078P-O0 for incoming@patchwork.ozlabs.org; Fri, 12 Feb 2010 13:33:46 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ng0IM-0005lY-Ck for qemu-devel@nongnu.org; Fri, 12 Feb 2010 13:31:14 -0500 Received: from [199.232.76.173] (port=38934 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ng0IL-0005kw-TV for qemu-devel@nongnu.org; Fri, 12 Feb 2010 13:31:13 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Ng0IK-0001zz-If for qemu-devel@nongnu.org; Fri, 12 Feb 2010 13:31:13 -0500 Received: from smtp2-g21.free.fr ([212.27.42.2]:44239) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ng0IJ-0001zV-PA for qemu-devel@nongnu.org; Fri, 12 Feb 2010 13:31:12 -0500 Received: from smtp2-g21.free.fr (localhost [127.0.0.1]) by smtp2-g21.free.fr (Postfix) with ESMTP id E92F24B00B7 for ; Fri, 12 Feb 2010 19:31:04 +0100 (CET) Received: from [192.168.1.189] (cac94-1-81-57-151-96.fbx.proxad.net [81.57.151.96]) by smtp2-g21.free.fr (Postfix) with ESMTP id 0AC8C4B0255 for ; Fri, 12 Feb 2010 19:31:01 +0100 (CET) Message-ID: <4B759E65.6050605@free.fr> Date: Fri, 12 Feb 2010 19:31:01 +0100 From: matthieu castet User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.8.1.23) Gecko/20090823 SeaMonkey/1.1.18 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH] add usermode NPTL support for i386 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, this patch try to add usermode NPTL support for i386. Note that this patch need review because I don't know if I did the right thing removing the cpu_reset in the clone path. Matthieu diff --git a/configure b/configure index 0a84b0e..69ccb13 100755 --- a/configure +++ b/configure @@ -2342,6 +2342,7 @@ TARGET_ABI_DIR="" case "$target_arch2" in i386) target_phys_bits=32 + target_nptl="yes" ;; x86_64) TARGET_BASE_ARCH=i386 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9fb493f..38f2067 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3426,6 +3426,13 @@ static abi_long do_get_thread_area(CPUX86State *env, abi_ulong ptr) unlock_user_struct(target_ldt_info, ptr, 1); return 0; } + +static inline void cpu_set_tls(CPUState *env, target_ulong newtls) +{ + do_set_thread_area(env, newtls); + /* reload gs */ + cpu_x86_load_seg(env, R_GS, env->segs[R_GS].selector); +} #endif /* TARGET_I386 && TARGET_ABI32 */ #ifndef TARGET_ABI32 @@ -3554,7 +3561,16 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, new_stack = ts->stack; /* we create a new CPU instance. */ new_env = cpu_copy(env); -#if defined(TARGET_I386) || defined(TARGET_SPARC) || defined(TARGET_PPC) +#if defined(TARGET_I386) + new_env->idt.base = target_mmap(0, sizeof(uint64_t) * (env->idt.limit + 1), + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + memcpy(g2h(new_env->idt.base), g2h(env->idt.base), sizeof(uint64_t) * (env->idt.limit + 1)); + new_env->gdt.base = target_mmap(0, sizeof(uint64_t) * TARGET_GDT_ENTRIES, + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); + memcpy(g2h(new_env->gdt.base), g2h(env->gdt.base), sizeof(uint64_t) * TARGET_GDT_ENTRIES); +#elif defined(TARGET_SPARC) || defined(TARGET_PPC) cpu_reset(new_env); #endif /* Init regs that differ from the parent. */