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.

tracing: Make undefsyms_base.c a first-class citizen

Linus points out that dumping undefsyms_base.c form the Makefile
is rather ugly, and that a much better course of action would be
to have this file as a first-class citizen in the git tree.

This allows some extra cleanup in the Makefile, and the removal of
the .gitignore file in kernel/trace.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/CAHk-=wieqGd_XKpu8UxDoyADZx8TDe8CF3RmkUXt5N_9t5Pf_w@mail.gmail.com
Link: https://lore.kernel.org/all/20260421095446.2951646-1-maz@kernel.org/
Link: https://patch.msgid.link/20260421100455.324333-1-pbonzini@redhat.com
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Paolo Bonzini and committed by
Steven Rostedt
5335e318 b4e07588

+32 -32
-1
kernel/trace/.gitignore
··· 1 - /undefsyms_base.c
+4 -31
kernel/trace/Makefile
··· 133 133 obj-$(CONFIG_SIMPLE_RING_BUFFER) += simple_ring_buffer.o 134 134 obj-$(CONFIG_TRACE_REMOTE_TEST) += remote_test.o 135 135 136 - # 137 136 # simple_ring_buffer is used by the pKVM hypervisor which does not have access 138 137 # to all kernel symbols. Fail the build if forbidden symbols are found. 139 - # 140 - # undefsyms_base generates a set of compiler and tooling-generated symbols that can 141 - # safely be ignored for simple_ring_buffer. 142 - # 143 - filechk_undefsyms_base = \ 144 - echo '$(pound)include <linux/atomic.h>'; \ 145 - echo '$(pound)include <linux/string.h>'; \ 146 - echo '$(pound)include <asm/page.h>'; \ 147 - echo 'static char page[PAGE_SIZE] __aligned(PAGE_SIZE);'; \ 148 - echo 'void undefsyms_base(void *p, int n);'; \ 149 - echo 'void undefsyms_base(void *p, int n) {'; \ 150 - echo ' char buffer[256] = { 0 };'; \ 151 - echo ' u32 u = 0;'; \ 152 - echo ' memset((char * volatile)page, 8, PAGE_SIZE);'; \ 153 - echo ' memset((char * volatile)buffer, 8, sizeof(buffer));'; \ 154 - echo ' memcpy((void * volatile)p, buffer, sizeof(buffer));'; \ 155 - echo ' cmpxchg((u32 * volatile)&u, 0, 8);'; \ 156 - echo ' WARN_ON(n == 0xdeadbeef);'; \ 157 - echo '}' 158 138 159 - $(obj)/undefsyms_base.c: FORCE 160 - $(call filechk,undefsyms_base) 161 - 162 - clean-files += undefsyms_base.c 163 - 164 - $(obj)/undefsyms_base.o: $(obj)/undefsyms_base.c 165 - 139 + # Basic compiler and tooling-generated symbols that can safely be left 140 + # undefined. Ensure KASAN is enabled to avoid logic that may disable 141 + # FORTIFY_SOURCE when KASAN is not enabled. undefsyms_base.o does not 142 + # automatically get KASAN flags because it is not linked into vmlinux. 166 143 targets += undefsyms_base.o 167 - 168 - # Ensure KASAN is enabled to avoid logic that may disable FORTIFY_SOURCE when 169 - # KASAN is not enabled. undefsyms_base.o does not automatically get KASAN flags 170 - # because it is not linked into vmlinux. 171 144 KASAN_SANITIZE_undefsyms_base.o := y 172 145 173 146 UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __x86_indirect_thunk \
+28
kernel/trace/undefsyms_base.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * simple_ring_buffer is used by the pKVM hypervisor which does not have access 5 + * to all kernel symbols. Whatever is undefined when compiling this file is 6 + * compiler and tooling-generated symbols that can safely be ignored for 7 + * simple_ring_buffer. 8 + */ 9 + 10 + #include <linux/atomic.h> 11 + #include <linux/string.h> 12 + #include <asm/page.h> 13 + 14 + void undefsyms_base(void *p, int n); 15 + 16 + static char page[PAGE_SIZE] __aligned(PAGE_SIZE); 17 + 18 + void undefsyms_base(void *p, int n) 19 + { 20 + char buffer[256] = { 0 }; 21 + 22 + u32 u = 0; 23 + memset((char * volatile)page, 8, PAGE_SIZE); 24 + memset((char * volatile)buffer, 8, sizeof(buffer)); 25 + memcpy((void * volatile)p, buffer, sizeof(buffer)); 26 + cmpxchg((u32 * volatile)&u, 0, 8); 27 + WARN_ON(n == 0xdeadbeef); 28 + }