Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Drop PG_RO, PG_KR and PG_PROT, they are useless and...



details:   https://anonhg.NetBSD.org/src/rev/d8e8c6d9d254
branches:  trunk
changeset: 997423:d8e8c6d9d254
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Mar 07 13:26:24 2019 +0000

description:
Drop PG_RO, PG_KR and PG_PROT, they are useless and create confusion.

diffstat:

 sys/arch/amd64/amd64/locore.S         |   6 +++---
 sys/arch/amd64/include/pte.h          |   5 +----
 sys/arch/amd64/stand/prekern/locore.S |   8 ++++----
 sys/arch/amd64/stand/prekern/mm.c     |   6 +++---
 sys/arch/i386/i386/genassym.cf        |   3 +--
 sys/arch/i386/i386/locore.S           |   8 ++++----
 sys/arch/i386/i386/machdep.c          |   6 +++---
 sys/arch/i386/include/pte.h           |   5 +----
 sys/arch/x86/x86/db_memrw.c           |   6 ++----
 sys/arch/x86/x86/pmap.c               |  14 +++++++-------
 sys/arch/xen/x86/x86_xpmap.c          |  17 ++++++++---------
 sys/arch/xen/x86/xen_pmap.c           |   6 +++---
 12 files changed, 40 insertions(+), 50 deletions(-)

diffs (truncated from 386 to 300 lines):

diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.178 2019/02/14 08:18:25 cherry Exp $      */
+/*     $NetBSD: locore.S,v 1.179 2019/03/07 13:26:24 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -680,7 +680,7 @@
        movl    $RELOC(__rodata_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt
 
        /* Map the kernel rodata R. */
@@ -688,7 +688,7 @@
        movl    $RELOC(__data_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt_nox
 
        /* Map the kernel data+bss RW. */
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/amd64/include/pte.h
--- a/sys/arch/amd64/include/pte.h      Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/amd64/include/pte.h      Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pte.h,v 1.9 2016/05/13 11:17:20 maxv Exp $     */
+/*     $NetBSD: pte.h,v 1.10 2019/03/07 13:26:24 maxv Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -98,10 +98,8 @@
  * PDE/PTE bits. These are no different from their i386 counterparts.
  */
 #define PG_V           0x0000000000000001      /* valid */
-#define PG_RO          0x0000000000000000      /* read-only */
 #define PG_RW          0x0000000000000002      /* read-write */
 #define PG_u           0x0000000000000004      /* user accessible */
-#define PG_PROT                0x0000000000000006
 #define PG_WT          0x0000000000000008      /* write-through */
 #define PG_N           0x0000000000000010      /* non-cacheable */
 #define PG_U           0x0000000000000020      /* used */
@@ -123,7 +121,6 @@
 /*
  * Short forms of protection codes.
  */
-#define PG_KR          0x0000000000000000      /* kernel read-only */
 #define PG_KW          0x0000000000000002      /* kernel read-write */
 
 #include <x86/pte.h>
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/amd64/stand/prekern/locore.S
--- a/sys/arch/amd64/stand/prekern/locore.S     Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/amd64/stand/prekern/locore.S     Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.8 2018/05/25 16:01:31 maxv Exp $  */
+/*     $NetBSD: locore.S,v 1.9 2019/03/07 13:26:24 maxv Exp $  */
 
 /*
  * Copyright (c) 1998, 2000, 2007, 2008, 2016, 2017 The NetBSD Foundation, Inc.
@@ -424,7 +424,7 @@
        movl    $_C_LABEL(__rodata_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt
 
        /* Map the prekern rodata R. */
@@ -432,7 +432,7 @@
        movl    $_C_LABEL(__data_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt_nox
 
        /* Map the prekern data+bss RW. */
@@ -448,7 +448,7 @@
        movl    %esi,%ecx               /* start of BOOTSTRAP TABLES */
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt_nox
 
        /* Map the BOOTSTRAP TABLES RW. */
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/amd64/stand/prekern/mm.c
--- a/sys/arch/amd64/stand/prekern/mm.c Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/amd64/stand/prekern/mm.c Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mm.c,v 1.22 2018/06/20 11:49:37 maxv Exp $     */
+/*     $NetBSD: mm.c,v 1.23 2019/03/07 13:26:24 maxv Exp $     */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -44,9 +44,9 @@
 #define MM_PROT_EXECUTE        0x02
 
 static const pt_entry_t protection_codes[3] = {
-       [MM_PROT_READ] = PG_RO | PG_NX,
+       [MM_PROT_READ] = PG_NX,
        [MM_PROT_WRITE] = PG_RW | PG_NX,
-       [MM_PROT_EXECUTE] = PG_RO,
+       [MM_PROT_EXECUTE] = 0,
        /* RWX does not exist */
 };
 
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf    Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/i386/i386/genassym.cf    Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.111 2019/02/15 08:54:01 nonaka Exp $
+#      $NetBSD: genassym.cf,v 1.112 2019/03/07 13:26:24 maxv Exp $
 
 #
 # Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -144,7 +144,6 @@
 define PG_RW                   PG_RW
 define PG_V                    PG_V
 define PG_KW                   PG_KW
-define PG_KR                   PG_KR
 define PGEX_U                  PGEX_U
 
 define L2_SLOT_KERNBASE        pl2_pi(KERNBASE)
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/i386/i386/locore.S       Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.164 2019/02/13 05:36:59 cherry Exp $      */
+/*     $NetBSD: locore.S,v 1.165 2019/03/07 13:26:24 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.164 2019/02/13 05:36:59 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.165 2019/03/07 13:26:24 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -693,7 +693,7 @@
        movl    $RELOC(__rodata_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt
 
        /* Map the kernel rodata R. */
@@ -701,7 +701,7 @@
        movl    $RELOC(__data_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
-       orl     $(PG_V|PG_KR),%eax
+       orl     $(PG_V),%eax
        fillkpt_nox
 
        /* Map the kernel data+bss RW. */
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/i386/i386/machdep.c      Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.816 2019/02/14 08:18:25 cherry Exp $     */
+/*     $NetBSD: machdep.c,v 1.817 2019/03/07 13:26:24 maxv Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.816 2019/02/14 08:18:25 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.817 2019/03/07 13:26:24 maxv Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -1029,7 +1029,7 @@
                pt_entry_t pte;
 
                pte = pmap_pa2pte((vaddr_t)gdtstore - KERNBASE);
-               pte |= PG_RO | xpmap_pg_nx | PG_V;
+               pte |= xpmap_pg_nx | PG_V;
 
                if (HYPERVISOR_update_va_mapping((vaddr_t)gdtstore, pte,
                    UVMF_INVLPG) < 0) {
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/i386/include/pte.h
--- a/sys/arch/i386/include/pte.h       Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/i386/include/pte.h       Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pte.h,v 1.28 2019/03/07 13:02:13 maxv Exp $    */
+/*     $NetBSD: pte.h,v 1.29 2019/03/07 13:26:24 maxv Exp $    */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -148,10 +148,8 @@
  * XXXCDC: need to rename these (PG_u == ugly).
  */
 #define PG_V           0x00000001      /* valid entry */
-#define PG_RO          0x00000000      /* read-only page */
 #define PG_RW          0x00000002      /* read-write page */
 #define PG_u           0x00000004      /* user accessible page */
-#define PG_PROT                0x00000806      /* all protection bits */
 #define PG_WT          0x00000008      /* write through */
 #define PG_N           0x00000010      /* non-cacheable */
 #define PG_U           0x00000020      /* has been used */
@@ -167,7 +165,6 @@
 /*
  * various short-hand protection codes
  */
-#define PG_KR          0x00000000      /* kernel read-only */
 #define PG_KW          0x00000002      /* kernel read-write */
 
 #ifdef PAE
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/x86/x86/db_memrw.c
--- a/sys/arch/x86/x86/db_memrw.c       Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/x86/x86/db_memrw.c       Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_memrw.c,v 1.8 2019/01/19 13:17:32 martin Exp $      */
+/*     $NetBSD: db_memrw.c,v 1.9 2019/03/07 13:26:24 maxv Exp $        */
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.8 2019/01/19 13:17:32 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.9 2019/03/07 13:26:24 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -170,7 +170,6 @@
                /*
                 * Make the kernel text page writable.
                 */
-               pmap_pte_clearbits(ppte, PG_KR);
                pmap_pte_setbits(ppte, PG_KW);
                pmap_update_pg(addr);
 
@@ -190,7 +189,6 @@
                 * Turn the page back to read-only.
                 */
                pmap_pte_clearbits(ppte, PG_KW);
-               pmap_pte_setbits(ppte, PG_KR);
                pmap_update_pg(addr);
 
                /*
diff -r 466d45505c0c -r d8e8c6d9d254 sys/arch/x86/x86/pmap.c
--- a/sys/arch/x86/x86/pmap.c   Thu Mar 07 13:02:13 2019 +0000
+++ b/sys/arch/x86/x86/pmap.c   Thu Mar 07 13:26:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.327 2019/02/23 10:59:12 maxv Exp $  */
+/*     $NetBSD: pmap.c,v 1.328 2019/03/07 13:26:24 maxv Exp $  */
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.327 2019/02/23 10:59:12 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.328 2019/03/07 13:26:24 maxv Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -1068,9 +1068,9 @@
         * into a x86 PTE.
         */
        protection_codes[VM_PROT_NONE] = pmap_pg_nx;
-       protection_codes[VM_PROT_EXECUTE] = PG_RO | PG_X;
-       protection_codes[VM_PROT_READ] = PG_RO | pmap_pg_nx;
-       protection_codes[VM_PROT_READ|VM_PROT_EXECUTE] = PG_RO | PG_X;
+       protection_codes[VM_PROT_EXECUTE] = PG_X;
+       protection_codes[VM_PROT_READ] = pmap_pg_nx;
+       protection_codes[VM_PROT_READ|VM_PROT_EXECUTE] = PG_X;
        protection_codes[VM_PROT_WRITE] = PG_RW | pmap_pg_nx;
        protection_codes[VM_PROT_WRITE|VM_PROT_EXECUTE] = PG_RW | PG_X;
        protection_codes[VM_PROT_WRITE|VM_PROT_READ] = PG_RW | pmap_pg_nx;
@@ -1660,7 +1660,7 @@
                pa = roundup(bootspace.segs[i].pa, NBPD_L2);
                for (/* */; kva < kva_end; kva += NBPD_L2, pa += NBPD_L2) {
                        pde = &L2_BASE[pl2_i(kva)];
-                       *pde = pa | pmap_pg_g | PG_PS | PG_KR | PG_V;
+                       *pde = pa | pmap_pg_g | PG_PS | PG_V;
                        tlbflushg();
                }
        }
@@ -1679,7 +1679,7 @@
                pa = roundup(bootspace.segs[i].pa, NBPD_L2);
                for (/* */; kva < kva_end; kva += NBPD_L2, pa += NBPD_L2) {
                        pde = &L2_BASE[pl2_i(kva)];
-                       *pde = pa | pmap_pg_g | PG_PS | pmap_pg_nx | PG_KR | PG_V;
+                       *pde = pa | pmap_pg_g | PG_PS | pmap_pg_nx | PG_V;



Home | Main Index | Thread Index | Old Index