Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbarm/fdt In fdt_add_boot_physmem make sure the me...



details:   https://anonhg.NetBSD.org/src/rev/651d0eb0bb22
branches:  trunk
changeset: 456112:651d0eb0bb22
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Apr 24 06:37:31 2019 +0000

description:
In fdt_add_boot_physmem make sure the memory range has pages available
before adding it to the fdt_physmem array.

Fixes a problem that jmcneill@ pointed out to me.

diffstat:

 sys/arch/evbarm/fdt/fdt_machdep.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r b92f63ab4a75 -r 651d0eb0bb22 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Wed Apr 24 06:03:02 2019 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Wed Apr 24 06:37:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.61 2019/03/30 13:17:23 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.62 2019/04/24 06:37:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.61 2019/03/30 13:17:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.62 2019/04/24 06:37:31 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -251,14 +251,22 @@
 static void
 fdt_add_boot_physmem(const struct fdt_memory *m, void *arg)
 {
-       struct boot_physmem *bp = &fdt_physmem[nfdt_physmem++];
+       const paddr_t saddr = round_page(m->start);
+       const paddr_t eaddr = trunc_page(m->end);
 
-       VPRINTF("  %" PRIx64 " - %" PRIx64 "\n", m->start, m->end - 1);
+       VPRINTF("  %" PRIx64 " - %" PRIx64, m->start, m->end - 1);
+       if (saddr >= eaddr) {
+               VPRINTF(" skipped\n");
+               return;
+       }
+       VPRINTF("\n");
+
+       struct boot_physmem *bp = &fdt_physmem[nfdt_physmem++];
 
        KASSERT(nfdt_physmem <= MAX_PHYSMEM);
 
-       bp->bp_start = atop(round_page(m->start));
-       bp->bp_pages = atop(trunc_page(m->end)) - bp->bp_start;
+       bp->bp_start = atop(saddr);
+       bp->bp_pages = atop(eaddr) - bp->bp_start;
        bp->bp_freelist = VM_FREELIST_DEFAULT;
 
 #ifdef _LP64



Home | Main Index | Thread Index | Old Index