From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0510bb6f1fcb7c2a30557bc374eba6fa@gmx.de> To: 9fans@9fans.net Date: Wed, 30 Jun 2010 00:35:43 +0200 From: cinap_lenrek@gmx.de In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-rdroxyytytxarupdccofurroby" Subject: Re: [9fans] Go/Inferno toolchain (Was: comment and newline in Topicbox-Message-UUID: 3aa8a16a-ead6-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-rdroxyytytxarupdccofurroby Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit the segment registers are just indices to the kernels descriptor tables. setting the segment registers can be done with assembly instructions from userspace. but what you need is being able to modify the descriptors in a save way from userspace! i needed this for linuxemu to implement set_thread_area syscalls under plan9 so i made the modifications to the kernel: /n/sources/contrib/cinap_lenrek/segdescpatch it adds the files ldt and gdt to devarch. heres a linuxemu process where glibc has setup a special descriptor and loaded %gs to point to it under plan9: cat /dev/gdt 000b data WPUBG 3 1819c080 fffff 000c data - 0 00000000 00000 000d data - 0 00000000 00000 PC 0x00020439 pread+0x7 /sys/src/libc/9syscall/pread.s:5 SP 0xdeffcd70 ECODE 0xf010080c EFLAG 0x00000286 CS 0x00000023 DS 0x0000001b SS 0x0000001b GS 0x0000005b FS 0x00000000 ES 0x0000001b TRAP 0x00000040 system call AX 0x00000032 BX 0x00032b4c CX 0x00000001 DX 0x00000000 DI 0x080e7468 SI 0x00000000 BP 0xdeffcf2c format of is simple text: /* * format: * idx[4] type[8] flags[8] dpl[1] base[8] limit[5]\n */ idx is the descriptor index (the one you load into a segment registers by the selector) type is code or data dpl is the priority level (usualy just 3 for userspace) base and limit describe the location of the segment (limit is in pages if G flag is set) /* * flags: * P = present * A = accessed (for code/data) * E = expand down (for data) * W = writable (for data) * R = readable (for code) * C = conforming (for code) * G = limit granularity in pages (for code/data) * D = 32 bit operand size (for code) * B = 32 bit stack pointer (for data) * Y = busy (for tss and tss16) * U = available for use by system software */ gdt and ldt are both per process. the only difference between gdt and ldt is that gdt has a small fixed number of descriptors in the gdt that you can modify. the ldt refers to the local descriptor table wich can have up to 2^13 user descriptors. -- cinap --upas-rdroxyytytxarupdccofurroby Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <9fans-bounces+cinap_lenrek=gmx.de@9fans.net> X-Flags: 0000 Delivered-To: GMX delivery to cinap_lenrek@gmx.de Received: (qmail invoked by alias); 29 Jun 2010 21:06:08 -0000 Received: from gouda.swtch.com (EHLO gouda.swtch.com) [67.207.142.3] by mx0.gmx.net (mx015) with SMTP; 29 Jun 2010 23:06:08 +0200 Received: from localhost ([127.0.0.1] helo=gouda.swtch.com) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from <9fans-bounces@9fans.net>) id 1OThy4-0001dS-Dg; Tue, 29 Jun 2010 21:03:44 +0000 Received: from mail-wy0-f177.google.com ([74.125.82.177]) by gouda.swtch.com with esmtp (Exim 4.69) (envelope-from ) id 1OThy2-0001dN-KF for 9fans@9fans.net; Tue, 29 Jun 2010 21:03:42 +0000 Received: by wyb32 with SMTP id 32so48746wyb.36 for <9fans@9fans.net>; Tue, 29 Jun 2010 14:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=DwSvxpDtsy816pV6RaREzlpkIvBHZvj2R2SvbHpovMk=; b=HocTDpfhQIDYGVcdbATwN0wC7Qs9WtwufRdsDHoB8iMnAJsA93r2NBUfFGNlLSw9HA obvlGhz5oV6kK3gcoZ/Jce5gPLcInbf4Awwm/vV0QN8YjW5Xt4HPRSkb4E1cm7ruyJoC rJ7I9MWt6eC1jtj6Hlhv0qMJGsCycRhD2sXe8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=B9sYdLV9yr+gHCnx1tOOD5+S/Mfwd7fVXDlEpdzBVH3PMwOZdkzo8XBklxMp1rAuaq Kg8A41qanzjiPb7a7HP3WTvTBnK4lMA9d0c89qlUFq2Dmo5iqT004YItHTDdyuayVUCU 1WPVZpYRh41adF0RUEIsCF5qEtHYF53IjF1yQ= MIME-Version: 1.0 Received: by 10.216.86.140 with SMTP id w12mr5784287wee.95.1277845416401; Tue, 29 Jun 2010 14:03:36 -0700 (PDT) Received: by 10.216.180.78 with HTTP; Tue, 29 Jun 2010 14:03:36 -0700 (PDT) In-Reply-To: <0ab4e0867c119e024b86176ede4cd12e@ladd.quanstro.net> References: <464534aea8c7fffa248a1368c41acb55@proxima.alt.za> <19b728d48aa74d67b8402c1b9727c80e@coraid.com> <0ab4e0867c119e024b86176ede4cd12e@ladd.quanstro.net> Date: Tue, 29 Jun 2010 14:03:36 -0700 Message-ID: From: ron minnich To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [9fans] Go/Inferno toolchain (Was: comment and newline in X-BeenThere: 9fans@9fans.net X-Mailman-Version: 2.1.10 Precedence: list Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> List-Id: Fans of the OS Plan 9 from Bell Labs <9fans.9fans.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: 9fans-bounces@9fans.net Errors-To: 9fans-bounces+cinap_lenrek=gmx.de@9fans.net X-GMX-Antivirus: 0 (no virus found) X-GMX-Antispam: 0 (Sender is in whitelist: rminnich@gmail.com); Detail=5D7Q89H36p4L00VTXC6D4q0N+AH0PUCnetdm6+jp8LF+tAiRn7+lma6RwlXCy1ukem4Xx mt89Mv9SdHr7XJZmXAvwanJf/hYV1; X-GMX-UID: eFIZeCJfX1Vpbssqz2FyuSl3SDc4NAzr Can someone remind me of the problem? Is it simply the need to be able to set %gs? Could a write to /dev/arch of something like gs 0xwhatever which sets %gs for that process solve the problem? Or is it bigger than that? ron --upas-rdroxyytytxarupdccofurroby--