* [PATCH] arm64/mm: Fix annotated branch unbootable kernel
@ 2025-12-31 12:44 Breno Leitao
2026-01-05 21:15 ` Will Deacon
0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2025-12-31 12:44 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland, Laura Abbott
Cc: linux-arm-kernel, linux-kernel, linux-trace-kernel,
Steven Rostedt, Masami Hiramatsu, puranjay, usamaarif642,
kernel-team, stable, Breno Leitao
The arm64 kernel doesn't boot with annotated branches
(PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.
Bisecting it, I found that disabling branch profiling in arch/arm64/mm
solved the problem. Narrowing down a bit further, I found that
physaddr.c is the file that needs to have branch profiling disabled to
get the machine to boot.
I suspect that it might invoke some ftrace helper very early in the boot
process and ftrace is still not enabled(!?).
Disable branch profiling for physaddr.o to allow booting an arm64
machine with CONFIG_PROFILE_ANNOTATED_BRANCHES and
CONFIG_DEBUG_VIRTUAL together.
Cc: stable@vger.kernel.org
Fixes: ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Another approach is to disable profiling on all arch/arm64 code, similarly to
x86, where DISABLE_BRANCH_PROFILING is called for all arch/x86 code. See
commit 2cbb20b008dba ("tracing: Disable branch profiling in noinstr
code").
---
arch/arm64/mm/Makefile | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/mm/Makefile b/arch/arm64/mm/Makefile
index c26489cf96cd..8bfe2451ea26 100644
--- a/arch/arm64/mm/Makefile
+++ b/arch/arm64/mm/Makefile
@@ -14,5 +14,10 @@ obj-$(CONFIG_ARM64_MTE) += mteswap.o
obj-$(CONFIG_ARM64_GCS) += gcs.o
KASAN_SANITIZE_physaddr.o += n
+# Branch profiling isn't noinstr-safe
+ifdef CONFIG_TRACE_BRANCH_PROFILING
+CFLAGS_physaddr.o += -DDISABLE_BRANCH_PROFILING
+endif
+
obj-$(CONFIG_KASAN) += kasan_init.o
KASAN_SANITIZE_kasan_init.o := n
---
base-commit: c8ebd433459bcbf068682b09544e830acd7ed222
change-id: 20251231-annotated-75de3f33cd7b
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64/mm: Fix annotated branch unbootable kernel
2025-12-31 12:44 [PATCH] arm64/mm: Fix annotated branch unbootable kernel Breno Leitao
@ 2026-01-05 21:15 ` Will Deacon
2026-01-09 19:47 ` Steven Rostedt
2026-01-09 19:50 ` Steven Rostedt
0 siblings, 2 replies; 6+ messages in thread
From: Will Deacon @ 2026-01-05 21:15 UTC (permalink / raw)
To: Breno Leitao
Cc: Catalin Marinas, Mark Rutland, Laura Abbott, linux-arm-kernel,
linux-kernel, linux-trace-kernel, Steven Rostedt,
Masami Hiramatsu, puranjay, usamaarif642, kernel-team, stable
On Wed, Dec 31, 2025 at 04:44:05AM -0800, Breno Leitao wrote:
> The arm64 kernel doesn't boot with annotated branches
> (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.
>
> Bisecting it, I found that disabling branch profiling in arch/arm64/mm
> solved the problem. Narrowing down a bit further, I found that
> physaddr.c is the file that needs to have branch profiling disabled to
> get the machine to boot.
>
> I suspect that it might invoke some ftrace helper very early in the boot
> process and ftrace is still not enabled(!?).
>
> Disable branch profiling for physaddr.o to allow booting an arm64
> machine with CONFIG_PROFILE_ANNOTATED_BRANCHES and
> CONFIG_DEBUG_VIRTUAL together.
>
> Cc: stable@vger.kernel.org
> Fixes: ec6d06efb0bac ("arm64: Add support for CONFIG_DEBUG_VIRTUAL")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> Another approach is to disable profiling on all arch/arm64 code, similarly to
> x86, where DISABLE_BRANCH_PROFILING is called for all arch/x86 code. See
> commit 2cbb20b008dba ("tracing: Disable branch profiling in noinstr
> code").
Yes, let's start with arch/arm64/. We know that's safe and then if
somebody wants to make it finer-grained, it's on them to figure out a
way to do it without playing whack-a-mole.
Will
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64/mm: Fix annotated branch unbootable kernel
2026-01-05 21:15 ` Will Deacon
@ 2026-01-09 19:47 ` Steven Rostedt
2026-01-09 19:50 ` Steven Rostedt
1 sibling, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2026-01-09 19:47 UTC (permalink / raw)
To: Will Deacon
Cc: Breno Leitao, Catalin Marinas, Mark Rutland, Laura Abbott,
linux-arm-kernel, linux-kernel, linux-trace-kernel,
Masami Hiramatsu, puranjay, usamaarif642, kernel-team, stable
On Mon, 5 Jan 2026 21:15:40 +0000
Will Deacon <will@kernel.org> wrote:
> > Another approach is to disable profiling on all arch/arm64 code, similarly to
> > x86, where DISABLE_BRANCH_PROFILING is called for all arch/x86 code. See
> > commit 2cbb20b008dba ("tracing: Disable branch profiling in noinstr
> > code").
>
> Yes, let's start with arch/arm64/. We know that's safe and then if
> somebody wants to make it finer-grained, it's on them to figure out a
> way to do it without playing whack-a-mole.
OK, so by adding -DDISABLE_BRANCH_PROFILING to the Makefile configs and for
the files that were audited, could be opt-in?
CFLAGS_REMOVE_<autdit_file>.o = -DDISABLE_BRANCH_PROFILING
And add that for each file that has been fully audited?
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64/mm: Fix annotated branch unbootable kernel
2026-01-05 21:15 ` Will Deacon
2026-01-09 19:47 ` Steven Rostedt
@ 2026-01-09 19:50 ` Steven Rostedt
2026-01-12 9:42 ` Breno Leitao
1 sibling, 1 reply; 6+ messages in thread
From: Steven Rostedt @ 2026-01-09 19:50 UTC (permalink / raw)
To: Will Deacon
Cc: Breno Leitao, Catalin Marinas, Mark Rutland, Laura Abbott,
linux-arm-kernel, linux-kernel, linux-trace-kernel,
Masami Hiramatsu, puranjay, usamaarif642, kernel-team, stable
[ Resending with my kernel.org email, as I received a bunch of messages from gmail saying it's blocking me :-p ]
On Mon, 5 Jan 2026 21:15:40 +0000
Will Deacon <will@kernel.org> wrote:
> > Another approach is to disable profiling on all arch/arm64 code, similarly to
> > x86, where DISABLE_BRANCH_PROFILING is called for all arch/x86 code. See
> > commit 2cbb20b008dba ("tracing: Disable branch profiling in noinstr
> > code").
>
> Yes, let's start with arch/arm64/. We know that's safe and then if
> somebody wants to make it finer-grained, it's on them to figure out a
> way to do it without playing whack-a-mole.
OK, so by adding -DDISABLE_BRANCH_PROFILING to the Makefile configs and for
the files that were audited, could be opt-in?
CFLAGS_REMOVE_<autdit_file>.o = -DDISABLE_BRANCH_PROFILING
And add that for each file that has been fully audited?
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64/mm: Fix annotated branch unbootable kernel
2026-01-09 19:50 ` Steven Rostedt
@ 2026-01-12 9:42 ` Breno Leitao
2026-01-12 15:46 ` Steven Rostedt
0 siblings, 1 reply; 6+ messages in thread
From: Breno Leitao @ 2026-01-12 9:42 UTC (permalink / raw)
To: Steven Rostedt
Cc: Will Deacon, Catalin Marinas, Mark Rutland, Laura Abbott,
linux-arm-kernel, linux-kernel, linux-trace-kernel,
Masami Hiramatsu, puranjay, usamaarif642, kernel-team, stable
Hello Steven,
On Fri, Jan 09, 2026 at 02:50:22PM -0500, Steven Rostedt wrote:
> [ Resending with my kernel.org email, as I received a bunch of messages from gmail saying it's blocking me :-p ]
>
> On Mon, 5 Jan 2026 21:15:40 +0000
> Will Deacon <will@kernel.org> wrote:
>
> > > Another approach is to disable profiling on all arch/arm64 code, similarly to
> > > x86, where DISABLE_BRANCH_PROFILING is called for all arch/x86 code. See
> > > commit 2cbb20b008dba ("tracing: Disable branch profiling in noinstr
> > > code").
> >
> > Yes, let's start with arch/arm64/. We know that's safe and then if
> > somebody wants to make it finer-grained, it's on them to figure out a
> > way to do it without playing whack-a-mole.
>
> OK, so by adding -DDISABLE_BRANCH_PROFILING to the Makefile configs and for
> the files that were audited, could be opt-in?
How to do the audit in this case? I suppose we want to disable branch
profiling for files that have any function that would eventually call
noinstr functions, right?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] arm64/mm: Fix annotated branch unbootable kernel
2026-01-12 9:42 ` Breno Leitao
@ 2026-01-12 15:46 ` Steven Rostedt
0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2026-01-12 15:46 UTC (permalink / raw)
To: Breno Leitao
Cc: Will Deacon, Catalin Marinas, Mark Rutland, Laura Abbott,
linux-arm-kernel, linux-kernel, linux-trace-kernel,
Masami Hiramatsu, puranjay, usamaarif642, kernel-team, stable
On Mon, 12 Jan 2026 01:42:47 -0800
Breno Leitao <leitao@debian.org> wrote:
> > OK, so by adding -DDISABLE_BRANCH_PROFILING to the Makefile configs and for
> > the files that were audited, could be opt-in?
>
> How to do the audit in this case? I suppose we want to disable branch
> profiling for files that have any function that would eventually call
> noinstr functions, right?
IIUC, noinstr is mostly used for the transition between user space and the
kernel (interrupts, exceptions, syscalls, etc). There shouldn't be any
random calls to noinstr functions unless it's going into user space, right?
-- Steve
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-12 15:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-31 12:44 [PATCH] arm64/mm: Fix annotated branch unbootable kernel Breno Leitao
2026-01-05 21:15 ` Will Deacon
2026-01-09 19:47 ` Steven Rostedt
2026-01-09 19:50 ` Steven Rostedt
2026-01-12 9:42 ` Breno Leitao
2026-01-12 15:46 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox