Changeset 308 for trunk/hal/x86_64/core/hal_init.c
- Timestamp:
- Aug 1, 2017, 10:30:39 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_init.c
r298 r308 26 26 #include <hal_acpi.h> 27 27 #include <hal_apic.h> 28 #include <hal_kentry.h> 28 29 #include <hal_internal.h> 29 30 #include <hal_register.h> … … 447 448 static void 448 449 gdt_set_memseg(struct gdt_memseg *sd, void *base, size_t limit, 449 int type, int dpl, int gran, int is64)450 int type, int dpl, int gran, bool_t is64) 450 451 { 451 452 sd->sd_lolimit = (unsigned)limit; … … 457 458 sd->sd_avl = 0; 458 459 sd->sd_long = is64; 459 sd->sd_def32 = 0;460 sd->sd_def32 = !is64; 460 461 sd->sd_gran = gran; 461 462 sd->sd_hibase = (unsigned long)base >> 24; … … 483 484 /* Flat segments */ 484 485 gdt_set_memseg(GDT_ADDR_MEM(gdtstore, GDT_KCODE_SEL), 0, 485 0xfffff, SDT_MEMERA, SEL_KPL, 1, 1);486 0xfffff, SDT_MEMERA, SEL_KPL, 1, true); 486 487 gdt_set_memseg(GDT_ADDR_MEM(gdtstore, GDT_KDATA_SEL), 0, 487 0xfffff, SDT_MEMRWA, SEL_KPL, 1, 1); 488 0xfffff, SDT_MEMRWA, SEL_KPL, 1, true); 489 gdt_set_memseg(GDT_ADDR_MEM(gdtstore, GDT_UCODE32_SEL), 0, 490 0xfffff, SDT_MEMERA, SEL_UPL, 1, false); 488 491 gdt_set_memseg(GDT_ADDR_MEM(gdtstore, GDT_UCODE_SEL), 0, 489 0xfffff, SDT_MEMERA, SEL_UPL, 1, 1);492 0xfffff, SDT_MEMERA, SEL_UPL, 1, true); 490 493 gdt_set_memseg(GDT_ADDR_MEM(gdtstore, GDT_UDATA_SEL), 0, 491 0xfffff, SDT_MEMRWA, SEL_UPL, 1, 1);494 0xfffff, SDT_MEMRWA, SEL_UPL, 1, true); 492 495 } 493 496 … … 625 628 void cpu_tls_init(size_t lid) 626 629 { 630 extern uint64_t x86_syscall; 631 extern uint64_t x86_syscall32; 632 627 633 percpu_archdata_t *data = &cpudata[lid]; 628 634 tls_t *cputls = &data->tls; … … 635 641 cputls->tls_intr = INTRS_DISABLED; 636 642 643 /* syscall */ 644 wrmsr(MSR_STAR, 645 ((uint64_t)GDT_FIXED_SEL(GDT_KCODE_SEL, SEL_KPL) << 32) | 646 ((uint64_t)GDT_FIXED_SEL(GDT_UCODE32_SEL, SEL_UPL) << 48)); 647 wrmsr(MSR_LSTAR, (uint64_t)&x86_syscall); 648 wrmsr(MSR_CSTAR, (uint64_t)&x86_syscall32); 649 wrmsr(MSR_SFMASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); 650 651 /* TLS */ 637 652 wrmsr(MSR_FSBASE, 0); 638 653 wrmsr(MSR_GSBASE, (uint64_t)cputls);
Note: See TracChangeset
for help on using the changeset viewer.