From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27D3B38B152 for ; Thu, 12 Mar 2026 08:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773305721; cv=none; b=UJnfDk+jUs3vRa3KxzroAnxOS7KOcqGAo0Jy8VLETz6/quYMqTF1PI4KvXV3YeA0mCWUL8XKB2rEuP9BX6Oh740EKa0tFm+m49XR+volCqcKAR1A+LyzdRyghbl7fl68ESHgkIYDtCHK1kQwx9ie5lbvyW0BvearHnM36MR9jwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773305721; c=relaxed/simple; bh=/3vdoFQ6xBKuMKdZ3izMz8e4s2bhLnzcXpE/ttaYt/A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S1Z50xcT+RsCsaEKDaQqdXMxjcTtuKBaA85WtYaZX/L+Rtzwotvu1DpU5+FCoZD/Fo8mUj95P8Y9MnnvXX0j4v9Y1jiGUgtadJF5BlPK5kk0VYB8Q/XwhtZ+gX9rVwlwJxZQwKUqxEsMVkFZ6SXwbqZuNHds3RJtKXGDO4W+VbU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BH3y5nSO; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BH3y5nSO" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4853c3c2fe7so3723345e9.0 for ; Thu, 12 Mar 2026 01:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773305718; x=1773910518; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6m3iVjAJ3GnbX16/A8yr0Uv8IZ6KsZjKuUcZqEbIVJA=; b=BH3y5nSO5KO/7vOPjLzlV3m8QGL6SAmVjL92ZGy1G7w+Td+CvWmFYgjtlXQ9KvF+id ymsgIlJFozYS+qQ/5cKwjX0MGKrrX85NuNK2clWszUgnSOQ8esOGfoWJsOXjHFLrQWj2 4zTtJ7SzMqdwaLd7debnGmXO8sYs1cSn+CYMVpu+VWZbTqj+iuL39GM4J33qDw00y2U8 JDnGfjwEirOQtBF7KyYzQ6rNYIKHBCluVAkqOtTr0dQW3Sh6+7TK9clZ+z/ugIAYU1U0 8xcGFP2mR0oCeEP80CjB56orV0Hs5uYTgfcE0LeXizFZbIOM4olYiPveNNXeDCzTFVc4 8pFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773305718; x=1773910518; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6m3iVjAJ3GnbX16/A8yr0Uv8IZ6KsZjKuUcZqEbIVJA=; b=PcxAKrDjbHFD8LOEraRKB+iVRN00b+efu8SD2WPr88cgnV/wjmvdjEROAUxOFakbJy 9LbRJ8dvV0LIEBZYEVsfNiT+IbvIluXUdoqjAwq5WrldGRdNyOnbkxRaywxnfnN1WEfi 52gFozDunscvNs1hLlHCQNsgFTQJgw6xc6B2fDXca6LKVlk8Dk6I0yxB5VwaHXKjkzZZ euZUF/Fot0LvzsJuaii/EdX+cmPBYDzv47glHRFE88HsvWca6tfR/3n8b+isyqgzfus8 Gc9pREC6bQR2VL4JIJUD4+HHD9y6RmOPOIKZbiy+REeU0ZQzJXVnaZaChQ/m9dPOxeuK LrYw== X-Forwarded-Encrypted: i=1; AJvYcCXz8OcBXLuoLtTrhAZmdD0GgKVpHxLMOVjzYTUas+Bm3cO7UmPR3WUuiGlkIKm192+QnZOpb7i7G/vyDUc=@vger.kernel.org X-Gm-Message-State: AOJu0YxsuqNuEWCKTQ+DxXghQAl77zFEZdKjwjOimOFnv7DKftIMmI/L Cry7JG7lnN4Udyt46dr6YV4ZfIKGqnHVvyQzOcxecckJQBWYhPgx41AKZtXicjMlZdv2k7Ze4gJ ArAVHlarD X-Gm-Gg: ATEYQzxHEI3EJ9PiEdtk5UKN13WZGodl3e488GksKqPHlpfz/DP+afOP/zVzkR5l/ht kpH+s7eE+3gmMVvOCyyrBBpujILsTBHrmT85WEvq5X3+WipNLnKLsSGnQwmX1wLO3WfMXGVv2mc b6sLO4aXCa8Ch5uHdC5T4cHOlQ1OdiJ5J0kuM60zELnSqhVTKGLtiZ8+TS6YA/AUOHtauE+kGHZ PSPIGfULRvXhJf8TcsOMG26rYTtOpIlJBDuzt9jCJwzhFmjj//dA4WfjUEZt4k48dBb9cpvr+l2 MhYMh5016soECN8utBYbPFjcU6NbZJLNx+rQ8oAGtx723iGwkx/OvwrGXBclndNuFn+74GbOvcf M54vMKwH66LduKwucpTD2bIH6bDK2Vo5Ctqhj6f/vvSTdtrDjwiiv2bnX3c7FEup8xVgZGGwvMw DVv5Ve+SBTehu34sfSdSI7n9JFfnyj9KatBhP8/fjWEPrg41wKRdBfIpqUJ5NsKqIcUuk= X-Received: by 2002:a05:600c:4455:b0:485:3e6c:aa84 with SMTP id 5b1f17b1804b1-4854b13b3cbmr83483945e9.33.1773305718060; Thu, 12 Mar 2026 01:55:18 -0700 (PDT) Received: from google.com (198.115.140.34.bc.googleusercontent.com. [34.140.115.198]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4854b47145dsm110869815e9.0.2026.03.12.01.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 01:55:17 -0700 (PDT) Date: Thu, 12 Mar 2026 08:55:14 +0000 From: Vincent Donnefort To: Nathan Chancellor Cc: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jstultz@google.com, qperret@google.com, will@kernel.org, aneesh.kumar@kernel.org, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v14 18/30] tracing: Check for undefined symbols in simple_ring_buffer Message-ID: References: <20260309162516.2623589-1-vdonnefort@google.com> <20260309162516.2623589-19-vdonnefort@google.com> <20260311221816.GA316631@ax162> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260311221816.GA316631@ax162> On Wed, Mar 11, 2026 at 03:18:16PM -0700, Nathan Chancellor wrote: > Hi Vincent, > > On Mon, Mar 09, 2026 at 04:25:04PM +0000, Vincent Donnefort wrote: > > The simple_ring_buffer implementation must remain simple enough to be > > used by the pKVM hypervisor. Prevent the object build if unresolved > > symbols are found. > > > > Reviewed-by: Steven Rostedt (Google) > > Signed-off-by: Vincent Donnefort > > > > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > > index d106beca8d7f..3182e1bc1cf7 100644 > > --- a/kernel/trace/Makefile > > +++ b/kernel/trace/Makefile > > @@ -132,4 +132,20 @@ 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. > > +# > > +UNDEFINED_ALLOWLIST := memset alt_cb_patch_nops __x86 __ubsan __asan __kasan __gcov __aeabi_unwind > > +UNDEFINED_ALLOWLIST += __stack_chk_fail stackleak_track_stack __ref_stack __sanitizer > > +UNDEFINED_ALLOWLIST := $(addprefix -e , $(UNDEFINED_ALLOWLIST)) > > + > > +quiet_cmd_check_undefined = NM $< > > + cmd_check_undefined = test -z "`$(NM) -u $< | grep -v $(UNDEFINED_ALLOWLIST)`" > > This check triggers when building allmodconfig targeting arm, arm64, > powerpc, and x86_64 (at least, I did not test more at the moment) with > clang. If this is a hard failure, this really needs to print something > out to the developer/user to help them debug off the bat, versus having > to manually dig the $(NM) command out from the .cmd file or V=1. I came > up with > > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > index 3182e1bc1cf7..c725b06876bc 100644 > --- a/kernel/trace/Makefile > +++ b/kernel/trace/Makefile > @@ -141,7 +141,13 @@ UNDEFINED_ALLOWLIST += __stack_chk_fail stackleak_track_stack __ref_stack __sani > UNDEFINED_ALLOWLIST := $(addprefix -e , $(UNDEFINED_ALLOWLIST)) > > quiet_cmd_check_undefined = NM $< > - cmd_check_undefined = test -z "`$(NM) -u $< | grep -v $(UNDEFINED_ALLOWLIST)`" > + cmd_check_undefined = \ > + undefsyms=$$($(NM) -u $< | grep -v $(UNDEFINED_ALLOWLIST) || true); \ > + if [ -n "$$undefsyms" ]; then \ > + echo "Unexpected symbols in $<:" >&2; \ > + echo "$$undefsyms" >&2; \ > + false; \ > + fi > > $(obj)/%.o.checked: $(obj)/%.o FORCE > $(call if_changed,check_undefined) > -- > > which prints > > Unexpected symbols in kernel/trace/simple_ring_buffer.o: > U llvm_gcda_emit_arcs > U llvm_gcda_emit_function > U llvm_gcda_end_file > U llvm_gcda_start_file > U llvm_gcda_summary_info > U llvm_gcov_init > > for arm64, which makes sense since these are LLVM specific GCOV symbols, > so they should probably get the same treatment as the other ones: > > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > index c725b06876bc..d464e3aa5bdd 100644 > --- a/kernel/trace/Makefile > +++ b/kernel/trace/Makefile > @@ -136,8 +136,8 @@ 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. > # > -UNDEFINED_ALLOWLIST := memset alt_cb_patch_nops __x86 __ubsan __asan __kasan __gcov __aeabi_unwind > -UNDEFINED_ALLOWLIST += __stack_chk_fail stackleak_track_stack __ref_stack __sanitizer > +UNDEFINED_ALLOWLIST := memset alt_cb_patch_nops __x86 __ubsan __asan __kasan __gcov llvm_gcda llvm_gcov > +UNDEFINED_ALLOWLIST += __aeabi_unwind __stack_chk_fail stackleak_track_stack __ref_stack __sanitizer > UNDEFINED_ALLOWLIST := $(addprefix -e , $(UNDEFINED_ALLOWLIST)) > > quiet_cmd_check_undefined = NM $< > -- > > For x86_64, I see > > Unexpected symbols in kernel/trace/simple_ring_buffer.o: > U __clear_pages_unrolled > U __memmove > U copy_page > > which comes from the use of KCFI_ADDRESSABLE(), since allmodconfig has > CONFIG_CFI=y. > > For powerpc (with both clang and GCC), I see > > Unexpected symbols in kernel/trace/simple_ring_buffer.o: > U .TOC. > > For arm (with both clang and GCC), I see > > Unexpected symbols in kernel/trace/simple_ring_buffer.o: > U __stack_chk_guard > U warn_slowpath_fmt > > Presumably adding all of those should be fine as well? > > diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile > index d464e3aa5bdd..4f120cb8c79c 100644 > --- a/kernel/trace/Makefile > +++ b/kernel/trace/Makefile > @@ -137,7 +137,8 @@ obj-$(CONFIG_TRACE_REMOTE_TEST) += remote_test.o > # to all kernel symbols. Fail the build if forbidden symbols are found. > # > UNDEFINED_ALLOWLIST := memset alt_cb_patch_nops __x86 __ubsan __asan __kasan __gcov llvm_gcda llvm_gcov > -UNDEFINED_ALLOWLIST += __aeabi_unwind __stack_chk_fail stackleak_track_stack __ref_stack __sanitizer > +UNDEFINED_ALLOWLIST += __aeabi_unwind __stack_chk_fail __stack_chk_guard stackleak_track_stack __ref_stack __sanitizer > +UNDEFINED_ALLOWLIST += \.TOC\. __clear_pages_unrolled __memmove copy_page warn_slowpath_fmt > UNDEFINED_ALLOWLIST := $(addprefix -e , $(UNDEFINED_ALLOWLIST)) > > quiet_cmd_check_undefined = NM $< > -- > > I don't mind sending a series for these, I just wanted to make sure I > was reasoning about everything correctly. Yes this is all fine. If you have something already, please send it. Meanwhile, I'll try something a bit more durable. Thanks, Vincent > > Cheers, > Nathan