Module Name:    src
Committed By:   maxv
Date:           Thu May 12 07:51:10 UTC 2016

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

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/arch/amd64/amd64/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.88 src/sys/arch/amd64/amd64/locore.S:1.89
--- src/sys/arch/amd64/amd64/locore.S:1.88	Thu May 12 07:21:18 2016
+++ src/sys/arch/amd64/amd64/locore.S	Thu May 12 07:51:09 2016
@@ -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 @@ no_NOX:
 	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

Reply via email to