Re: [PATCH v2 11/20] objtool: Detect code coverage instrumentation in noinstr code

From: Sasha Levin

Date: Thu Nov 12 2026 - 08:18:51 EST


On Wed, Nov 11, 2026 at 10:23:41PM -0800, Josh Poimboeuf wrote:
>What exactly is the problem with noinstr code incrementing counters
>inline?

The counter is a memory write, and a memory write can trap. In noinstr
code that can happen before we're ready to take another exception.

With GCOV_PROFILE_ALL today, exc_debug_kernel() bumps a counter before
it clears DR7. Set a watchpoint on that counter and the next kernel #DB
never returns, it just keeps re-entering the handler. I tried it on
v7.4-rc1 in a VM and it hangs.

noinstr is already supposed to keep these out, it has had __no_profile
for years. But that doesn't cover what gets inlined into it, and nothing
checks. This patch adds the check.

--
Thanks,
Sasha