From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7d86713974a2fbf4ce745a97e7cb5ab5@gmx.de> To: 9fans@9fans.net Date: Tue, 16 Jun 2009 05:46:10 +0200 From: cinap_lenrek@gmx.de MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] interface for per process gdt manipulation Topicbox-Message-UUID: 0b613684-ead5-11e9-9d60-3106f5b1d025 for vx32 and linuxemu an interface is needed in the plan9 kernel to modify per process gdt entries. for linuxemu, i ended up with a kernel patch that adds a gdt file to devproc for each process that contains the binary representation of the process view of the global descriptor table. /n/sources/contrib/cinap_Lenrek/gdtpatch.tar the interface: /proc/n/gdt reading the gdt file gets you the whole gdt table. starting from a constant offset, here are 4 descriptors that are writable trou the gdt file. writing any other offsets causes an error. the write also checks if the current segment registers still contain valid selectors if the write would be applied. so for example writing a descriptor for a read only segment that is selected by the current ss register will fail. i would like to have such an interface in the default distribution some day so any objections are welcome. implementation details for the patch: the patch adds Segdesc ugdt[NUGDT] to the PMMU struct in pc/dat.h for the per process gdt entries. these entries are copied to m->gdt[] on procrestore in pc/main.c on context switch. noted was changed in pc/trap.c to only check for the case that the selectors point to valid descriptors, not force any specific selector. pc/mmu.c contains the reading/writing and checking code. -- cinap