ring-buffer fix for v7.1

- 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.
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYKADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCaekbsxQccm9zdGVkdEBn
 b29kbWlzLm9yZwAKCRAp5XQQmuv6qr0MAQCHMFK56uzmMvQJg5Tfhtb+grY7ryo4
 j0rjLkNQBovmxwD/XylBDkhxr8IQ72jU04e+xuXzrqoT18U7XvQEVpPgkQQ=
 =dQi0
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2026-04-22 14:47:52 -07:00
commit 1e18ed5727
3 changed files with 32 additions and 32 deletions

View File

@ -1 +0,0 @@
/undefsyms_base.c

View File

@ -133,41 +133,14 @@ obj-$(CONFIG_TRACE_REMOTE) += trace_remote.o
obj-$(CONFIG_SIMPLE_RING_BUFFER) += simple_ring_buffer.o
obj-$(CONFIG_TRACE_REMOTE_TEST) += remote_test.o
#
# simple_ring_buffer is used by the pKVM hypervisor which does not have access
# to all kernel symbols. Fail the build if forbidden symbols are found.
#
# undefsyms_base generates a set of compiler and tooling-generated symbols that can
# safely be ignored for simple_ring_buffer.
#
filechk_undefsyms_base = \
echo '$(pound)include <linux/atomic.h>'; \
echo '$(pound)include <linux/string.h>'; \
echo '$(pound)include <asm/page.h>'; \
echo 'static char page[PAGE_SIZE] __aligned(PAGE_SIZE);'; \
echo 'void undefsyms_base(void *p, int n);'; \
echo 'void undefsyms_base(void *p, int n) {'; \
echo ' char buffer[256] = { 0 };'; \
echo ' u32 u = 0;'; \
echo ' memset((char * volatile)page, 8, PAGE_SIZE);'; \
echo ' memset((char * volatile)buffer, 8, sizeof(buffer));'; \
echo ' memcpy((void * volatile)p, buffer, sizeof(buffer));'; \
echo ' cmpxchg((u32 * volatile)&u, 0, 8);'; \
echo ' WARN_ON(n == 0xdeadbeef);'; \
echo '}'
$(obj)/undefsyms_base.c: FORCE
$(call filechk,undefsyms_base)
clean-files += undefsyms_base.c
$(obj)/undefsyms_base.o: $(obj)/undefsyms_base.c
# Basic compiler and tooling-generated symbols that can safely be left
# undefined. Ensure KASAN is enabled to avoid logic that may disable
# FORTIFY_SOURCE when KASAN is not enabled. undefsyms_base.o does not
# automatically get KASAN flags because it is not linked into vmlinux.
targets += undefsyms_base.o
# Ensure KASAN is enabled to avoid logic that may disable FORTIFY_SOURCE when
# KASAN is not enabled. undefsyms_base.o does not automatically get KASAN flags
# because it is not linked into vmlinux.
KASAN_SANITIZE_undefsyms_base.o := y
UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __x86_indirect_thunk \

View File

@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-2.0
/*
* simple_ring_buffer is used by the pKVM hypervisor which does not have access
* to all kernel symbols. Whatever is undefined when compiling this file is
* compiler and tooling-generated symbols that can safely be ignored for
* simple_ring_buffer.
*/
#include <linux/atomic.h>
#include <linux/string.h>
#include <asm/page.h>
void undefsyms_base(void *p, int n);
static char page[PAGE_SIZE] __aligned(PAGE_SIZE);
void undefsyms_base(void *p, int n)
{
char buffer[256] = { 0 };
u32 u = 0;
memset((char * volatile)page, 8, PAGE_SIZE);
memset((char * volatile)buffer, 8, sizeof(buffer));
memcpy((void * volatile)p, buffer, sizeof(buffer));
cmpxchg((u32 * volatile)&u, 0, 8);
WARN_ON(n == 0xdeadbeef);
}