Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kmsan: expose kmsan_get_metadata()

Each s390 CPU has lowcore pages associated with it. Each CPU sees its own
lowcore at virtual address 0 through a hardware mechanism called
prefixing. Additionally, all lowcores are mapped to non-0 virtual
addresses stored in the lowcore_ptr[] array.

When lowcore is accessed through virtual address 0, one needs to resolve
metadata for lowcore_ptr[raw_smp_processor_id()].

Expose kmsan_get_metadata() to make it possible to do this from the arch
code.

Link: https://lkml.kernel.org/r/20240621113706.315500-10-iii@linux.ibm.com
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: <kasan-dev@googlegroups.com>
Cc: Marco Elver <elver@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Steven Rostedt (Google) <rostedt@goodmis.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ilya Leoshkevich and committed by
Andrew Morton
6b1709d4 61849c89

+10 -1
+9
include/linux/kmsan.h
··· 230 230 */ 231 231 void kmsan_unpoison_entry_regs(const struct pt_regs *regs); 232 232 233 + /** 234 + * kmsan_get_metadata() - Return a pointer to KMSAN shadow or origins. 235 + * @addr: kernel address. 236 + * @is_origin: whether to return origins or shadow. 237 + * 238 + * Return NULL if metadata cannot be found. 239 + */ 240 + void *kmsan_get_metadata(void *addr, bool is_origin); 241 + 233 242 #else 234 243 235 244 static inline void kmsan_init_shadow(void)
+1
mm/kmsan/instrumentation.c
··· 14 14 15 15 #include "kmsan.h" 16 16 #include <linux/gfp.h> 17 + #include <linux/kmsan.h> 17 18 #include <linux/kmsan_string.h> 18 19 #include <linux/mm.h> 19 20 #include <linux/uaccess.h>
-1
mm/kmsan/kmsan.h
··· 66 66 67 67 struct shadow_origin_ptr kmsan_get_shadow_origin_ptr(void *addr, u64 size, 68 68 bool store); 69 - void *kmsan_get_metadata(void *addr, bool is_origin); 70 69 void __init kmsan_init_alloc_meta_for_range(void *start, void *end); 71 70 72 71 enum kmsan_bug_reason {