these are the changes to the plan 9 kernel to add per process segment descriptors. the 9/ directory contains all the changed files from /sys/src/9. kernel.diff contains the changes. the changes in detail are: pc/fns.h 1) prototype for lldt() added (for l.s) 2) prototype for procfork() added 3) changed userureg macro to test for the rpl bits but not for the specific UDSEL selector. this is because with the patch, a process is allowed to change its data segment. so we test only for the "requested priviledge level" bits. pc/dat.h 1) moved the Segdesc struct declaration. 2) added ldt and gdt to PMMU struct pc/mem.h 1) added segment definitions for LDT and PROCSEGs pc/io.h 1) added vector constants for general protection fault and seg not present. pc/trap.c 1) replaced the user test with userureg() macro 2) added GPF handler to trap() that catches the fault when we return to userspace, but the segment registers contain invalid selectors. previously this was not needed as the segment registers for user space where constant and checked. 3) in the case we have a trap in kernel mode, the processor doesnt push the SS and SP registers. fixed up dumpregs() to print the right values. 4) set default segments in notify() 5) removed the segment check in notify as we handle it with the GPF handler in trap(). only make sure the user doesnt change the code and stack segments to kernel ones. 6) set default segments in execregs() 7) changing of segments from devproc is ok now as long as code and stack don't point to kernel segments. changed in setregisters() pc/mmu.c 1) added switching of procsegs and ldt in mmuswitch() 2) free the ldt in mmurelease() pc/l.s 1) added lldt() function as it is requred for switching the ldt. 2) added load_fs() and load_gs() as it is needed in the GPF handler. pc/segdesc.c 1) this file contains the code to change the per process descriptors. it adds the ldt and gdt files to devarch. pc/main.c 1) setup gdt and ldt in procsetup() 2) added procfork() to copy ldt and gdt when forking */main.c 1) added empty procfork() as well */fns.h 1) added procfork() prototype port/sysproc.c 1) added call to forkfork() from sysfork() to the ldt and gdt get copied