Index: src/sys/amd64/amd64/mp_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/amd64/amd64/mp_machdep.c,v retrieving revision 1.287.2.2 diff -u -p -u -r1.287.2.2 mp_machdep.c --- src/sys/amd64/amd64/mp_machdep.c 28 Nov 2007 23:24:06 -0000 1.287.2.2 +++ src/sys/amd64/amd64/mp_machdep.c 18 May 2008 13:45:32 -0000 @@ -457,10 +457,18 @@ init_secondary(void) common_tss[cpu].tss_iobase = sizeof(struct amd64tss); common_tss[cpu].tss_ist1 = (long)&doublefault_stack[PAGE_SIZE]; + /* Use a seperate gdt for each cpu because the tss differs. + * This avoids complications for e.g. virtualization software + * that needs to reload the task register and otherwise would + * then end up using the last cpu's tss on others. + */ + bcopy(gdt, &gdt[NGDT * cpu], NGDT * sizeof(gdt[0])); + gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; ssdtosyssd(&gdt_segs[GPROC0_SEL], - (struct system_segment_descriptor *)&gdt[GPROC0_SEL]); + (struct system_segment_descriptor *)&gdt[NGDT * cpu + GPROC0_SEL]); + r_gdt.rd_base = (long) &gdt[NGDT * cpu]; lgdt(&r_gdt); /* does magic intra-segment return */ /* Get per-cpu data */