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.

Merge tag 'trace-ring-buffer-v7.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace

Pull ring-buffer fix from Steven Rostedt:

- Make undefsyms_base.c into a real file

The file undefsyms_base.c is used to catch any symbols used by a
remote ring buffer that is made for use of a pKVM hypervisor. As it
doesn't share the same text as the rest of the kernel, referencing
any symbols within the kernel will make it fail to be built for the
standalone hypervisor.

A file was created by the Makefile that checked for any symbols that
could cause issues. There's no reason to have this file created by
the Makefile, just create it as a normal file instead.

* tag 'trace-ring-buffer-v7.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
tracing: Make undefsyms_base.c a first-class citizen

+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 + }