Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Localify.



details:   https://anonhg.NetBSD.org/src/rev/ae66b9da1f22
branches:  trunk
changeset: 347307:ae66b9da1f22
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Aug 20 16:05:48 2016 +0000

description:
Localify.

diffstat:

 sys/arch/amd64/amd64/gdt.c  |  22 +++++++++----------
 sys/arch/i386/i386/gdt.c    |  50 +++++++++++++++++++++-----------------------
 sys/arch/i386/include/gdt.h |   4 +--
 3 files changed, 35 insertions(+), 41 deletions(-)

diffs (222 lines):

diff -r 62ed3e056801 -r ae66b9da1f22 sys/arch/amd64/amd64/gdt.c
--- a/sys/arch/amd64/amd64/gdt.c        Sat Aug 20 15:50:50 2016 +0000
+++ b/sys/arch/amd64/amd64/gdt.c        Sat Aug 20 16:05:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.26 2015/11/22 13:41:24 maxv Exp $    */
+/*     $NetBSD: gdt.c,v 1.27 2016/08/20 16:05:48 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.26 2015/11/22 13:41:24 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.27 2016/08/20 16:05:48 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -64,9 +64,9 @@
 int gdt_free;          /* next free slot; terminated with GNULL_SEL */
 
 void gdt_init(void);
-void gdt_grow(void);
-int gdt_get_slot(void);
-void gdt_put_slot(int);
+static void gdt_grow(void);
+static int gdt_get_slot(void);
+static void gdt_put_slot(int);
 
 void
 update_descriptor(void *tp, void *ep)
@@ -88,8 +88,7 @@
 }
 
 void
-set_sys_gdt(int slot, void *base, size_t limit,
-           int type, int dpl, int gran)
+set_sys_gdt(int slot, void *base, size_t limit, int type, int dpl, int gran)
 {
        union {
                struct sys_segment_descriptor sd;
@@ -208,11 +207,10 @@
 }
 #endif
 
-
 /*
  * Grow or shrink the GDT.
  */
-void
+static void
 gdt_grow(void)
 {
        size_t old_len, new_len;
@@ -223,7 +221,7 @@
        gdt_size <<= 1;
        new_len = old_len << 1;
        gdt_dynavail =
-           (gdt_size - DYNSEL_START) / sizeof (struct sys_segment_descriptor);
+           (gdt_size - DYNSEL_START) / sizeof(struct sys_segment_descriptor);
 
        for (va = (vaddr_t)gdtstore + old_len; va < (vaddr_t)gdtstore + new_len;
            va += PAGE_SIZE) {
@@ -245,7 +243,7 @@
  * 3) As a last resort, we increase the size of the GDT, and sweep through
  *    the new slots.
  */
-int
+static int
 gdt_get_slot(void)
 {
        int slot;
@@ -280,7 +278,7 @@
 /*
  * Deallocate a GDT slot, putting it on the free list.
  */
-void
+static void
 gdt_put_slot(int slot)
 {
        struct sys_segment_descriptor *gdt;
diff -r 62ed3e056801 -r ae66b9da1f22 sys/arch/i386/i386/gdt.c
--- a/sys/arch/i386/i386/gdt.c  Sat Aug 20 15:50:50 2016 +0000
+++ b/sys/arch/i386/i386/gdt.c  Sat Aug 20 16:05:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.c,v 1.53 2012/02/24 08:06:07 cherry Exp $  */
+/*     $NetBSD: gdt.c,v 1.54 2016/08/20 16:05:48 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.53 2012/02/24 08:06:07 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gdt.c,v 1.54 2016/08/20 16:05:48 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -61,9 +61,9 @@
 static int ldt_max = 1000;/* max number of LDTs */
 
 void gdt_init(void);
-void gdt_grow(int);
-int gdt_get_slot1(int);
-void gdt_put_slot1(int, int);
+static void gdt_grow(int);
+static int gdt_get_slot1(int);
+static void gdt_put_slot1(int, int);
 
 void
 update_descriptor(union descriptor *table, union descriptor *entry)
@@ -82,8 +82,8 @@
 }
 
 void
-setgdt(int sel, const void *base, size_t limit,
-    int type, int dpl, int def32, int gran)
+setgdt(int sel, const void *base, size_t limit, int type, int dpl, int def32,
+    int gran)
 {
        struct segment_descriptor *sd = &gdt[sel].sd;
        CPU_INFO_ITERATOR cii;
@@ -201,23 +201,21 @@
        pt_entry_t *ptp;
        int f;
 
-       for (va = (vaddr_t)ci->ci_gdt, f = 0;
-            va < (vaddr_t)ci->ci_gdt + len;
-            va += PAGE_SIZE, f++) {
+       for (va = (vaddr_t)ci->ci_gdt, f = 0; va < (vaddr_t)ci->ci_gdt + len;
+           va += PAGE_SIZE, f++) {
                KASSERT(va >= VM_MIN_KERNEL_ADDRESS);
                ptp = kvtopte(va);
                frames[f] = *ptp >> PAGE_SHIFT;
-               { 
-                  /* 
-                   * pmap_pte_clearbits(ptp, PG_RW);
-                   * but without spl(), since %fs is not setup
-                   * properly yet, ie; curcpu() won't work at this
-                   * point and spl() will break.
-                   */
-                       if (HYPERVISOR_update_va_mapping((vaddr_t)va,
-                               *ptp & ~PG_RW, UVMF_INVLPG) < 0) {
-                               panic("%s page RO update failed.\n", __func__);
-                       }
+
+               /* 
+                * pmap_pte_clearbits(ptp, PG_RW);
+                * but without spl(), since %fs is not setup
+                * properly yet, ie; curcpu() won't work at this
+                * point and spl() will break.
+                */
+               if (HYPERVISOR_update_va_mapping((vaddr_t)va,
+                       *ptp & ~PG_RW, UVMF_INVLPG) < 0) {
+                       panic("%s page RO update failed.\n", __func__);
                }
        }
 
@@ -274,7 +272,7 @@
                                        uvm_wait("gdt_grow");
                                }
                                pmap_kenter_pa(va, VM_PAGE_TO_PHYS(pg),
-                                              VM_PROT_READ | VM_PROT_WRITE, 0);
+                                   VM_PROT_READ | VM_PROT_WRITE, 0);
                        }
                }
                return;
@@ -306,7 +304,7 @@
  *    the new slots.
  */
 
-int
+static int
 gdt_get_slot(void)
 {
 
@@ -315,7 +313,7 @@
        return gdt_get_slot1(0);
 }
 
-int
+static int
 gdt_get_slot1(int which)
 {
        int slot;
@@ -345,7 +343,7 @@
 /*
  * Deallocate a GDT slot, putting it on the free list.
  */
-void
+static void
 gdt_put_slot(int slot)
 {
 
@@ -354,7 +352,7 @@
        gdt_put_slot1(slot, 0);
 }
 
-void
+static void
 gdt_put_slot1(int slot, int which)
 {
        union descriptor d;
diff -r 62ed3e056801 -r ae66b9da1f22 sys/arch/i386/include/gdt.h
--- a/sys/arch/i386/include/gdt.h       Sat Aug 20 15:50:50 2016 +0000
+++ b/sys/arch/i386/include/gdt.h       Sat Aug 20 16:05:48 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gdt.h,v 1.13 2008/04/28 20:23:24 martin Exp $  */
+/*     $NetBSD: gdt.h,v 1.14 2016/08/20 16:05:48 maxv Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -37,8 +37,6 @@
 void gdt_init(void);
 void gdt_init_cpu(struct cpu_info *);
 void gdt_reload_cpu(struct cpu_info *);
-int gdt_get_slot(void);
-void gdt_put_slot(int);
 void gdt_alloc_cpu(struct cpu_info *);
 int tss_alloc(const struct i386tss *);
 void tss_free(int);



Home | Main Index | Thread Index | Old Index