/* * Functions below are declared in the header to make sure they are inlined. * They all are called from kmsan_get_metadata() for every memory access in * the kernel, so speed is important here.
*/
/* * Compute metadata addresses for the CPU entry area on x86.
*/ staticinlinevoid *arch_kmsan_get_meta_or_null(void *addr, bool is_origin)
{ unsignedlong addr64 = (unsignedlong)addr; char *metadata_array; unsignedlong off; int cpu;
/* * Taken from arch/x86/mm/physaddr.h to avoid using an instrumented version.
*/ staticinlinebool kmsan_phys_addr_valid(unsignedlong addr)
{ if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) return !(addr >> boot_cpu_data.x86_phys_bits); else returntrue;
}
/* * Taken from arch/x86/mm/physaddr.c to avoid using an instrumented version.
*/ staticinlinebool kmsan_virt_addr_valid(void *addr)
{ unsignedlong x = (unsignedlong)addr; unsignedlong y = x - __START_KERNEL_map; bool ret;
/* use the carry flag to determine if x was < __START_KERNEL_map */ if (unlikely(x > y)) {
x = y + phys_base;
if (y >= KERNEL_IMAGE_SIZE) returnfalse;
} else {
x = y + (__START_KERNEL_map - PAGE_OFFSET);
/* carry flag will be set if starting x was >= PAGE_OFFSET */ if ((x > y) || !kmsan_phys_addr_valid(x)) returnfalse;
}
/* * pfn_valid() relies on RCU, and may call into the scheduler on exiting * the critical section. However, this would result in recursion with * KMSAN. Therefore, disable preemption here, and re-enable preemption * below while suppressing reschedules to avoid recursion. * * Note, this sacrifices occasionally breaking scheduling guarantees. * Although, a kernel compiled with KMSAN has already given up on any * performance guarantees due to being heavily instrumented.
*/
preempt_disable();
ret = pfn_valid(x >> PAGE_SHIFT);
preempt_enable_no_resched();
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.