Module Name:    src
Committed By:   riz
Date:           Sat May 19 16:37:14 UTC 2012

Modified Files:
        src/sys/arch/amd64/amd64 [netbsd-5]: db_memrw.c
        src/sys/arch/i386/i386 [netbsd-5]: db_memrw.c

Log Message:
Pull up following revision(s) (requested by jym in ticket #1754):
        sys/arch/amd64/amd64/db_memrw.c: revision 1.10
        sys/arch/amd64/amd64/db_memrw.c: revision 1.11
        sys/arch/i386/i386/db_memrw.c: revision 1.29
Use the current destination address to compute PTE, not the address of
origin.
Harmless, except when db_write_text() passes a page boundary.
 From Bug Hunting.
XXX has to be pulled up to -5 and -6.
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.6 -r1.6.10.1 src/sys/arch/amd64/amd64/db_memrw.c
cvs rdiff -u -r1.24.10.1 -r1.24.10.2 src/sys/arch/i386/i386/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.6 src/sys/arch/amd64/amd64/db_memrw.c:1.6.10.1
--- src/sys/arch/amd64/amd64/db_memrw.c:1.6	Mon Apr 28 20:23:12 2008
+++ src/sys/arch/amd64/amd64/db_memrw.c	Sat May 19 16:37:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.6 2008/04/28 20:23:12 martin Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.6.10.1 2012/05/19 16:37:14 riz 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.6 2008/04/28 20:23:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.6.10.1 2012/05/19 16:37:14 riz Exp $");
 
 #include "opt_xen.h"
 
@@ -115,7 +115,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
+		pte = kvtopte((vaddr_t)dst);
 		oldpte = *pte;
 
 		if ((oldpte & PG_V) == 0) {
@@ -127,7 +127,7 @@ db_write_text(vaddr_t addr, size_t size,
 		 * Get the VA for the page.
 		 */
 		if (oldpte & PG_PS)
-			pgva = (vaddr_t)dst & PG_LGFRAME;
+			pgva = VA_SIGN_NEG((vaddr_t)dst & PG_LGFRAME);
 		else
 			pgva = x86_trunc_page(dst);
 

Index: src/sys/arch/i386/i386/db_memrw.c
diff -u src/sys/arch/i386/i386/db_memrw.c:1.24.10.1 src/sys/arch/i386/i386/db_memrw.c:1.24.10.2
--- src/sys/arch/i386/i386/db_memrw.c:1.24.10.1	Wed Sep 30 00:08:03 2009
+++ src/sys/arch/i386/i386/db_memrw.c	Sat May 19 16:37:14 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_memrw.c,v 1.24.10.1 2009/09/30 00:08:03 snj Exp $	*/
+/*	$NetBSD: db_memrw.c,v 1.24.10.2 2012/05/19 16:37:14 riz Exp $	*/
 
 /*-
  * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.24.10.1 2009/09/30 00:08:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.24.10.2 2012/05/19 16:37:14 riz Exp $");
 
 #include "opt_xen.h"
 
@@ -111,7 +111,7 @@ db_write_text(vaddr_t addr, size_t size,
 		/*
 		 * Get the PTE for the page.
 		 */
-		pte = kvtopte(addr);
+		pte = kvtopte((vaddr_t)dst);
 		oldpte = *pte;
 
 		if ((oldpte & PG_V) == 0) {

Reply via email to