// SPDX-License-Identifier: GPL-2.0 /* * KASAN for 64-bit Book3S powerpc * * Copyright 2019-2022, Daniel Axtens, IBM Corporation.
*/
/* * ppc64 turns on virtual memory late in boot, after calling into generic code * like the device-tree parser, so it uses this in conjunction with a hook in * outline mode to avoid invalid access early in boot.
*/
va = memblock_alloc_or_panic(k_end - k_start, PAGE_SIZE); for (k_cur = k_start; k_cur < k_end; k_cur += PAGE_SIZE, va += PAGE_SIZE)
map_kernel_page(k_cur, __pa(va), PAGE_KERNEL);
}
void __init kasan_init(void)
{ /* * We want to do the following things: * 1) Map real memory into the shadow for all physical memblocks * This takes us from c000... to c008... * 2) Leave a hole over the shadow of vmalloc space. KASAN_VMALLOC * will manage this for us. * This takes us from c008... to c00a... * 3) Map the 'early shadow'/zero page over iomap and vmemmap space. * This takes us up to where we start at c00e...
*/
for (i = 0; i < PTRS_PER_PTE; i++)
__set_pte_at(&init_mm, (unsignedlong)kasan_early_shadow_page,
&kasan_early_shadow_pte[i], zero_pte, 0);
for (i = 0; i < PTRS_PER_PMD; i++)
pmd_populate_kernel(&init_mm, &kasan_early_shadow_pmd[i],
kasan_early_shadow_pte);
for (i = 0; i < PTRS_PER_PUD; i++)
pud_populate(&init_mm, &kasan_early_shadow_pud[i],
kasan_early_shadow_pmd);
/* map the early shadow over the iomap and vmemmap space */
kasan_populate_early_shadow(k_start, k_end);
/* mark early shadow region as RO and wipe it */
zero_pte = pfn_pte(virt_to_pfn(kasan_early_shadow_page), PAGE_KERNEL_RO); for (i = 0; i < PTRS_PER_PTE; i++)
__set_pte_at(&init_mm, (unsignedlong)kasan_early_shadow_page,
&kasan_early_shadow_pte[i], zero_pte, 0);
/* * clear_page relies on some cache info that hasn't been set up yet. * It ends up looping ~forever and blows up other data. * Use memset instead.
*/
memset(kasan_early_shadow_page, 0, PAGE_SIZE);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.