OLD | NEW |
1 /* | 1 /* |
2 * This file contains kasan initialization code for ARM64. | 2 * This file contains kasan initialization code for ARM64. |
3 * | 3 * |
4 * Copyright (c) 2015 Samsung Electronics Co., Ltd. | 4 * Copyright (c) 2015 Samsung Electronics Co., Ltd. |
5 * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com> | 5 * Author: Andrey Ryabinin <ryabinin.a.a@gmail.com> |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
9 * published by the Free Software Foundation. | 9 * published by the Free Software Foundation. |
10 * | 10 * |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); | 162 clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); |
163 | 163 |
164 vmemmap_populate(kimg_shadow_start, kimg_shadow_end, | 164 vmemmap_populate(kimg_shadow_start, kimg_shadow_end, |
165 pfn_to_nid(virt_to_pfn(lm_alias(_text)))); | 165 pfn_to_nid(virt_to_pfn(lm_alias(_text)))); |
166 | 166 |
167 /* | 167 /* |
168 * vmemmap_populate() has populated the shadow region that covers the | 168 * vmemmap_populate() has populated the shadow region that covers the |
169 * kernel image with SWAPPER_BLOCK_SIZE mappings, so we have to round | 169 * kernel image with SWAPPER_BLOCK_SIZE mappings, so we have to round |
170 * the start and end addresses to SWAPPER_BLOCK_SIZE as well, to prevent | 170 * the start and end addresses to SWAPPER_BLOCK_SIZE as well, to prevent |
171 » * kasan_populate_zero_shadow() from replacing the page table entries | 171 » * kasan_populate_shadow() from replacing the page table entries |
172 * (PMD or PTE) at the edges of the shadow region for the kernel | 172 * (PMD or PTE) at the edges of the shadow region for the kernel |
173 * image. | 173 * image. |
174 */ | 174 */ |
175 kimg_shadow_start = round_down(kimg_shadow_start, SWAPPER_BLOCK_SIZE); | 175 kimg_shadow_start = round_down(kimg_shadow_start, SWAPPER_BLOCK_SIZE); |
176 kimg_shadow_end = round_up(kimg_shadow_end, SWAPPER_BLOCK_SIZE); | 176 kimg_shadow_end = round_up(kimg_shadow_end, SWAPPER_BLOCK_SIZE); |
177 | 177 |
178 » kasan_populate_zero_shadow((void *)KASAN_SHADOW_START, | 178 » kasan_populate_shadow((void *)KASAN_SHADOW_START, |
179 » » » » (void *)mod_shadow_start); | 179 » » » » (void *)mod_shadow_start, |
180 » kasan_populate_zero_shadow((void *)kimg_shadow_end, | 180 » » » » true, false); |
181 » » » » kasan_mem_to_shadow((void *)PAGE_OFFSET)); | 181 » kasan_populate_shadow((void *)kimg_shadow_end, |
| 182 » » » » kasan_mem_to_shadow((void *)PAGE_OFFSET), |
| 183 » » » » true, false); |
182 | 184 |
183 if (kimg_shadow_start > mod_shadow_end) | 185 if (kimg_shadow_start > mod_shadow_end) |
184 » » kasan_populate_zero_shadow((void *)mod_shadow_end, | 186 » » kasan_populate_shadow((void *)mod_shadow_end, |
185 » » » » » (void *)kimg_shadow_start); | 187 » » » » » (void *)kimg_shadow_start, |
| 188 » » » » » true, false); |
186 | 189 |
187 for_each_memblock(memory, reg) { | 190 for_each_memblock(memory, reg) { |
188 void *start = (void *)__phys_to_virt(reg->base); | 191 void *start = (void *)__phys_to_virt(reg->base); |
189 void *end = (void *)__phys_to_virt(reg->base + reg->size); | 192 void *end = (void *)__phys_to_virt(reg->base + reg->size); |
190 | 193 |
191 if (start >= end) | 194 if (start >= end) |
192 break; | 195 break; |
193 | 196 |
194 /* | 197 /* |
195 * end + 1 here is intentional. We check several shadow bytes in | 198 * end + 1 here is intentional. We check several shadow bytes in |
(...skipping 14 matching lines...) Expand all Loading... |
210 set_pte(&kasan_zero_pte[i], | 213 set_pte(&kasan_zero_pte[i], |
211 pfn_pte(sym_to_pfn(kasan_zero_page), PAGE_KERNEL_RO)); | 214 pfn_pte(sym_to_pfn(kasan_zero_page), PAGE_KERNEL_RO)); |
212 | 215 |
213 memset(kasan_zero_page, 0, PAGE_SIZE); | 216 memset(kasan_zero_page, 0, PAGE_SIZE); |
214 cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); | 217 cpu_replace_ttbr1(lm_alias(swapper_pg_dir)); |
215 | 218 |
216 /* At this point kasan is fully initialized. Enable error messages */ | 219 /* At this point kasan is fully initialized. Enable error messages */ |
217 init_task.kasan_depth = 0; | 220 init_task.kasan_depth = 0; |
218 pr_info("KernelAddressSanitizer initialized\n"); | 221 pr_info("KernelAddressSanitizer initialized\n"); |
219 } | 222 } |
OLD | NEW |