Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mips/mips Fix mm_md_kernacc() for 64 bit kernels (i...



details:   https://anonhg.NetBSD.org/src/rev/173b490c5862
branches:  trunk
changeset: 935272:173b490c5862
user:      simonb <simonb%NetBSD.org@localhost>
date:      Sun Jun 28 13:33:06 2020 +0000

description:
Fix mm_md_kernacc() for 64 bit kernels (including n32):
 - FAULT for any physical address less than start of cached XKPHY address.
 - Pass any remaining physical address less then end of RAM.
 - Pass any remaining physical address within the KEGS0 kernel address range.
Ignore all remaining addresses and fall back to uvm_kernacc() for checking
virtual address ranges.

Fixes pmap(1) (and probably other kmem grovellers).

diffstat:

 sys/arch/mips/mips/mips_machdep.c |  27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diffs (55 lines):

diff -r ac26f21591dc -r 173b490c5862 sys/arch/mips/mips/mips_machdep.c
--- a/sys/arch/mips/mips/mips_machdep.c Sun Jun 28 12:43:00 2020 +0000
+++ b/sys/arch/mips/mips/mips_machdep.c Sun Jun 28 13:33:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mips_machdep.c,v 1.293 2020/06/15 07:55:45 simonb Exp $        */
+/*     $NetBSD: mips_machdep.c,v 1.294 2020/06/28 13:33:06 simonb Exp $        */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.293 2020/06/15 07:55:45 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.294 2020/06/28 13:33:06 simonb Exp $");
 
 #define __INTR_PRIVATE
 #include "opt_cputype.h"
@@ -2481,21 +2481,28 @@
        const vaddr_t v = (vaddr_t)ptr;
 
 #ifdef _LP64
-       if (v < MIPS_XKPHYS_START) {
+       extern char end[];
+
+       /* For any address < XKPHYS cached address 0, fault */
+       if (v < MIPS_PHYS_TO_XKPHYS_CACHED(0)) {
                return EFAULT;
        }
-       if (MIPS_XKPHYS_P(v) && v > MIPS_PHYS_TO_XKPHYS_CACHED(pmap_limits.avail_end +
+
+       /* If address < XKPHY(end of message buffer), good! */
+       if (v < MIPS_PHYS_TO_XKPHYS_CACHED(pmap_limits.avail_end +
            mips_round_page(MSGBUFSIZE))) {
-               return EFAULT;
-       }
-       if (MIPS_KSEG0_P(v) ||
-           (MIPS_XKSEG_P(v) && v < MIPS_KSEG0_START)) {
+               /* XXX holes in RAM (eg, EdgeRouter 4) */
                *handled = true;
                return 0;
        }
-       if (MIPS_KSEG1_P(v) || MIPS_KSEG2_P(v)) {
-               return EFAULT;
+
+       /* If address in KSEG0 and is before end of kernel, good! */
+       if (MIPS_KSEG0_P(v) && v < (vaddr_t)end) {
+               *handled = true;
+               return 0;
        }
+
+       /* Otherwise, fall back to the uvm_kernacc() check. */
 #else
        if (v < MIPS_KSEG0_START) {
                return EFAULT;



Home | Main Index | Thread Index | Old Index