[PATCH v3 11/21] objtool: Allow empty alternatives

Josh Poimboeuf jpoimboe at kernel.org
Fri Aug 7 17:11:31 PDT 2026


On Fri, Aug 07, 2026 at 04:40:34PM -0700, Josh Poimboeuf wrote:
> On Wed, May 13, 2026 at 09:37:11AM +0200, Peter Zijlstra wrote:
> > On Tue, May 12, 2026 at 08:33:45PM -0700, Josh Poimboeuf wrote:
> > > arm64 can have empty alternatives, which are effectively no-ops.  Ignore
> > > them.  While at it, fix a memory leak.
> > 
> > How does this happen?
> 
> Yeah, that commit log sucks...
> 
> The case I stumbled on was the dcache_by_myline_op_nosync macro:
> 
> alternative_if ARM64_WORKAROUND_4311569
> 	.ifnc	\op, cvau
> 	mov	\start, \tmp
> 	mov	\tmp, xzr
> 	cbnz	\start, .Ldcache_op\@
> 	.endif
> alternative_else_nop_endif
> 
> That's actually a bit weird, the .ifnc should probably be outside the
> alternative_if.  Let me try fixing that instead.

I'll probably drop the above patch (leaving empty alternatives as a hard
error) and replace it with this one:

commit 5dd83bdddff38f4df2829b05f876e57215b2e850
Author: Josh Poimboeuf <jpoimboe at kernel.org>
Date:   Fri Aug 7 16:41:10 2026 -0700

    arm64: Remove unnecessary empty alternatives
    
    The code in arch/arm64/mm/cache.S creates three empty alternatives, all
    from calling the dcache_by_myline_op_nosync asm macro.  If \op == cvau,
    it creates an empty alternative for ARM64_WORKAROUND_4311569.
    
    Since orig_len == 0, the alternative patching code mostly ignores it,
    though it does do an unnecessary clean_dcache_range_nopatch().  It also
    triggers an objtool error ("empty alternative entry").
    
    Clean it up by moving the .ifnc check outside the alternative emit.
    
    Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>

diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index effae53e9739d..6e059efced5bb 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -404,13 +404,13 @@ alternative_else_nop_endif
 	add	\start, \start, \linesz
 	cmp	\start, \end
 	b.lo	.Ldcache_op\@
-alternative_if ARM64_WORKAROUND_4311569
 	.ifnc	\op, cvau
+alternative_if ARM64_WORKAROUND_4311569
 	mov	\start, \tmp
 	mov	\tmp, xzr
 	cbnz	\start, .Ldcache_op\@
-	.endif
 alternative_else_nop_endif
+	.endif
 
 	_cond_uaccess_extable .Ldcache_op\@, \fixup
 	.endm



More information about the linux-arm-kernel mailing list