On Tue, Oct 15, 2024 at 11:37:14PM +0200, Linus Walleij wrote:
@@ -125,6 +126,12 @@ void __check_vmalloc_seq(struct mm_struct *mm) pgd_offset_k(VMALLOC_START), sizeof(pgd_t) * (pgd_index(VMALLOC_END) - pgd_index(VMALLOC_START)));
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
memcpy(pgd_offset(mm, (unsigned long)kasan_mem_to_shadow((void *)VMALLOC_START)),
pgd_offset_k((unsigned long)kasan_mem_to_shadow((void *)VMALLOC_START)),
sizeof(pgd_t) * (pgd_index((unsigned long)kasan_mem_to_shadow((void *)VMALLOC_END)) -
pgd_index((unsigned long)kasan_mem_to_shadow((void *)VMALLOC_START))));
Maybe the following would be more readable:
static unsigned long arm_kasan_mem_to_shadow(unsigned long addr) { return (unsigned long)kasan_mem_to_shadow((void *)addr); }
static void memcpy_pgd(struct mm_struct *mm, unsigned long start, unsigned long end) { memcpy(pgd_offset(mm, start), pgd_offset_k(start), sizeof(pgd_t) * (pgd_index(end) - pgd_index(start))); }
seq = ...; memcpy_pgd(mm, VMALLOC_START, VMALLOC_END);
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) { unsigned long start = arm_kasan_mem_to_shadow(VMALLOC_START); unsigned long end = arm_kasan_mem_to_shadow(VMALLOC_END);
memcpy_pgd(mm, start, end);
}
?