From 514d1bbc7b6bb754d49ecdb64b02553bfed7af5f Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 24 May 2015 01:01:49 +0000 Subject: [PATCH] Treat primary cpu like others and put pointer to its GDT in cpu_info.ci_gdt requested by and ok mlarkin@ --- sys/arch/amd64/amd64/gdt.c | 4 ++-- sys/arch/amd64/amd64/machdep.c | 19 +++++++++---------- sys/arch/amd64/include/segments.h | 3 +-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/arch/amd64/amd64/gdt.c b/sys/arch/amd64/amd64/gdt.c index e6933b5d436..bb4ede6af01 100644 --- a/sys/arch/amd64/amd64/gdt.c +++ b/sys/arch/amd64/amd64/gdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.c,v 1.23 2015/03/14 03:38:46 jsg Exp $ */ +/* $OpenBSD: gdt.c,v 1.24 2015/05/24 01:01:49 guenther Exp $ */ /* $NetBSD: gdt.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -66,7 +66,7 @@ gdt_alloc_cpu(struct cpu_info *ci) panic("gdt_init: no pages"); pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg), PROT_READ | PROT_WRITE); } - memcpy(ci->ci_gdt, gdtstore, GDT_SIZE); + memcpy(ci->ci_gdt, cpu_info_primary.ci_gdt, GDT_SIZE); bzero(ci->ci_tss, sizeof(*ci->ci_tss)); } diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index a5f17ebc1ab..4d7be8a8466 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.211 2015/05/18 19:59:27 guenther Exp $ */ +/* $OpenBSD: machdep.c,v 1.212 2015/05/24 01:01:49 guenther Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -1077,7 +1077,6 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, struct gate_descriptor *idt; char idt_allocmap[NIDT]; -char *gdtstore; extern struct user *proc0paddr; void @@ -1558,25 +1557,25 @@ init_x86_64(paddr_t first_avail) idt = (struct gate_descriptor *)idt_vaddr; cpu_info_primary.ci_tss = (void *)(idt + NIDT); - gdtstore = (void *)(cpu_info_primary.ci_tss + 1); + cpu_info_primary.ci_gdt = (void *)(cpu_info_primary.ci_tss + 1); /* make gdt gates and memory segments */ - set_mem_segment(GDT_ADDR_MEM(gdtstore, GCODE_SEL), 0, + set_mem_segment(GDT_ADDR_MEM(cpu_info_primary.ci_gdt, GCODE_SEL), 0, 0xfffff, SDT_MEMERA, SEL_KPL, 1, 0, 1); - set_mem_segment(GDT_ADDR_MEM(gdtstore, GDATA_SEL), 0, + set_mem_segment(GDT_ADDR_MEM(cpu_info_primary.ci_gdt, GDATA_SEL), 0, 0xfffff, SDT_MEMRWA, SEL_KPL, 1, 0, 1); - set_mem_segment(GDT_ADDR_MEM(gdtstore, GUCODE32_SEL), 0, + set_mem_segment(GDT_ADDR_MEM(cpu_info_primary.ci_gdt, GUCODE32_SEL), 0, atop(VM_MAXUSER_ADDRESS32) - 1, SDT_MEMERA, SEL_UPL, 1, 1, 0); - set_mem_segment(GDT_ADDR_MEM(gdtstore, GUDATA_SEL), 0, + set_mem_segment(GDT_ADDR_MEM(cpu_info_primary.ci_gdt, GUDATA_SEL), 0, atop(VM_MAXUSER_ADDRESS) - 1, SDT_MEMRWA, SEL_UPL, 1, 0, 1); - set_mem_segment(GDT_ADDR_MEM(gdtstore, GUCODE_SEL), 0, + set_mem_segment(GDT_ADDR_MEM(cpu_info_primary.ci_gdt, GUCODE_SEL), 0, atop(VM_MAXUSER_ADDRESS) - 1, SDT_MEMERA, SEL_UPL, 1, 0, 1); - set_sys_segment(GDT_ADDR_SYS(gdtstore, GPROC0_SEL), + set_sys_segment(GDT_ADDR_SYS(cpu_info_primary.ci_gdt, GPROC0_SEL), cpu_info_primary.ci_tss, sizeof (struct x86_64_tss)-1, SDT_SYS386TSS, SEL_KPL, 0); @@ -1589,7 +1588,7 @@ init_x86_64(paddr_t first_avail) idt_allocmap[x] = 1; } - setregion(®ion, gdtstore, GDT_SIZE - 1); + setregion(®ion, cpu_info_primary.ci_gdt, GDT_SIZE - 1); lgdt(®ion); cpu_init_idt(); diff --git a/sys/arch/amd64/include/segments.h b/sys/arch/amd64/include/segments.h index 56f23480738..e5b5597a525 100644 --- a/sys/arch/amd64/include/segments.h +++ b/sys/arch/amd64/include/segments.h @@ -1,4 +1,4 @@ -/* $OpenBSD: segments.h,v 1.10 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: segments.h,v 1.11 2015/05/24 01:01:49 guenther Exp $ */ /* $NetBSD: segments.h,v 1.1 2003/04/26 18:39:47 fvdl Exp $ */ /*- @@ -154,7 +154,6 @@ struct region_descriptor { extern struct sys_segment_descriptor *ldt; #endif extern struct gate_descriptor *idt; -extern char *gdtstore; void setgate(struct gate_descriptor *, void *, int, int, int, int); void unsetgate(struct gate_descriptor *); -- 2.20.1