hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/perf/arch/x86/tests/dwarf-unwind.c
....@@ -3,6 +3,7 @@
33 #include "perf_regs.h"
44 #include "thread.h"
55 #include "map.h"
6
+#include "maps.h"
67 #include "event.h"
78 #include "debug.h"
89 #include "tests/tests.h"
....@@ -26,7 +27,7 @@
2627
2728 sp = (unsigned long) regs[PERF_REG_X86_SP];
2829
29
- map = map_groups__find(thread->mg, (u64)sp);
30
+ map = maps__find(thread->maps, (u64)sp);
3031 if (!map) {
3132 pr_debug("failed to get stack map\n");
3233 free(buf);
....@@ -37,6 +38,13 @@
3738 stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
3839
3940 memcpy(buf, (void *) sp, stack_size);
41
+#ifdef MEMORY_SANITIZER
42
+ /*
43
+ * Copying the stack may copy msan poison, avoid false positives in the
44
+ * unwinder by removing the poison here.
45
+ */
46
+ __msan_unpoison(buf, stack_size);
47
+#endif
4048 stack->data = (char *) buf;
4149 stack->size = stack_size;
4250 return 0;
....@@ -54,6 +62,14 @@
5462 return -1;
5563 }
5664
65
+#ifdef MEMORY_SANITIZER
66
+ /*
67
+ * Assignments to buf in the assembly function perf_regs_load aren't
68
+ * seen by memory sanitizer. Zero the memory to convince memory
69
+ * sanitizer the memory is initialized.
70
+ */
71
+ memset(buf, 0, sizeof(u64) * PERF_REGS_MAX);
72
+#endif
5773 perf_regs_load(buf);
5874 regs->abi = PERF_SAMPLE_REGS_ABI;
5975 regs->regs = buf;