Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64/stand/prekern Oh, damn. Obviously I forgot on...
details: https://anonhg.NetBSD.org/src/rev/7aeb3925d4c1
branches: trunk
changeset: 357768:7aeb3925d4c1
user: maxv <maxv%NetBSD.org@localhost>
date: Sun Nov 26 14:29:48 2017 +0000
description:
Oh, damn. Obviously I forgot one case here: an already-mapped region could
be contained entirely in the region we're trying to create. So go through
another round. While here add mm_reenter_pa, and make sure the va given to
mm_enter_pa does not already point to something.
diffstat:
sys/arch/amd64/stand/prekern/mm.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diffs (54 lines):
diff -r 68bfd28cdfef -r 7aeb3925d4c1 sys/arch/amd64/stand/prekern/mm.c
--- a/sys/arch/amd64/stand/prekern/mm.c Sun Nov 26 12:48:44 2017 +0000
+++ b/sys/arch/amd64/stand/prekern/mm.c Sun Nov 26 14:29:48 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mm.c,v 1.19 2017/11/26 11:01:09 maxv Exp $ */
+/* $NetBSD: mm.c,v 1.20 2017/11/26 14:29:48 maxv Exp $ */
/*
* Copyright (c) 2017 The NetBSD Foundation, Inc. All rights reserved.
@@ -71,6 +71,15 @@
static void
mm_enter_pa(paddr_t pa, vaddr_t va, pte_prot_t prot)
{
+ if (PTE_BASE[pl1_i(va)] & PG_V) {
+ fatal("mm_enter_pa: mapping already present");
+ }
+ PTE_BASE[pl1_i(va)] = pa | PG_V | protection_codes[prot];
+}
+
+static void
+mm_reenter_pa(paddr_t pa, vaddr_t va, pte_prot_t prot)
+{
PTE_BASE[pl1_i(va)] = pa | PG_V | protection_codes[prot];
}
@@ -92,7 +101,7 @@
/* Zero them out */
for (i = 0; i < npages; i++) {
- mm_enter_pa(pa + i * PAGE_SIZE, tmpva,
+ mm_reenter_pa(pa + i * PAGE_SIZE, tmpva,
MM_PROT_READ|MM_PROT_WRITE);
mm_flush_va(tmpva);
memset((void *)tmpva, 0, PAGE_SIZE);
@@ -120,7 +129,7 @@
for (i = 0; i < npages; i++) {
va = startva + i * PAGE_SIZE;
pa = (PTE_BASE[pl1_i(va)] & PG_FRAME);
- mm_enter_pa(pa, va, prot);
+ mm_reenter_pa(pa, va, prot);
mm_flush_va(va);
}
}
@@ -227,6 +236,10 @@
ok = false;
break;
}
+ if (randva < sva && eva < (randva + size)) {
+ ok = false;
+ break;
+ }
}
if (ok) {
break;
Home |
Main Index |
Thread Index |
Old Index