Sat Apr 30 19:20:47 2016 UTC ()
* fix checking physical address range. on some arm devices, physical memory doesn't start from 0x00000000.
* allow /dev/mem to read/write memory mapped I/O area depending on kauth.


(ryo)
diff -r1.109 -r1.110 src/sys/arch/arm/arm32/arm32_machdep.c

cvs diff -r1.109 -r1.110 src/sys/arch/arm/arm32/arm32_machdep.c (expand / switch to unified diff)

--- src/sys/arch/arm/arm32/arm32_machdep.c 2015/04/11 13:37:59 1.109
+++ src/sys/arch/arm/arm32/arm32_machdep.c 2016/04/30 19:20:47 1.110
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: arm32_machdep.c,v 1.109 2015/04/11 13:37:59 bouyer Exp $ */ 1/* $NetBSD: arm32_machdep.c,v 1.110 2016/04/30 19:20:47 ryo Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994-1998 Mark Brinicombe. 4 * Copyright (c) 1994-1998 Mark Brinicombe.
5 * Copyright (c) 1994 Brini. 5 * Copyright (c) 1994 Brini.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software written for Brini by Mark Brinicombe 8 * This code is derived from software written for Brini by Mark Brinicombe
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE. 36 * SUCH DAMAGE.
37 * 37 *
38 * Machine dependent functions for kernel setup 38 * Machine dependent functions for kernel setup
39 * 39 *
40 * Created : 17/09/94 40 * Created : 17/09/94
41 * Updated : 18/04/01 updated for new wscons 41 * Updated : 18/04/01 updated for new wscons
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.109 2015/04/11 13:37:59 bouyer Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.110 2016/04/30 19:20:47 ryo Exp $");
46 46
47#include "opt_modular.h" 47#include "opt_modular.h"
48#include "opt_md.h" 48#include "opt_md.h"
49#include "opt_pmap_debug.h" 49#include "opt_pmap_debug.h"
50#include "opt_multiprocessor.h" 50#include "opt_multiprocessor.h"
51 51
52#include <sys/param.h> 52#include <sys/param.h>
53#include <sys/systm.h> 53#include <sys/systm.h>
54#include <sys/reboot.h> 54#include <sys/reboot.h>
55#include <sys/proc.h> 55#include <sys/proc.h>
56#include <sys/kauth.h> 56#include <sys/kauth.h>
57#include <sys/kernel.h> 57#include <sys/kernel.h>
58#include <sys/mbuf.h> 58#include <sys/mbuf.h>
@@ -670,28 +670,31 @@ dosoftints(void) @@ -670,28 +670,31 @@ dosoftints(void)
670#ifdef MODULAR 670#ifdef MODULAR
671/* 671/*
672 * Push any modules loaded by the boot loader. 672 * Push any modules loaded by the boot loader.
673 */ 673 */
674void 674void
675module_init_md(void) 675module_init_md(void)
676{ 676{
677} 677}
678#endif /* MODULAR */ 678#endif /* MODULAR */
679 679
680int 680int
681mm_md_physacc(paddr_t pa, vm_prot_t prot) 681mm_md_physacc(paddr_t pa, vm_prot_t prot)
682{ 682{
 683 if (pa >= physical_start && pa < physical_end)
 684 return 0;
683 685
684 return (pa < ctob(physmem)) ? 0 : EFAULT; 686 return kauth_authorize_machdep(kauth_cred_get(),
 687 KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
685} 688}
686 689
687#ifdef __HAVE_CPU_UAREA_ALLOC_IDLELWP 690#ifdef __HAVE_CPU_UAREA_ALLOC_IDLELWP
688vaddr_t 691vaddr_t
689cpu_uarea_alloc_idlelwp(struct cpu_info *ci) 692cpu_uarea_alloc_idlelwp(struct cpu_info *ci)
690{ 693{
691 const vaddr_t va = idlestack.pv_va + ci->ci_cpuid * USPACE; 694 const vaddr_t va = idlestack.pv_va + ci->ci_cpuid * USPACE;
692 // printf("%s: %s: va=%lx\n", __func__, ci->ci_data.cpu_name, va); 695 // printf("%s: %s: va=%lx\n", __func__, ci->ci_data.cpu_name, va);
693 return va; 696 return va;
694} 697}
695#endif 698#endif
696 699
697#ifdef MULTIPROCESSOR 700#ifdef MULTIPROCESSOR