Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 Simplify gdt_grow, and make sure we don...



details:   https://anonhg.NetBSD.org/src/rev/0a65760985ca
branches:  trunk
changeset: 347332:0a65760985ca
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Aug 21 10:42:33 2016 +0000

description:
Simplify gdt_grow, and make sure we don't kenter more than has been
virtually allocated.

diffstat:

 sys/arch/amd64/amd64/gdt.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (46 lines):

diff -r 7443441fd524 -r 0a65760985ca sys/arch/amd64/amd64/gdt.c
--- a/sys/arch/amd64/amd64/gdt.c        Sun Aug 21 10:20:21 2016 +0000
+++ b/sys/arch/amd64/amd64/gdt.c        Sun Aug 21 10:42:33 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.33 2016/08/21 10:20:21 maxv Exp $    */
+/*     $NetBSD: gdt.c,v 1.34 2016/08/21 10:42:33 maxv Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 2009 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.33 2016/08/21 10:20:21 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.34 2016/08/21 10:42:33 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -228,21 +228,22 @@
 static void
 gdt_grow(void)
 {
-       size_t old_len, new_len;
+       size_t old_size;
        CPU_INFO_ITERATOR cii;
        struct cpu_info *ci;
        struct vm_page *pg;
        vaddr_t va;
 
-       old_len = gdt_size;
+       old_size = gdt_size;
        gdt_size <<= 1;
-       new_len = old_len << 1;
+       if (gdt_size > MAXGDTSIZ)
+               gdt_size = MAXGDTSIZ;
        gdt_dynavail =
            (gdt_size - DYNSEL_START) / sizeof(struct sys_segment_descriptor);
 
        for (CPU_INFO_FOREACH(cii, ci)) {
-               for (va = (vaddr_t)(ci->ci_gdt) + old_len;
-                    va < (vaddr_t)(ci->ci_gdt) + new_len;
+               for (va = (vaddr_t)(ci->ci_gdt) + old_size;
+                    va < (vaddr_t)(ci->ci_gdt) + gdt_size;
                     va += PAGE_SIZE) {
                        while ((pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_ZERO)) ==
                            NULL) {



Home | Main Index | Thread Index | Old Index