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 Make cpu_uarea_{alloc, free} conditional o...
details: https://anonhg.NetBSD.org/src/rev/6cc38b1bdc3d
branches: trunk
changeset: 353533:6cc38b1bdc3d
user: skrll <skrll%NetBSD.org@localhost>
date: Wed May 10 22:19:31 2017 +0000
description:
Make cpu_uarea_{alloc,free} conditional on PMAP_{,UN}MAP_POOLPAGE and
use PMAP_{,UN}_POOLPAGE to ensure cache aliases are handled correctly
and for all the pages used.
diffstat:
sys/arch/mips/mips/vm_machdep.c | 47 ++++++++++++++++++++++++++--------------
1 files changed, 30 insertions(+), 17 deletions(-)
diffs (97 lines):
diff -r dd7a218f0728 -r 6cc38b1bdc3d sys/arch/mips/mips/vm_machdep.c
--- a/sys/arch/mips/mips/vm_machdep.c Wed May 10 16:35:18 2017 +0000
+++ b/sys/arch/mips/mips/vm_machdep.c Wed May 10 22:19:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.155 2017/05/10 12:12:21 skrll Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.156 2017/05/10 22:19:31 skrll Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.155 2017/05/10 12:12:21 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.156 2017/05/10 22:19:31 skrll Exp $");
#include "opt_ddb.h"
#include "opt_coredump.h"
@@ -172,6 +172,8 @@
void *
cpu_uarea_alloc(bool system)
{
+#ifdef PMAP_MAP_POOLPAGE
+
struct pglist pglist;
#ifdef _LP64
const paddr_t high = pmap_limits.avail_end;
@@ -212,15 +214,25 @@
pa, pmap_limits.avail_end);
/*
- * we need to return a direct-mapped VA for the pa.
+ * we need to return a direct-mapped VA for the pa of the first (maybe
+ * only) page and call PMAP_MAP_POOLPAGE on all pages in the list, so
+ * that cache aliases are handled correctly.
*/
-#ifdef _LP64
- const vaddr_t va = MIPS_PHYS_TO_XKPHYS_CACHED(pa);
-#else
- const vaddr_t va = MIPS_PHYS_TO_KSEG0(pa);
-#endif
+
+ /* Initialise to unexpected result */
+ vaddr_t va = MIPS_KSEG2_START;
+ const struct vm_page *pglv;
+ TAILQ_FOREACH_REVERSE(pglv, &pglist, pglist, pageq.queue) {
+ const paddr_t palv = VM_PAGE_TO_PHYS(pglv);
+ va = PMAP_MAP_POOLPAGE(palv);
+ }
+
+ KASSERT(va != MIPS_KSEG2_START);
return (void *)va;
+#else
+ return NULL;
+#endif
}
/*
@@ -229,27 +241,28 @@
bool
cpu_uarea_free(void *va)
{
+#ifdef PMAP_UNMAP_POOLPAGE
#ifdef _LP64
if (!MIPS_XKPHYS_P(va))
return false;
- paddr_t pa = MIPS_XKPHYS_TO_PHYS(va);
#else
if (!MIPS_KSEG0_P(va))
return false;
- paddr_t pa = MIPS_KSEG0_TO_PHYS(va);
#endif
-#ifdef MIPS3_PLUS
- if (MIPS_CACHE_VIRTUAL_ALIAS)
- mips_dcache_inv_range((intptr_t)va, USPACE);
-#endif
-
- for (const paddr_t epa = pa + USPACE; pa < epa; pa += PAGE_SIZE) {
- struct vm_page * const pg = PHYS_TO_VM_PAGE(pa);
+ vaddr_t valv = (vaddr_t)va;
+ for (size_t i = 0; i < UPAGES; i++, valv += NBPG) {
+ const paddr_t pa = PMAP_UNMAP_POOLPAGE(valv);
+ struct vm_page * const pg = PHYS_TO_VM_PAGE(pa);
KASSERT(pg != NULL);
uvm_pagefree(pg);
}
+
return true;
+#else
+ return false;
+#endif
+
}
void
Home |
Main Index |
Thread Index |
Old Index