From owner-p4-projects@FreeBSD.ORG Tue Feb 20 21:22:41 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 35ED116A8A4; Tue, 20 Feb 2007 21:22:40 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C64DF16C6DE for ; Tue, 20 Feb 2007 21:22:39 +0000 (UTC) (envelope-from jkim@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id B53BA13C481 for ; Tue, 20 Feb 2007 21:22:39 +0000 (UTC) (envelope-from jkim@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l1KLMdCQ029793 for ; Tue, 20 Feb 2007 21:22:39 GMT (envelope-from jkim@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l1KLMdXR029790 for perforce@freebsd.org; Tue, 20 Feb 2007 21:22:39 GMT (envelope-from jkim@freebsd.org) Date: Tue, 20 Feb 2007 21:22:39 GMT Message-Id: <200702202122.l1KLMdXR029790@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jkim@freebsd.org using -f From: Jung-uk Kim To: Perforce Change Reviews Cc: Subject: PERFORCE change 114771 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Feb 2007 21:22:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=114771 Change 114771 by jkim@jkim_hammer on 2007/02/20 21:21:45 - Check GUDATA_SEL for set_thread_area(). It is default selector for %gs. - Force GUGS32_SEL for clone with CLONE_SETTLS. Affected files ... .. //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#40 edit Differences ... ==== //depot/projects/linuxolator/src/sys/amd64/linux32/linux32_machdep.c#40 (text+ko) ==== @@ -659,39 +659,19 @@ struct user_segment_descriptor sd; struct l_user_desc info; int a[2]; - int idx; error = copyin((void *)td->td_frame->tf_rsi, &info, sizeof(struct l_user_desc)); if (error) { printf(LMSG("copyin failed!")); } else { + /* We might copy out the entry_number as GUGS32_SEL. */ + info.entry_number = GUGS32_SEL; + error = copyout(&info, (void *)td->td_frame->tf_rsi, + sizeof(struct l_user_desc)); + if (error) + printf(LMSG("copyout failed!")); - idx = info.entry_number; - - /* - * It looks like we're getting the idx we returned - * in the set_thread_area() syscall. - */ - if (idx != 6 && idx != GUGS32_SEL) { - printf(LMSG("resetting idx!")); - idx = 6; /* or GUGS32_SEL? */ - } - - /* this doesnt happen in practice */ - if (idx == 6) { - /* - * We might copy out the entry_number - * as GUGS32_SEL. - */ - info.entry_number = GUGS32_SEL; - error = copyout(&info, - (void *)td->td_frame->tf_rsi, - sizeof(struct l_user_desc)); - if (error) - printf(LMSG("copyout failed!")); - } - a[0] = LDT_entry_a(&info); a[1] = LDT_entry_b(&info); @@ -1252,7 +1232,6 @@ struct user_segment_descriptor sd; int a[2]; int error; - int idx; error = copyin(args->desc, &info, sizeof(struct l_user_desc)); if (error) @@ -1267,7 +1246,6 @@ info.seg_not_present, info.useable); #endif - idx = info.entry_number; /* * Semantics of Linux version: every thread in the system has array * of three TLS descriptors. 1st is GLIBC TLS, 2nd is WINE, 3rd unknown. @@ -1287,18 +1265,25 @@ /* * GLIBC reads current %gs and call set_thread_area() with it. - * We should let GUGS32_SEL proceed as well because we use this - * segment. + * We should let GUDATA_SEL and GUGS32_SEL proceed as well because + * we use these segments. */ - if (idx != 6 && idx != -1 && idx != GUGS32_SEL) + switch (info.entry_number) { + case GUGS32_SEL: + case GUDATA_SEL: + case 6: + case -1: + info.entry_number = GUGS32_SEL; + break; + default: return (EINVAL); + } /* * We have to copy out the GDT entry we use. * XXX: What if userspace program does not check return value and * tries to use 6, 7 or 8? */ - idx = info.entry_number = GUGS32_SEL; error = copyout(&info, args->desc, sizeof(struct l_user_desc)); if (error) return (error);