Linux 6.9-rc1
[linux-2.6-microblaze.git] / kernel / kcov.c
index e19c84b..f9ac2e9 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/hashtable.h>
 #include <linux/init.h>
+#include <linux/kmsan-checks.h>
 #include <linux/mm.h>
 #include <linux/preempt.h>
 #include <linux/printk.h>
@@ -152,6 +153,12 @@ static void kcov_remote_area_put(struct kcov_remote_area *area,
        INIT_LIST_HEAD(&area->list);
        area->size = size;
        list_add(&area->list, &kcov_remote_areas);
+       /*
+        * KMSAN doesn't instrument this file, so it may not know area->list
+        * is initialized. Unpoison it explicitly to avoid reports in
+        * kcov_remote_area_get().
+        */
+       kmsan_unpoison_memory(&area->list, sizeof(area->list));
 }
 
 static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
@@ -272,7 +279,7 @@ void notrace __sanitizer_cov_trace_cmp4(u32 arg1, u32 arg2)
 }
 EXPORT_SYMBOL(__sanitizer_cov_trace_cmp4);
 
-void notrace __sanitizer_cov_trace_cmp8(u64 arg1, u64 arg2)
+void notrace __sanitizer_cov_trace_cmp8(kcov_u64 arg1, kcov_u64 arg2)
 {
        write_comp_data(KCOV_CMP_SIZE(3), arg1, arg2, _RET_IP_);
 }
@@ -299,16 +306,17 @@ void notrace __sanitizer_cov_trace_const_cmp4(u32 arg1, u32 arg2)
 }
 EXPORT_SYMBOL(__sanitizer_cov_trace_const_cmp4);
 
-void notrace __sanitizer_cov_trace_const_cmp8(u64 arg1, u64 arg2)
+void notrace __sanitizer_cov_trace_const_cmp8(kcov_u64 arg1, kcov_u64 arg2)
 {
        write_comp_data(KCOV_CMP_SIZE(3) | KCOV_CMP_CONST, arg1, arg2,
                        _RET_IP_);
 }
 EXPORT_SYMBOL(__sanitizer_cov_trace_const_cmp8);
 
-void notrace __sanitizer_cov_trace_switch(u64 val, u64 *cases)
+void notrace __sanitizer_cov_trace_switch(kcov_u64 val, void *arg)
 {
        u64 i;
+       u64 *cases = arg;
        u64 count = cases[0];
        u64 size = cases[1];
        u64 type = KCOV_CMP_CONST;
@@ -482,7 +490,7 @@ static int kcov_mmap(struct file *filep, struct vm_area_struct *vma)
                goto exit;
        }
        spin_unlock_irqrestore(&kcov->lock, flags);
-       vma->vm_flags |= VM_DONTEXPAND;
+       vm_flags_set(vma, VM_DONTEXPAND);
        for (off = 0; off < size; off += PAGE_SIZE) {
                page = vmalloc_to_page(kcov->area + off);
                res = vm_insert_page(vma, vma->vm_start + off, page);