Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/arch Pull up following revision(s) (requested by jym ...



details:   https://anonhg.NetBSD.org/src/rev/29bd59c9e56e
branches:  netbsd-6
changeset: 774078:29bd59c9e56e
user:      riz <riz%NetBSD.org@localhost>
date:      Wed May 09 15:50:38 2012 +0000

description:
Pull up following revision(s) (requested by jym in ticket #233):
        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.

diffstat:

 sys/arch/amd64/amd64/db_memrw.c |  8 ++++----
 sys/arch/i386/i386/db_memrw.c   |  6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (63 lines):

diff -r 4f1d0e7b6df2 -r 29bd59c9e56e sys/arch/amd64/amd64/db_memrw.c
--- a/sys/arch/amd64/amd64/db_memrw.c   Wed May 09 15:42:08 2012 +0000
+++ b/sys/arch/amd64/amd64/db_memrw.c   Wed May 09 15:50:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_memrw.c,v 1.9 2011/11/23 01:15:02 jym Exp $ */
+/*     $NetBSD: db_memrw.c,v 1.9.4.1 2012/05/09 15:50:38 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.9 2011/11/23 01:15:02 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.9.4.1 2012/05/09 15:50:38 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -111,7 +111,7 @@
                /*
                 * Get the PTE for the page.
                 */
-               ppte = kvtopte(addr);
+               ppte = kvtopte((vaddr_t)dst);
                pte = *ppte;
 
                if ((pte & PG_V) == 0) {
@@ -123,7 +123,7 @@
                 * 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);
 
diff -r 4f1d0e7b6df2 -r 29bd59c9e56e sys/arch/i386/i386/db_memrw.c
--- a/sys/arch/i386/i386/db_memrw.c     Wed May 09 15:42:08 2012 +0000
+++ b/sys/arch/i386/i386/db_memrw.c     Wed May 09 15:50:38 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_memrw.c,v 1.25 2009/03/10 20:05:30 bouyer Exp $     */
+/*     $NetBSD: db_memrw.c,v 1.25.18.1 2012/05/09 15:50:38 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.25 2009/03/10 20:05:30 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.25.18.1 2012/05/09 15:50:38 riz Exp $");
 
 #include "opt_xen.h"
 
@@ -111,7 +111,7 @@
                /*
                 * Get the PTE for the page.
                 */
-               pte = kvtopte(addr);
+               pte = kvtopte((vaddr_t)dst);
                oldpte = *pte;
 
                if ((oldpte & PG_V) == 0) {



Home | Main Index | Thread Index | Old Index