Fri Jun 26 08:42:27 2020 UTC ()
Avoid unbounded stack usage warning


(skrll)
diff -r1.59 -r1.60 src/sys/arch/arm/arm32/arm32_kvminit.c

cvs diff -r1.59 -r1.60 src/sys/arch/arm/arm32/arm32_kvminit.c (expand / switch to unified diff)

--- src/sys/arch/arm/arm32/arm32_kvminit.c 2020/06/20 07:10:36 1.59
+++ src/sys/arch/arm/arm32/arm32_kvminit.c 2020/06/26 08:42:27 1.60
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: arm32_kvminit.c,v 1.59 2020/06/20 07:10:36 skrll Exp $ */ 1/* $NetBSD: arm32_kvminit.c,v 1.60 2020/06/26 08:42:27 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. 4 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
5 * Written by Hiroyuki Bessho for Genetec Corporation. 5 * Written by Hiroyuki Bessho for Genetec Corporation.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -117,27 +117,27 @@ @@ -117,27 +117,27 @@
117 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 117 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
118 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 118 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
119 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 119 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
120 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 120 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
121 * SUCH DAMAGE. 121 * SUCH DAMAGE.
122 */ 122 */
123 123
124#include "opt_arm_debug.h" 124#include "opt_arm_debug.h"
125#include "opt_arm_start.h" 125#include "opt_arm_start.h"
126#include "opt_fdt.h" 126#include "opt_fdt.h"
127#include "opt_multiprocessor.h" 127#include "opt_multiprocessor.h"
128 128
129#include <sys/cdefs.h> 129#include <sys/cdefs.h>
130__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.59 2020/06/20 07:10:36 skrll Exp $"); 130__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.60 2020/06/26 08:42:27 skrll Exp $");
131 131
132#include <sys/param.h> 132#include <sys/param.h>
133 133
134#include <sys/bus.h> 134#include <sys/bus.h>
135#include <sys/device.h> 135#include <sys/device.h>
136#include <sys/kernel.h> 136#include <sys/kernel.h>
137#include <sys/reboot.h> 137#include <sys/reboot.h>
138 138
139#include <dev/cons.h> 139#include <dev/cons.h>
140 140
141#include <uvm/uvm_extern.h> 141#include <uvm/uvm_extern.h>
142 142
143#include <arm/arm32/machdep.h> 143#include <arm/arm32/machdep.h>
@@ -485,27 +485,27 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b @@ -485,27 +485,27 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b
485 */ 485 */
486 const size_t KERNEL_L2PT_KERNEL_NUM = 486 const size_t KERNEL_L2PT_KERNEL_NUM =
487 round_page(kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE; 487 round_page(kernel_size + L2_S_SEGSIZE - 1) / L2_S_SEGSIZE;
488 488
489 VPRINTF("%s: %zu L2 pages are needed to map %#zx kernel bytes\n", 489 VPRINTF("%s: %zu L2 pages are needed to map %#zx kernel bytes\n",
490 __func__, KERNEL_L2PT_KERNEL_NUM, kernel_size); 490 __func__, KERNEL_L2PT_KERNEL_NUM, kernel_size);
491 491
492 KASSERT(KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM < __arraycount(bmi->bmi_l2pts)); 492 KASSERT(KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM < __arraycount(bmi->bmi_l2pts));
493 pv_addr_t * const kernel_l2pt = bmi->bmi_l2pts; 493 pv_addr_t * const kernel_l2pt = bmi->bmi_l2pts;
494 pv_addr_t * const vmdata_l2pt = kernel_l2pt + KERNEL_L2PT_KERNEL_NUM; 494 pv_addr_t * const vmdata_l2pt = kernel_l2pt + KERNEL_L2PT_KERNEL_NUM;
495 pv_addr_t msgbuf; 495 pv_addr_t msgbuf;
496 pv_addr_t text; 496 pv_addr_t text;
497 pv_addr_t data; 497 pv_addr_t data;
498 pv_addr_t chunks[KERNEL_L2PT_KERNEL_NUM + KERNEL_L2PT_VMDATA_NUM + 11]; 498 pv_addr_t chunks[__arraycount(bmi->bmi_l2pts) + 11];
499#if ARM_MMU_XSCALE == 1 499#if ARM_MMU_XSCALE == 1
500 pv_addr_t minidataclean; 500 pv_addr_t minidataclean;
501#endif 501#endif
502 502
503 /* 503 /*
504 * We need to allocate some fixed page tables to get the kernel going. 504 * We need to allocate some fixed page tables to get the kernel going.
505 * 505 *
506 * We are going to allocate our bootstrap pages from the beginning of 506 * We are going to allocate our bootstrap pages from the beginning of
507 * the free space that we just calculated. We allocate one page 507 * the free space that we just calculated. We allocate one page
508 * directory and a number of page tables and store the physical 508 * directory and a number of page tables and store the physical
509 * addresses in the bmi_l2pts array in bootmem_info. 509 * addresses in the bmi_l2pts array in bootmem_info.
510 * 510 *
511 * The kernel page directory must be on a 16K boundary. The page 511 * The kernel page directory must be on a 16K boundary. The page