From 0932d38536828dd305e30d446b6cfa02e763a14d Mon Sep 17 00:00:00 2001 From: claudio Date: Mon, 4 Dec 2023 15:00:09 +0000 Subject: [PATCH] Account for nkmempages as well in the pmap_growkernel() call during initalisation. This way there is enough KVA mapped that kmeminit() succeeds even with large nkmempages. This is similar to e.g. alpha. OK miod@ kettenis@ --- sys/arch/arm64/arm64/machdep.c | 8 +++++--- sys/arch/riscv64/riscv64/machdep.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index d0c1601139f..69dc76ae9d2 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.84 2023/08/10 21:01:50 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.85 2023/12/04 15:00:09 claudio Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -1067,13 +1067,15 @@ initarm(struct arm64_bootparams *abp) physmem += atop(end - start); } + kmeminit_nkmempages(); + /* * Make sure that we have enough KVA to initialize UVM. In * particular, we need enough KVA to be able to allocate the - * vm_page structures. + * vm_page structures and nkmempages for malloc(9). */ pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 1024 * 1024 * 1024 + - physmem * sizeof(struct vm_page)); + physmem * sizeof(struct vm_page) + ptoa(nkmempages)); #ifdef DDB db_machine_init(); diff --git a/sys/arch/riscv64/riscv64/machdep.c b/sys/arch/riscv64/riscv64/machdep.c index b6843711864..eb7778d9e08 100644 --- a/sys/arch/riscv64/riscv64/machdep.c +++ b/sys/arch/riscv64/riscv64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.32 2023/08/14 13:49:42 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.33 2023/12/04 15:00:09 claudio Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -813,13 +813,15 @@ initriscv(struct riscv_bootparams *rbp) atop(start), atop(end), 0); } + kmeminit_nkmempages(); + /* * Make sure that we have enough KVA to initialize UVM. In * particular, we need enough KVA to be able to allocate the - * vm_page structures. + * vm_page structures and nkmempages for malloc(9). */ pmap_growkernel(VM_MIN_KERNEL_ADDRESS + 1024 * 1024 * 1024 + - physmem * sizeof(struct vm_page)); + physmem * sizeof(struct vm_page) + ptoa(nkmempages)); #ifdef DDB db_machine_init(); -- 2.20.1