public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	torvalds@linux-foundation.org, rostedt@goodmis.org,
	Marc Zyngier <maz@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
Date: Tue, 21 Apr 2026 14:51:35 -0700	[thread overview]
Message-ID: <20260421215135.GA367904@ax162> (raw)
In-Reply-To: <20260421100455.324333-1-pbonzini@redhat.com>

On Tue, Apr 21, 2026 at 11:04:55AM +0100, Paolo Bonzini wrote:
> The code to autogenerate undefsyms_base.c in the Makefile is larger
> than the file itself.
> 
> Remove the "echo" indirection that creates the file, which keeps
> the build system sane and makes it much easier to edit it if/when
> new situations arrive.
> 
> Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Yeah, I don't really know how I did not see this originally :/ tunnel
vision is real I suppose.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  kernel/trace/.gitignore       |  1 -
>  kernel/trace/Makefile         | 35 ++++-------------------------------
>  kernel/trace/undefsyms_base.c | 28 ++++++++++++++++++++++++++++
>  3 files changed, 32 insertions(+), 32 deletions(-)
>  delete mode 100644 kernel/trace/.gitignore
>  create mode 100644 kernel/trace/undefsyms_base.c
> 
> diff --git a/kernel/trace/.gitignore b/kernel/trace/.gitignore
> deleted file mode 100644
> index 6adbb09d6deb..000000000000
> --- a/kernel/trace/.gitignore
> +++ /dev/null
> @@ -1 +0,0 @@
> -/undefsyms_base.c
> diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
> index 4d4229e5eec4..1decdce8cbef 100644
> --- a/kernel/trace/Makefile
> +++ b/kernel/trace/Makefile
> @@ -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 \
> diff --git a/kernel/trace/undefsyms_base.c b/kernel/trace/undefsyms_base.c
> new file mode 100644
> index 000000000000..e65baf58e6ff
> --- /dev/null
> +++ b/kernel/trace/undefsyms_base.c
> @@ -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);
> +}
> -- 
> 2.53.0
> 

      parent reply	other threads:[~2026-04-21 21:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 10:04 [PATCH] kernel: trace: do not generate undefsyms_base.c Paolo Bonzini
2026-04-21 14:02 ` Steven Rostedt
2026-04-21 14:16   ` Marc Zyngier
2026-04-21 14:21     ` Paolo Bonzini
2026-04-21 19:56       ` Steven Rostedt
2026-04-21 21:51 ` Nathan Chancellor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260421215135.GA367904@ax162 \
    --to=nathan@kernel.org \
    --cc=arnd@arndb.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox