Date: Fri, 25 Apr 2003 17:52:23 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 29751 for review Message-ID: <200304260052.h3Q0qNqQ095460@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=29751 Change 29751 by peter@peter_daintree on 2003/04/25 17:51:55 words cannot express my joy at discovering that I'd misread the sysret description and how it requires an both a 32 bit and 64 bit %cs slot for userland, where the 64 bit slot comes after the shared %ss slot. Also, I neglected to use MSR_SF_MAST to clear PSL_I etc, so get out the big hammer and use it. Affected files ... .. //depot/projects/hammer/sys/x86_64/include/segments.h#18 edit .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#85 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/include/segments.h#18 (text+ko) ==== @@ -176,11 +176,12 @@ #define GNULL_SEL 0 /* Null Descriptor */ #define GCODE_SEL 1 /* Kernel Code Descriptor */ #define GDATA_SEL 2 /* Kernel Data Descriptor */ -#define GUCODE_SEL 3 /* User Code Descriptor */ -#define GUDATA_SEL 4 /* User Data Descriptor */ -#define GPROC0_SEL 5 /* TSS for entering kernel etc */ +#define GUCODE32_SEL 3 /* User 32 bit code Descriptor */ +#define GUDATA_SEL 4 /* User 32/64 bit Data Descriptor */ +#define GUCODE_SEL 5 /* User 64 bit Code Descriptor */ +#define GPROC0_SEL 6 /* TSS for entering kernel etc */ /* slot 6 is second half of GPROC0_SEL */ -#define NGDT 7 +#define NGDT 8 #ifdef _KERNEL extern struct user_segment_descriptor gdt[]; ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#85 (text+ko) ==== @@ -575,27 +575,36 @@ SEL_KPL, /* segment descriptor priority level */ 1, /* segment descriptor present */ 1, /* long */ + 0, /* default 32 vs 16 bit size */ + 1 /* limit granularity (byte/page units)*/ }, +/* GUCODE32_SEL 3 32 bit Code Descriptor for user */ +{ 0x0, /* segment base address */ + 0xfffff, /* length - all address space */ + SDT_MEMERA, /* segment type */ + SEL_UPL, /* segment descriptor priority level */ + 0, /* segment descriptor present */ + 0, /* long */ 1, /* default 32 vs 16 bit size */ 1 /* limit granularity (byte/page units)*/ }, -/* GUCODE_SEL 3 Code Descriptor for user */ +/* GUDATA_SEL 4 32/64 bit Data Descriptor for user */ { 0x0, /* segment base address */ 0xfffff, /* length - all address space */ - SDT_MEMERA, /* segment type */ + SDT_MEMRWA, /* segment type */ SEL_UPL, /* segment descriptor priority level */ 1, /* segment descriptor present */ - 1, /* long */ - 0, /* default 32 vs 16 bit size */ + 0, /* long */ + 1, /* default 32 vs 16 bit size */ 1 /* limit granularity (byte/page units)*/ }, -/* GUDATA_SEL 4 Code Descriptor for user */ +/* GUCODE_SEL 5 64 bit Code Descriptor for user */ { 0x0, /* segment base address */ 0xfffff, /* length - all address space */ - SDT_MEMRWA, /* segment type */ + SDT_MEMERA, /* segment type */ SEL_UPL, /* segment descriptor priority level */ 1, /* segment descriptor present */ 1, /* long */ 0, /* default 32 vs 16 bit size */ 1 /* limit granularity (byte/page units)*/ }, -/* GPROC0_SEL 5 Proc 0 Tss Descriptor */ +/* GPROC0_SEL 6 Proc 0 Tss Descriptor */ { 0x0, /* segment base address */ sizeof(struct x86_64tss)-1,/* length - all address space */ @@ -1250,10 +1259,11 @@ /* Set up the fast syscall stuff */ msr = rdmsr(MSR_EFER) | EFER_SCE; wrmsr(MSR_EFER, msr); - wrmsr(MSR_LSTAR, (uint64_t)IDTVEC(fast_syscall)); + wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall)); msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) | - ((u_int64_t)GSEL(GUCODE_SEL, SEL_UPL) << 48); + ((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48); wrmsr(MSR_STAR, msr); + wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); getmemsize(kmdp, physfree); init_param2(physmem);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304260052.h3Q0qNqQ095460>