Tue Jun 23 17:21:55 2020 UTC ()
Rename __MD_CANONICAL_BASE -> __MD_KERNMEM_BASE for clarity.


(maxv)
diff -r1.6 -r1.7 src/sys/arch/aarch64/include/asan.h
diff -r1.6 -r1.7 src/sys/arch/amd64/include/asan.h

cvs diff -r1.6 -r1.7 src/sys/arch/aarch64/include/asan.h (expand / switch to unified diff)

--- src/sys/arch/aarch64/include/asan.h 2019/04/08 21:18:22 1.6
+++ src/sys/arch/aarch64/include/asan.h 2020/06/23 17:21:55 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: asan.h,v 1.6 2019/04/08 21:18:22 ryo Exp $ */ 1/* $NetBSD: asan.h,v 1.7 2020/06/23 17:21:55 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Maxime Villard. 8 * by Maxime Villard.
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.
@@ -29,40 +29,40 @@ @@ -29,40 +29,40 @@
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/atomic.h> 32#include <sys/atomic.h>
33#include <sys/ksyms.h> 33#include <sys/ksyms.h>
34 34
35#include <aarch64/pmap.h> 35#include <aarch64/pmap.h>
36#include <aarch64/vmparam.h> 36#include <aarch64/vmparam.h>
37#include <aarch64/cpufunc.h> 37#include <aarch64/cpufunc.h>
38#include <aarch64/armreg.h> 38#include <aarch64/armreg.h>
39#include <aarch64/machdep.h> 39#include <aarch64/machdep.h>
40 40
41#define __MD_VIRTUAL_SHIFT 48 /* 49bit address space, cut half */ 41#define __MD_VIRTUAL_SHIFT 48 /* 49bit address space, cut half */
42#define __MD_CANONICAL_BASE 0xFFFF000000000000 42#define __MD_KERNMEM_BASE 0xFFFF000000000000 /* kern mem base address */
43 43
44#define __MD_SHADOW_SIZE (1ULL << (__MD_VIRTUAL_SHIFT - KASAN_SHADOW_SCALE_SHIFT)) 44#define __MD_SHADOW_SIZE (1ULL << (__MD_VIRTUAL_SHIFT - KASAN_SHADOW_SCALE_SHIFT))
45#define KASAN_MD_SHADOW_START (AARCH64_KSEG_END) 45#define KASAN_MD_SHADOW_START (AARCH64_KSEG_END)
46#define KASAN_MD_SHADOW_END (KASAN_MD_SHADOW_START + __MD_SHADOW_SIZE) 46#define KASAN_MD_SHADOW_END (KASAN_MD_SHADOW_START + __MD_SHADOW_SIZE)
47 47
48static bool __md_early __read_mostly = true; 48static bool __md_early __read_mostly = true;
49 49
50static inline int8_t * 50static inline int8_t *
51kasan_md_addr_to_shad(const void *addr) 51kasan_md_addr_to_shad(const void *addr)
52{ 52{
53 vaddr_t va = (vaddr_t)addr; 53 vaddr_t va = (vaddr_t)addr;
54 return (int8_t *)(KASAN_MD_SHADOW_START + 54 return (int8_t *)(KASAN_MD_SHADOW_START +
55 ((va - __MD_CANONICAL_BASE) >> KASAN_SHADOW_SCALE_SHIFT)); 55 ((va - __MD_KERNMEM_BASE) >> KASAN_SHADOW_SCALE_SHIFT));
56} 56}
57 57
58static inline bool 58static inline bool
59kasan_md_unsupported(vaddr_t addr) 59kasan_md_unsupported(vaddr_t addr)
60{ 60{
61 return (addr < VM_MIN_KERNEL_ADDRESS) || 61 return (addr < VM_MIN_KERNEL_ADDRESS) ||
62 (addr >= VM_KERNEL_IO_ADDRESS); 62 (addr >= VM_KERNEL_IO_ADDRESS);
63} 63}
64 64
65static paddr_t 65static paddr_t
66__md_palloc(void) 66__md_palloc(void)
67{ 67{
68 paddr_t pa; 68 paddr_t pa;

cvs diff -r1.6 -r1.7 src/sys/arch/amd64/include/asan.h (expand / switch to unified diff)

--- src/sys/arch/amd64/include/asan.h 2020/05/02 16:28:37 1.6
+++ src/sys/arch/amd64/include/asan.h 2020/06/23 17:21:55 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: asan.h,v 1.6 2020/05/02 16:28:37 maxv Exp $ */ 1/* $NetBSD: asan.h,v 1.7 2020/06/23 17:21:55 maxv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2018 The NetBSD Foundation, Inc. 4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Maxime Villard. 8 * by Maxime Villard.
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#include <sys/ksyms.h> 32#include <sys/ksyms.h>
33 33
34#include <amd64/pmap.h> 34#include <amd64/pmap.h>
35#include <amd64/vmparam.h> 35#include <amd64/vmparam.h>
36 36
37#ifdef __HAVE_PCPU_AREA 37#ifdef __HAVE_PCPU_AREA
38#error "PCPU area not allowed with KASAN" 38#error "PCPU area not allowed with KASAN"
39#endif 39#endif
40#ifdef __HAVE_DIRECT_MAP 40#ifdef __HAVE_DIRECT_MAP
41#error "DMAP not allowed with KASAN" 41#error "DMAP not allowed with KASAN"
42#endif 42#endif
43 43
44#define __MD_VIRTUAL_SHIFT 47 /* 48bit address space, cut half */ 44#define __MD_VIRTUAL_SHIFT 47 /* 48bit address space, cut half */
45#define __MD_CANONICAL_BASE 0xFFFF800000000000 45#define __MD_KERNMEM_BASE 0xFFFF800000000000 /* kern mem base address */
46 46
47#define __MD_SHADOW_SIZE (1ULL << (__MD_VIRTUAL_SHIFT - KASAN_SHADOW_SCALE_SHIFT)) 47#define __MD_SHADOW_SIZE (1ULL << (__MD_VIRTUAL_SHIFT - KASAN_SHADOW_SCALE_SHIFT))
48#define KASAN_MD_SHADOW_START (VA_SIGN_NEG((L4_SLOT_KASAN * NBPD_L4))) 48#define KASAN_MD_SHADOW_START (VA_SIGN_NEG((L4_SLOT_KASAN * NBPD_L4)))
49#define KASAN_MD_SHADOW_END (KASAN_MD_SHADOW_START + __MD_SHADOW_SIZE) 49#define KASAN_MD_SHADOW_END (KASAN_MD_SHADOW_START + __MD_SHADOW_SIZE)
50 50
51/* -------------------------------------------------------------------------- */ 51/* -------------------------------------------------------------------------- */
52 52
53/* 53/*
54 * Early mapping, used to map just the stack at boot time. We rely on the fact 54 * Early mapping, used to map just the stack at boot time. We rely on the fact
55 * that VA = PA + KERNBASE. 55 * that VA = PA + KERNBASE.
56 */ 56 */
57 57
58static bool __md_early __read_mostly = true; 58static bool __md_early __read_mostly = true;
@@ -103,27 +103,27 @@ __md_early_shadow_map_page(vaddr_t va) @@ -103,27 +103,27 @@ __md_early_shadow_map_page(vaddr_t va)
103 if (!pmap_valid_entry(pdir[pl1_pi(va)])) { 103 if (!pmap_valid_entry(pdir[pl1_pi(va)])) {
104 pa = __md_early_palloc(); 104 pa = __md_early_palloc();
105 pdir[pl1_pi(va)] = pa | pteflags | pmap_pg_g; 105 pdir[pl1_pi(va)] = pa | pteflags | pmap_pg_g;
106 } 106 }
107} 107}
108 108
109/* -------------------------------------------------------------------------- */ 109/* -------------------------------------------------------------------------- */
110 110
111static inline int8_t * 111static inline int8_t *
112kasan_md_addr_to_shad(const void *addr) 112kasan_md_addr_to_shad(const void *addr)
113{ 113{
114 vaddr_t va = (vaddr_t)addr; 114 vaddr_t va = (vaddr_t)addr;
115 return (int8_t *)(KASAN_MD_SHADOW_START + 115 return (int8_t *)(KASAN_MD_SHADOW_START +
116 ((va - __MD_CANONICAL_BASE) >> KASAN_SHADOW_SCALE_SHIFT)); 116 ((va - __MD_KERNMEM_BASE) >> KASAN_SHADOW_SCALE_SHIFT));
117} 117}
118 118
119static inline bool 119static inline bool
120kasan_md_unsupported(vaddr_t addr) 120kasan_md_unsupported(vaddr_t addr)
121{ 121{
122 return (addr >= (vaddr_t)PTE_BASE && 122 return (addr >= (vaddr_t)PTE_BASE &&
123 addr < ((vaddr_t)PTE_BASE + NBPD_L4)); 123 addr < ((vaddr_t)PTE_BASE + NBPD_L4));
124} 124}
125 125
126static paddr_t 126static paddr_t
127__md_palloc(void) 127__md_palloc(void)
128{ 128{
129 /* The page is zeroed. */ 129 /* The page is zeroed. */