Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Rename ldt->ldtstore and gdt->gdtstore on i386. It reduc...
details: https://anonhg.NetBSD.org/src/rev/343e1ba1a7c8
branches: trunk
changeset: 351189:343e1ba1a7c8
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Feb 05 10:42:21 2017 +0000
description:
Rename ldt->ldtstore and gdt->gdtstore on i386. It reduces the diff with
amd64, and makes it easier to track down these variables on nxr - 'ldt'
and 'gdt' being common keywords.
diffstat:
sys/arch/i386/i386/gdt.c | 45 ++++++++-------
sys/arch/i386/i386/machdep.c | 85 +++++++++++++++--------------
sys/arch/i386/include/segments.h | 4 +-
sys/arch/x86/x86/sys_machdep.c | 10 +-
sys/arch/xen/x86/cpu.c | 8 +-
sys/arch/xen/x86/xenfunc.c | 6 +-
sys/compat/linux/arch/i386/linux_machdep.c | 6 +-
7 files changed, 85 insertions(+), 79 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r 62c89103c3e6 -r 343e1ba1a7c8 sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c Sun Feb 05 10:13:43 2017 +0000
+++ b/sys/arch/i386/i386/gdt.c Sun Feb 05 10:42:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gdt.c,v 1.56 2016/12/17 14:27:53 maxv Exp $ */
+/* $NetBSD: gdt.c,v 1.57 2017/02/05 10:42:21 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.56 2016/12/17 14:27:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.57 2017/02/05 10:42:21 maxv Exp $");
#include "opt_multiprocessor.h"
#include "opt_xen.h"
@@ -85,7 +85,7 @@
setgdt(int sel, const void *base, size_t limit, int type, int dpl, int def32,
int gran)
{
- struct segment_descriptor *sd = &gdt[sel].sd;
+ struct segment_descriptor *sd = &gdtstore[sel].sd;
CPU_INFO_ITERATOR cii;
struct cpu_info *ci;
@@ -115,8 +115,8 @@
vaddr_t va;
struct cpu_info *ci = &cpu_info_primary;
- max_len = MAXGDTSIZ * sizeof(gdt[0]);
- min_len = MINGDTSIZ * sizeof(gdt[0]);
+ max_len = MAXGDTSIZ * sizeof(gdtstore[0]);
+ min_len = MINGDTSIZ * sizeof(gdtstore[0]);
gdt_size[0] = MINGDTSIZ;
gdt_count[0] = NGDT;
@@ -130,10 +130,11 @@
gdt_free[1] = GNULL_SEL;
#endif
- old_gdt = gdt;
- gdt = (union descriptor *)uvm_km_alloc(kernel_map, max_len,
+ old_gdt = gdtstore;
+ gdtstore = (union descriptor *)uvm_km_alloc(kernel_map, max_len,
0, UVM_KMF_VAONLY);
- for (va = (vaddr_t)gdt; va < (vaddr_t)gdt + min_len; va += PAGE_SIZE) {
+ for (va = (vaddr_t)gdtstore; va < (vaddr_t)gdtstore + min_len;
+ va += PAGE_SIZE) {
pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO);
if (pg == NULL) {
panic("gdt_init: no pages");
@@ -142,8 +143,8 @@
VM_PROT_READ | VM_PROT_WRITE, 0);
}
pmap_update(pmap_kernel());
- memcpy(gdt, old_gdt, NGDT * sizeof(gdt[0]));
- ci->ci_gdt = gdt;
+ memcpy(gdtstore, old_gdt, NGDT * sizeof(gdtstore[0]));
+ ci->ci_gdt = gdtstore;
setsegment(&ci->ci_gdt[GCPU_SEL].sd, ci,
sizeof(struct cpu_info) - 1, SDT_MEMRWA, SEL_KPL, 1, 0);
@@ -156,8 +157,8 @@
void
gdt_alloc_cpu(struct cpu_info *ci)
{
- int max_len = MAXGDTSIZ * sizeof(gdt[0]);
- int min_len = MINGDTSIZ * sizeof(gdt[0]);
+ int max_len = MAXGDTSIZ * sizeof(gdtstore[0]);
+ int min_len = MINGDTSIZ * sizeof(gdtstore[0]);
struct vm_page *pg;
vaddr_t va;
@@ -174,7 +175,7 @@
}
pmap_update(pmap_kernel());
memset(ci->ci_gdt, 0, min_len);
- memcpy(ci->ci_gdt, gdt, gdt_count[0] * sizeof(gdt[0]));
+ memcpy(ci->ci_gdt, gdtstore, gdt_count[0] * sizeof(gdtstore[0]));
setsegment(&ci->ci_gdt[GCPU_SEL].sd, ci,
sizeof(struct cpu_info) - 1, SDT_MEMRWA, SEL_KPL, 1, 0);
}
@@ -191,11 +192,11 @@
struct region_descriptor region;
size_t max_len;
- max_len = MAXGDTSIZ * sizeof(gdt[0]);
+ max_len = MAXGDTSIZ * sizeof(gdtstore[0]);
setregion(®ion, ci->ci_gdt, max_len - 1);
lgdt(®ion);
#else
- size_t len = gdt_size[0] * sizeof(gdt[0]);
+ size_t len = gdt_size[0] * sizeof(gdtstore[0]);
unsigned long frames[len >> PAGE_SHIFT];
vaddr_t va;
pt_entry_t *ptp;
@@ -233,7 +234,7 @@
struct region_descriptor region;
size_t max_len;
- max_len = MAXGDTSIZ * sizeof(gdt[0]);
+ max_len = MAXGDTSIZ * sizeof(gdtstore[0]);
setregion(®ion, ci->ci_gdt, max_len - 1);
lgdt(®ion);
}
@@ -252,16 +253,16 @@
struct vm_page *pg;
vaddr_t va;
- old_len = gdt_size[which] * sizeof(gdt[0]);
+ old_len = gdt_size[which] * sizeof(gdtstore[0]);
gdt_size[which] <<= 1;
new_len = old_len << 1;
#ifdef XEN
if (which != 0) {
- size_t max_len = MAXGDTSIZ * sizeof(gdt[0]);
+ size_t max_len = MAXGDTSIZ * sizeof(gdtstore[0]);
if (old_len == 0) {
gdt_size[which] = MINGDTSIZ;
- new_len = gdt_size[which] * sizeof(gdt[0]);
+ new_len = gdt_size[which] * sizeof(gdtstore[0]);
}
for (CPU_INFO_FOREACH(cii, ci)) {
for(va = (vaddr_t)(ci->ci_gdt) + old_len + max_len;
@@ -325,9 +326,9 @@
if (gdt_free[which] != GNULL_SEL) {
slot = gdt_free[which];
- gdt_free[which] = gdt[slot].gd.gd_selector;
+ gdt_free[which] = gdtstore[slot].gd.gd_selector;
} else {
- offset = which * MAXGDTSIZ * sizeof(gdt[0]);
+ offset = which * MAXGDTSIZ * sizeof(gdtstore[0]);
if (gdt_next[which] != gdt_count[which] + offset)
panic("gdt_get_slot botch 1");
if (gdt_next[which] - offset >= gdt_size[which]) {
@@ -369,7 +370,7 @@
d.gd.gd_type = SDT_SYSNULL;
d.gd.gd_selector = gdt_free[which];
- update_descriptor(&gdt[slot], &d);
+ update_descriptor(&gdtstore[slot], &d);
gdt_free[which] = slot;
}
diff -r 62c89103c3e6 -r 343e1ba1a7c8 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Sun Feb 05 10:13:43 2017 +0000
+++ b/sys/arch/i386/i386/machdep.c Sun Feb 05 10:42:21 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.777 2017/01/22 20:17:10 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.778 2017/02/05 10:42:21 maxv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.777 2017/01/22 20:17:10 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.778 2017/02/05 10:42:21 maxv Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -505,8 +505,8 @@
pcb->pcb_esp0 = uvm_lwp_getuarea(l) + USPACE - 16;
pcb->pcb_iopl = SEL_KPL;
l->l_md.md_regs = (struct trapframe *)pcb->pcb_esp0 - 1;
- memcpy(&pcb->pcb_fsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_fsd));
- memcpy(&pcb->pcb_gsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_gsd));
+ memcpy(&pcb->pcb_fsd, &gdtstore[GUDATA_SEL], sizeof(pcb->pcb_fsd));
+ memcpy(&pcb->pcb_gsd, &gdtstore[GUDATA_SEL], sizeof(pcb->pcb_gsd));
memset(l->l_md.md_watchpoint, 0, sizeof(*l->l_md.md_watchpoint));
#ifndef XEN
@@ -838,8 +838,8 @@
fpu_save_area_clear(l, pack->ep_osversion >= 699002600
? __INITIAL_NPXCW__ : __NetBSD_COMPAT_NPXCW__);
- memcpy(&pcb->pcb_fsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_fsd));
- memcpy(&pcb->pcb_gsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_gsd));
+ memcpy(&pcb->pcb_fsd, &gdtstore[GUDATA_SEL], sizeof(pcb->pcb_fsd));
+ memcpy(&pcb->pcb_gsd, &gdtstore[GUDATA_SEL], sizeof(pcb->pcb_gsd));
memset(l->l_md.md_watchpoint, 0, sizeof(*l->l_md.md_watchpoint));
@@ -867,8 +867,8 @@
* Initialize segments and descriptor tables
*/
-union descriptor *gdt, *ldt;
-union descriptor *pentium_idt;
+union descriptor *gdtstore, *ldtstore;
+union descriptor *pentium_idt;
extern vaddr_t lwp0uarea;
void
@@ -959,34 +959,37 @@
{
KASSERT(tgdt != NULL);
- gdt = tgdt;
+ gdtstore = tgdt;
#ifdef XEN
u_long frames[16];
#else
struct region_descriptor region;
- memset(gdt, 0, NGDT*sizeof(*gdt));
-#endif /* XEN */
+ memset(gdtstore, 0, NGDT * sizeof(*gdtstore));
+#endif
+
/* make gdt gates and memory segments */
- setsegment(&gdt[GCODE_SEL].sd, 0, 0xfffff, SDT_MEMERA, SEL_KPL, 1, 1);
- setsegment(&gdt[GDATA_SEL].sd, 0, 0xfffff, SDT_MEMRWA, SEL_KPL, 1, 1);
- setsegment(&gdt[GUCODE_SEL].sd, 0, x86_btop(I386_MAX_EXE_ADDR) - 1,
+ setsegment(&gdtstore[GCODE_SEL].sd, 0, 0xfffff,
+ SDT_MEMERA, SEL_KPL, 1, 1);
+ setsegment(&gdtstore[GDATA_SEL].sd, 0, 0xfffff,
+ SDT_MEMRWA, SEL_KPL, 1, 1);
+ setsegment(&gdtstore[GUCODE_SEL].sd, 0, x86_btop(I386_MAX_EXE_ADDR) - 1,
SDT_MEMERA, SEL_UPL, 1, 1);
- setsegment(&gdt[GUCODEBIG_SEL].sd, 0, 0xfffff,
+ setsegment(&gdtstore[GUCODEBIG_SEL].sd, 0, 0xfffff,
SDT_MEMERA, SEL_UPL, 1, 1);
- setsegment(&gdt[GUDATA_SEL].sd, 0, 0xfffff,
+ setsegment(&gdtstore[GUDATA_SEL].sd, 0, 0xfffff,
SDT_MEMRWA, SEL_UPL, 1, 1);
#if NBIOSCALL > 0
/* bios trampoline GDT entries */
- setsegment(&gdt[GBIOSCODE_SEL].sd, 0, 0xfffff, SDT_MEMERA, SEL_KPL, 0,
- 0);
- setsegment(&gdt[GBIOSDATA_SEL].sd, 0, 0xfffff, SDT_MEMRWA, SEL_KPL, 0,
- 0);
+ setsegment(&gdtstore[GBIOSCODE_SEL].sd, 0, 0xfffff,
+ SDT_MEMERA, SEL_KPL, 0, 0);
+ setsegment(&gdtstore[GBIOSDATA_SEL].sd, 0, 0xfffff,
+ SDT_MEMRWA, SEL_KPL, 0, 0);
#endif
- setsegment(&gdt[GCPU_SEL].sd, &cpu_info_primary,
+ setsegment(&gdtstore[GCPU_SEL].sd, &cpu_info_primary,
sizeof(struct cpu_info) - 1, SDT_MEMRWA, SEL_KPL, 1, 0);
#ifndef XEN
- setregion(®ion, gdt, NGDT * sizeof(gdt[0]) - 1);
+ setregion(®ion, gdtstore, NGDT * sizeof(gdtstore[0]) - 1);
lgdt(®ion);
#else /* !XEN */
/*
@@ -997,7 +1000,7 @@
xpmap_phys_to_machine_mapping =
(unsigned long *)xen_start_info.mfn_list;
- frames[0] = xpmap_ptom((uint32_t)gdt - KERNBASE) >> PAGE_SHIFT;
+ frames[0] = xpmap_ptom((uint32_t)gdtstore - KERNBASE) >> PAGE_SHIFT;
{ /*
* Enter the gdt page RO into the kernel map. We can't
* use pmap_kenter_pa() here, because %fs is not
@@ -1009,10 +1012,11 @@
extern pt_entry_t xpmap_pg_nx;
pt_entry_t pte;
- pte = pmap_pa2pte((vaddr_t)gdt - KERNBASE);
+ pte = pmap_pa2pte((vaddr_t)gdtstore - KERNBASE);
pte |= PG_k | PG_RO | xpmap_pg_nx | PG_V;
- if (HYPERVISOR_update_va_mapping((vaddr_t)gdt, pte, UVMF_INVLPG) < 0) {
+ if (HYPERVISOR_update_va_mapping((vaddr_t)gdtstore, pte,
+ UVMF_INVLPG) < 0) {
panic("gdt page RO update failed.\n");
}
@@ -1153,7 +1157,7 @@
/* Use the dummy page as a gdt */
extern vaddr_t xen_dummy_page;
- gdt = (void *)xen_dummy_page;
+ gdtstore = (void *)xen_dummy_page;
/* Determine physical address space */
avail_end = ctob((paddr_t)xen_start_info.nr_pages);
@@ -1170,7 +1174,7 @@
* initialised. initgdt() uses pmap_kenter_pa so it can't be called
* before the above variables are set.
*/
- initgdt(gdt);
+ initgdt(gdtstore);
mutex_init(&pte_lock, MUTEX_DEFAULT, IPL_VM);
#endif /* XEN */
@@ -1262,31 +1266,32 @@
pmap_update(pmap_kernel());
pentium_idt = (union descriptor *)pentium_idt_vaddr;
- tgdt = gdt;
+ tgdt = gdtstore;
idt = (struct gate_descriptor *)idt_vaddr;
- gdt = (union descriptor *)gdt_vaddr;
Home |
Main Index |
Thread Index |
Old Index