public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel: trace: do not generate undefsyms_base.c
@ 2026-04-21 10:04 Paolo Bonzini
  2026-04-21 14:02 ` Steven Rostedt
  2026-04-21 21:51 ` Nathan Chancellor
  0 siblings, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2026-04-21 10:04 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: torvalds, rostedt, Marc Zyngier, Arnd Bergmann, Nathan Chancellor,
	linux-trace-kernel

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
  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 21:51 ` Nathan Chancellor
  1 sibling, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2026-04-21 14:02 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: linux-kernel, kvm, torvalds, Marc Zyngier, Arnd Bergmann,
	Nathan Chancellor, linux-trace-kernel

On Tue, 21 Apr 2026 11:04:55 +0100
Paolo Bonzini <pbonzini@redhat.com> 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>

Marc beat you to it by a few minutes ;-)

  https://lore.kernel.org/all/20260421095446.2951646-1-maz@kernel.org/

Although he didn't Cc linux-trace-kernel@vger.kernel.org :-p

But anyway, it ended up in my internal Patchwork. I'll take his as they are
both pretty much the same patch.

Thanks,

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
  2026-04-21 14:02 ` Steven Rostedt
@ 2026-04-21 14:16   ` Marc Zyngier
  2026-04-21 14:21     ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Zyngier @ 2026-04-21 14:16 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Paolo Bonzini, linux-kernel, kvm, torvalds, Arnd Bergmann,
	Nathan Chancellor, linux-trace-kernel

On Tue, 21 Apr 2026 15:02:09 +0100,
Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Tue, 21 Apr 2026 11:04:55 +0100
> Paolo Bonzini <pbonzini@redhat.com> 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>
> 
> Marc beat you to it by a few minutes ;-)
> 
>   https://lore.kernel.org/all/20260421095446.2951646-1-maz@kernel.org/
> 
> Although he didn't Cc linux-trace-kernel@vger.kernel.org :-p
> 
> But anyway, it ended up in my internal Patchwork. I'll take his as they are
> both pretty much the same patch.

On the other hand, Paolo's patch has the SPDX tag on the new file,
which I forgot to add. Your call, anyway.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
  2026-04-21 14:16   ` Marc Zyngier
@ 2026-04-21 14:21     ` Paolo Bonzini
  2026-04-21 19:56       ` Steven Rostedt
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2026-04-21 14:21 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Steven Rostedt, linux-kernel, kvm, torvalds, Arnd Bergmann,
	Nathan Chancellor, linux-trace-kernel

On Tue, Apr 21, 2026 at 3:18 PM Marc Zyngier <maz@kernel.org> wrote:
> On Tue, 21 Apr 2026 15:02:09 +0100, Steven Rostedt <rostedt@goodmis.org> wrote:
> > Marc beat you to it by a few minutes ;-)
> >
> >   https://lore.kernel.org/all/20260421095446.2951646-1-maz@kernel.org/
> >
> > Although he didn't Cc linux-trace-kernel@vger.kernel.org :-p
> >
> > But anyway, it ended up in my internal Patchwork. I'll take his as they are
> > both pretty much the same patch.
>
> On the other hand, Paolo's patch has the SPDX tag on the new file,
> which I forgot to add. Your call, anyway.

Yeah if you want to get the best of both worlds, take the commit
message from Marc's and the code from mine; he has more complete
trailers whereas I have slightly cleaner formatting and more comments.
But otherwise it's not a big deal.

Paolo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
  2026-04-21 14:21     ` Paolo Bonzini
@ 2026-04-21 19:56       ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2026-04-21 19:56 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Marc Zyngier, linux-kernel, kvm, torvalds, Arnd Bergmann,
	Nathan Chancellor, linux-trace-kernel

On Tue, 21 Apr 2026 15:21:19 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On Tue, Apr 21, 2026 at 3:18 PM Marc Zyngier <maz@kernel.org> wrote:
> > On Tue, 21 Apr 2026 15:02:09 +0100, Steven Rostedt <rostedt@goodmis.org> wrote:  
> > > Marc beat you to it by a few minutes ;-)
> > >
> > >   https://lore.kernel.org/all/20260421095446.2951646-1-maz@kernel.org/
> > >
> > > Although he didn't Cc linux-trace-kernel@vger.kernel.org :-p
> > >
> > > But anyway, it ended up in my internal Patchwork. I'll take his as they are
> > > both pretty much the same patch.  
> >
> > On the other hand, Paolo's patch has the SPDX tag on the new file,
> > which I forgot to add. Your call, anyway.  

Ah, OK. I'll take Paolo's.

> 
> Yeah if you want to get the best of both worlds, take the commit
> message from Marc's and the code from mine; he has more complete
> trailers whereas I have slightly cleaner formatting and more comments.
> But otherwise it's not a big deal.

I'll update the subject and change log slightly, but otherwise, it's your
patch.

-- Steve


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel: trace: do not generate undefsyms_base.c
  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 21:51 ` Nathan Chancellor
  1 sibling, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2026-04-21 21:51 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: linux-kernel, kvm, torvalds, rostedt, Marc Zyngier, Arnd Bergmann,
	linux-trace-kernel

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
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-21 21:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox