Module Name:    src
Committed By:   maxv
Date:           Sat Jul  9 06:58:06 UTC 2016

Modified Files:
        src/sys/arch/amd64/amd64: locore.S
        src/sys/arch/i386/i386: locore.S

Log Message:
The CPU considers a given va as executable if none of its levels have
the NOX bit. With the top level recursive slot, however, several levels
are recursively omitted, which implies that each entry that is not the
child of NOX-ed parents actually appears somewhere in the virtual space
as executable via this slot, even if it is followed by an underlying
entry that has the NOX bit.

This recursive slot is only used to edit the page tree itself. Make it
non-executable.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/arch/amd64/amd64/locore.S
cvs rdiff -u -r1.134 -r1.135 src/sys/arch/i386/i386/locore.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amd64/amd64/locore.S
diff -u src/sys/arch/amd64/amd64/locore.S:1.105 src/sys/arch/amd64/amd64/locore.S:1.106
--- src/sys/arch/amd64/amd64/locore.S:1.105	Fri Jul  8 09:15:38 2016
+++ src/sys/arch/amd64/amd64/locore.S	Sat Jul  9 06:58:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.105 2016/07/08 09:15:38 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.106 2016/07/09 06:58:06 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -777,12 +777,12 @@ no_NOX:
 	movl	$NKL4_KIMG_ENTRIES,%ecx
 	fillkpt
 
-	/* Install recursive top level PDE */
+	/* Install recursive top level PDE (one entry) */
 	leal	(PROC0_PML4_OFF + PDIR_SLOT_PTE * PDE_SIZE)(%esi),%ebx
 	leal	(PROC0_PML4_OFF)(%esi),%eax
 	orl	$(PG_V|PG_KW),%eax
-	movl	%eax,(%ebx)
-	movl	$0,(PDE_SIZE-4)(%ebx)
+	movl	$1,%ecx
+	fillkpt_nox
 
 	/*
 	 * Startup checklist:

Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.134 src/sys/arch/i386/i386/locore.S:1.135
--- src/sys/arch/i386/i386/locore.S:1.134	Fri Jul  8 09:15:38 2016
+++ src/sys/arch/i386/i386/locore.S	Sat Jul  9 06:58:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.134 2016/07/08 09:15:38 maxv Exp $	*/
+/*	$NetBSD: locore.S,v 1.135 2016/07/09 06:58:06 maxv Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.134 2016/07/08 09:15:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.135 2016/07/09 06:58:06 maxv Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -776,12 +776,12 @@ no_NOX:
 	movl	RELOC(nkptp)+1*4,%ecx
 	fillkpt
 
-	/* Install a PDE recursively mapping page directory as a page table! */
+	/* Install recursive top level PDE */
 	leal	(PROC0_PDIR_OFF + PDIR_SLOT_PTE * PDE_SIZE)(%esi),%ebx
 	leal	(PROC0_PDIR_OFF)(%esi),%eax
 	orl	$(PG_V|PG_KW),%eax
 	movl	$PDP_SIZE,%ecx
-	fillkpt
+	fillkpt_nox
 
 #ifdef PAE
 	/*

Reply via email to