diff options
author | Thomas Nordin <nordin@cvs.openbsd.org> | 2004-05-20 21:06:47 +0000 |
---|---|---|
committer | Thomas Nordin <nordin@cvs.openbsd.org> | 2004-05-20 21:06:47 +0000 |
commit | dbfc9b31db04326f1c9b4ee0b93585abd064848b (patch) | |
tree | 6c376fb084f5824da0e141ac53f0ad93f7bf9342 /sys/arch | |
parent | 7c69cf8c4003a6653d7489bbe821376a3207db2f (diff) |
Make MINGDTSIZ a multiple of PAGE_SIZE to avoid destroying the gdt table.
ok tom@ toby@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/gdt.c | 15 | ||||
-rw-r--r-- | sys/arch/amd64/include/gdt.h | 5 |
2 files changed, 9 insertions, 11 deletions
diff --git a/sys/arch/amd64/amd64/gdt.c b/sys/arch/amd64/amd64/gdt.c index a3d97358368..837c82b8e88 100644 --- a/sys/arch/amd64/amd64/gdt.c +++ b/sys/arch/amd64/amd64/gdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.c,v 1.2 2004/02/27 23:45:23 deraadt Exp $ */ +/* $OpenBSD: gdt.c,v 1.3 2004/05/20 21:06:46 nordin Exp $ */ /* $NetBSD: gdt.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -54,9 +54,6 @@ #include <machine/gdt.h> -#define MINGDTSIZ 2048 -#define MAXGDTSIZ 65536 - int gdt_size; /* size of GDT in bytes */ int gdt_dyncount; /* number of dyn. allocated GDT entries in use */ int gdt_dynavail; @@ -158,7 +155,7 @@ gdt_init() old_gdt = gdtstore; gdtstore = (char *)uvm_km_valloc(kernel_map, MAXGDTSIZ); - for (va = (vaddr_t)gdtstore; va < (vaddr_t)gdtstore + MINGDTSIZ; + for (va = (vaddr_t)gdtstore; va < (vaddr_t)gdtstore + gdt_size; va += PAGE_SIZE) { pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO); if (pg == NULL) { @@ -222,17 +219,17 @@ gdt_reload_cpu(struct cpu_info *ci) void gdt_grow() { - size_t old_len, new_len; + size_t old_len; struct vm_page *pg; vaddr_t va; old_len = gdt_size; - gdt_size <<= 1; - new_len = old_len << 1; + gdt_size = 2 * gdt_size; gdt_dynavail = (gdt_size - DYNSEL_START) / sizeof (struct sys_segment_descriptor); - for (va = (vaddr_t)gdtstore + old_len; va < (vaddr_t)gdtstore + new_len; + for (va = (vaddr_t)gdtstore + old_len; + va < (vaddr_t)gdtstore + gdt_size; va += PAGE_SIZE) { while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO)) == NULL) { diff --git a/sys/arch/amd64/include/gdt.h b/sys/arch/amd64/include/gdt.h index a26608a78e8..a9e5a3dd2f3 100644 --- a/sys/arch/amd64/include/gdt.h +++ b/sys/arch/amd64/include/gdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */ +/* $OpenBSD: gdt.h,v 1.2 2004/05/20 21:06:46 nordin Exp $ */ /* $NetBSD: gdt.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */ /*- @@ -58,5 +58,6 @@ void set_sys_gdt(struct sys_segment_descriptor *, void *, size_t, int, int, int); #endif -#define MINGDTSIZ 2048 +/* MINGDTSIZ must be a multiple of PAGE_SIZE or gdt_grow breaks */ +#define MINGDTSIZ PAGE_SIZE #define MAXGDTSIZ 65536 |