Module Name:    src
Committed By:   jym
Date:           Mon May  7 12:20:27 UTC 2012

Modified Files:
        src/sys/arch/amd64/amd64: db_memrw.c

Log Message:
invlpg on a non canonical address is a noop, so no chance to invalidate
the TLB and the CPU will not notice the access right change.

This results in write protection faults in supervisor mode when patching
kernel code through ddb(4) (originally mapped as read only).

Bug reported by David Laight on port-amd64@ (thanks!), patch and test by
me.

i386 is unaffected as PG_LGFRAME does not mask the sign bits. For the
sake of correctness, use VA_SIGN_NEG(...) anyway.

XXX this is the patch that will be pulled-up to -5 and -6.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amd64/amd64/db_memrw.c

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/db_memrw.c
diff -u src/sys/arch/amd64/amd64/db_memrw.c:1.10 src/sys/arch/amd64/amd64/db_memrw.c:1.11
--- src/sys/arch/amd64/amd64/db_memrw.c:1.10	Mon May  7 12:12:04 2012
+++ src/sys/arch/amd64/amd64/db_memrw.c	Mon May  7 12:20:27 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.11 2012/05/07 12:20:27 jym Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.10 2012/05/07 12:12:04 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.11 2012/05/07 12:20:27 jym Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -123,7 +123,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (pte & PG_PS)
-			pgva = (vaddr_t)dst & PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst & PG_LGFRAME);
 		else
 			pgva = x86_trunc_page(dst);
 

Reply via email to