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 Define fillkpt_nox, which sets up a set...



details:   https://anonhg.NetBSD.org/src/rev/17984b6dc804
branches:  trunk
changeset: 345195:17984b6dc804
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu May 12 07:51:09 2016 +0000

description:
Define fillkpt_nox, which sets up a set of pages and puts the NOX bit on
them by using nox_flag. Use fillkpt_nox to map the rodata segment
without X permissions.

diffstat:

 sys/arch/amd64/amd64/locore.S |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r cd93ab7aa4a4 -r 17984b6dc804 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Thu May 12 07:21:18 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Thu May 12 07:51:09 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.88 2016/05/12 07:21:18 maxv Exp $ */
+/*     $NetBSD: locore.S,v 1.89 2016/05/12 07:51:09 maxv Exp $ */
 
 /*
  * Copyright-o-rama!
@@ -227,6 +227,19 @@
        loop    1b                      ;
 
 /*
+ * fillkpt_nox - Same as fillkpt, but sets the NX/XD bit.
+ */
+#define fillkpt_nox \
+       pushl   %ebp                    ;       \
+       movl    RELOC(nox_flag),%ebp    ;       \
+1:     movl    %eax,(%ebx)             ;       /* store phys addr */   \
+       movl    %ebp,(PDE_SIZE-4)(%ebx) ;       /* upper 32 bits: NX */ \
+       addl    $PDE_SIZE,%ebx          ;       /* next PTE/PDE */      \
+       addl    $PAGE_SIZE,%eax         ;       /* next phys page */    \
+       loop    1b                      ;       \
+       popl    %ebp                    ;
+
+/*
  * killkpt - Destroy a kernel page table (long mode)
  *     rbx = page table address
  *     rcx = number of pages to destroy
@@ -625,13 +638,13 @@
        orl     $(PG_V|PG_KR),%eax
        fillkpt
 
-       /* Map the kernel rodata ROX. */
+       /* Map the kernel rodata RO. */
        movl    $RELOC(__rodata_start),%eax
        movl    $RELOC(__data_start),%ecx
        subl    %eax,%ecx
        shrl    $PGSHIFT,%ecx
        orl     $(PG_V|PG_KR),%eax
-       fillkpt
+       fillkpt_nox
 
        /*
         * We actually have to be careful here. The memory layout is as



Home | Main Index | Thread Index | Old Index