From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C76633A7F47; Tue, 17 Mar 2026 22:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787892; cv=none; b=WMXA7yfz9WzDq8H6IjnntmRdDfpZNvoNxLCws+bvTJLBb/YMta9TFp3RQ7KoooOnwjbtyjgkNvhdNGxZkm3DwQkr36XeKnksrF6P8z+SyVf2f8+mJxdtTN9cViRG3vYr3qFf6MNKaeKme9ZukTB4uCXbCMuZAA+DzKoiRlldLvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787892; c=relaxed/simple; bh=sgRjFM7xWFg9L5n1fihixm+C5Qbm0Ax6cGt49J083JI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sftcsAuwLhxDzZvYTCV47E1GR1qRszm9l5+TKEL7Gwsr6y8le/scrLtMdxS0N2/Pj5dul/aEpW0eiP7C3jcwJJEFE5opaIJb/iC27XmI6XNL/gwZ0FAQuks7DnCmJoCeM2jujwjPsrZGOYOFruJbrtha+2moQCeLQWT13JVXT5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k/glGm01; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="k/glGm01" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D2F0C2BCB3; Tue, 17 Mar 2026 22:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787892; bh=sgRjFM7xWFg9L5n1fihixm+C5Qbm0Ax6cGt49J083JI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k/glGm01cZOY8IhazlamaSFb++2gB16akWLwpdr+xDiQlDwhFBMGEU+K/8zBRuBlC E3nJxjLBpP4w9TPa2qn0+fQbZdGcp+F/8gAq9AGPW60tQaMAONlVXt/uBSXnmlXS+L tkPS3KC48AHcJwsfN1+2IhpieaQv8xJN3jDq6D47+DEYYYnVtemNLlENMmwtTN8mTr uYpB+UFZ9H2OEZrWlCtfUYzDP8txjmPEzdJgFLb1mAcJgyU56qpNRmHCFgWI4b9kBH qP2VJq8c4xLG6iEn9WyvagAuVOJ3K+GnjBxedvNJgtm3e9xgDIhRdvuATTHneM+y/i kJNmpFfWVDzqw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 01/12] arm64: Annotate intra-function calls Date: Tue, 17 Mar 2026 15:51:01 -0700 Message-ID: <3a9decf6cc0ad8ae707c3b4df814b92b3e7f85d8.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for enabling objtool on arm64, annotate intra-function calls. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- arch/arm64/kernel/entry.S | 2 ++ arch/arm64/kernel/proton-pack.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index f8018b5c1f9a..cf808bb2abc0 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -10,6 +10,7 @@ #include #include #include +#include =20 #include #include @@ -707,6 +708,7 @@ alternative_else_nop_endif * entry onto the return stack and using a RET instruction to * enter the full-fat kernel vectors. */ + ANNOTATE_INTRA_FUNCTION_CALL bl 2f b . 2: diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pac= k.c index b3801f532b10..b63887a1b823 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 #include #include @@ -245,11 +246,12 @@ static noinstr void qcom_link_stack_sanitisation(void) { u64 tmp; =20 - asm volatile("mov %0, x30 \n" - ".rept 16 \n" - "bl . + 4 \n" - ".endr \n" - "mov x30, %0 \n" + asm volatile("mov %0, x30 \n" + ".rept 16 \n" + ANNOTATE_INTRA_FUNCTION_CALL " \n" + "bl . + 4 \n" + ".endr \n" + "mov x30, %0 \n" : "=3D&r" (tmp)); } =20 --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FF703E6DFE; Tue, 17 Mar 2026 22:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787893; cv=none; b=hK8TOpyrqQ6ZeiRs4lwQMJtTkXuwhHVXYfsXBMRZsgKq4aBRsOllWjBBqc5RLes19w+WwUhdev1eAsjTYw/cU3McjdZ8iv11n07Nai5+l5gWXV0su6/W7B7lcoRGjAskKsI+RPXBiEWfnJOQRerFy9ZWp0zO1k5e08FgUDcwT4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787893; c=relaxed/simple; bh=W1WxiHbuvXgUL/GnkhyKUEAdymsHY0Opyqu1xOqSq/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TKei3Phd4ZXatsuYoIMKmrN8KWfI9wcgz8+f9umYs+sbaz8sNKfKXK+IkaFKd7tE1oWm6NoFvzcMAtz4N/Qw6ladBDL2ctT8ruIxvyVh9A6PxSbNbjV2tkHV9QvW07CdqQDp6xVAUYNfJtUVFoYTb1liPihbAe2q7Wc8X6af25o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V7ngc1os; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V7ngc1os" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD522C4CEF7; Tue, 17 Mar 2026 22:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787893; bh=W1WxiHbuvXgUL/GnkhyKUEAdymsHY0Opyqu1xOqSq/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7ngc1osjOIco43BFhUtLp/DIzLkOHFDFV+nx47wIDWCw6gIbjjSTRd6CLV8NdBMa 6l67mCiRx8lBOK5RN4xfJELW5Qf4FSoabnC0rua2yK+TL4H5Hpk0WMwQ5a15Jw6woj rkV9WKrQcr3Yvu+VWEDLr5iaxIaiEzlWvrVdN02BFPnasdHFdJDThvzsi6bYvLI988 YfmgRPIJ1ugL7fCiNCL0e5JIVj+A+7lb/7kYGeheud3n8CtNUu+npm7sc0FztMfOQ/ u2ZIcn7gnkMQ8ZyGI830V2JDgb0d61Xpbl0QJUU3Z2950Fz7yvAdHPMiU/y5PnVzV0 nVWfXKoXBZqPA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 02/12] arm64: head: Move boot header to .head.data Date: Tue, 17 Mar 2026 15:51:02 -0700 Message-ID: <63e5cf00cb5636d1315754a264ff90175820ec65.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The arm64 boot header is mostly data. Move it to a data section to prevent objtool and other tools from trying to disassemble it. The final linked result is the same. Acked-by: Song Liu --- arch/arm64/kernel/head.S | 2 +- include/asm-generic/vmlinux.lds.h | 2 +- include/linux/init.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 87a822e5c4ca..0681c6e50859 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -54,7 +54,7 @@ * that are useful before the MMU is enabled. The allocations are described * in the entry routines. */ - __HEAD + __HEADDATA /* * DO NOT MODIFY. Image header expected by Linux boot-loaders. */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 1e1580febe4b..f82f170a97eb 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -663,7 +663,7 @@ __static_call_text_end =3D .; =20 /* Section used for early init (in .S files) */ -#define HEAD_TEXT KEEP(*(.head.text)) +#define HEAD_TEXT KEEP(*(.head.data .head.text)) =20 #define HEAD_TEXT_SECTION \ .head.text : AT(ADDR(.head.text) - LOAD_OFFSET) { \ diff --git a/include/linux/init.h b/include/linux/init.h index 40331923b9f4..91e16f3205e2 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -90,6 +90,7 @@ =20 /* For assembly routines */ #define __HEAD .section ".head.text","ax" +#define __HEADDATA .section ".head.data","aw" #define __INIT .section ".init.text","ax" #define __FINIT .previous =20 --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 119A13EBF2E; Tue, 17 Mar 2026 22:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787894; cv=none; b=YZLt6PoihB8GBlolRyWNIn2pxPrN2UOkk8IhwvlguML7kk4QuKGFchb+ZqO3QX6yAnRg5P7k0Wlqvu0ZjKvFyt1MIeMljjnaEhXqjJ+LtDhW6RuwmKSFvOAq30YDEHo/ZFk5I6jna/Huir/8OI5n174i/NedTdEP1pvrZZ/AEmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787894; c=relaxed/simple; bh=XnVKZDr9XXzDhXGeIbv+VTsNo7kWr53t2t9B4bwhIjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gd98A/ertk9IphXNRjeDK2bdl1hDOgRS5xTRapIgl0xKsvt422MG9/OfEXt5QKc57k5i0xcRfsNz3ksLfDAa8c6RAoTXnth+sKRtKmNN96A4yFxGrJcAsmmkiX2gWYGk2Qcv14eNF+pn8x0g9ZuRNjg19zwN779tiYSGQgGFu/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jIXLFcFb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jIXLFcFb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C6F1C19425; Tue, 17 Mar 2026 22:51:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787893; bh=XnVKZDr9XXzDhXGeIbv+VTsNo7kWr53t2t9B4bwhIjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jIXLFcFbAMraX2atbcW3r9Z+fs4ZD/daKD8AiV3tBTBKJ1S50NTymLNUxoszu+aLq kqTLzEm7y//QxjgVbCsaQO8IxziAFguXcL2rNdNo/gaTNkDq9sG3hguBy6NADJgEP2 D69XncXOdQ9oMSsDXXkbS38LaQzJGchph9+WgLAGf9GdoGO1EOVRh3ke0CqflRSWnB yapgHfMLJDPcKDFO8lWba2fVQVYqP1DbzSatQ31xhZVCoYHhvSZry6tqy+M/A6pRiY UJaSR73MsQOgP9ueUx8Bvio4GHNWHeUSoWlnBuXxwmEoAjbvS57p9A0c9K0PAkr/RG 0QyVKkZYbsSUw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 03/12] arm64: Fix EFI linking with -fdata-sections Date: Tue, 17 Mar 2026 15:51:03 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When building with func-fdata-sections, the .init.bss section gets split up into a bunch of .init.bss. sections. Make sure they get linked into .init.data. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- arch/arm64/kernel/vmlinux.lds.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.ld= s.S index 2964aad0362e..f825e6a26918 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -269,7 +269,7 @@ SECTIONS INIT_CALLS CON_INITCALL INIT_RAM_FS - *(.init.altinstructions .init.bss) /* from the EFI stub */ + *(.init.altinstructions .init.bss .init.bss.*) /* from the EFI stub */ } .exit.data : { EXIT_DATA --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 975D23F7897; Tue, 17 Mar 2026 22:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787894; cv=none; b=ZQeIjEko4bKpJG2+ys5+eIUqpwHsj7oJzojfezzNqffsjbzHQgL8/D7C2Shx1qYqj9QpkQQI2ZVCVRJQT2jNqf7ut3gFtdb09xsEJwY7h6MiLZm1/bT1W+tcHm34yxWSL59NUFRmD9SJCPSzEX1jMfIitK79AlI20Rd253qCDfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787894; c=relaxed/simple; bh=VHYVcG46HDcvFMvnPYNK+XTdXj0sPBym+XtZyAEFC2M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kK1vRsmJYo+3s5gh4hYArGbQPzaYlV+HAm27hqH4r/TS51ZATG6qxctwOJRHKjZHYQUVIV3EX6LqGA4Q881BXFk0xlXEvRIjH7FFFMuJH90ney8ZNdBEQcnR3QNU0jrzgoFbgsT4G1uIKC06AV5Uj1GRa3Nb9zxiq9d+/k0tL1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F9dGKUuC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F9dGKUuC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11D8BC2BCB0; Tue, 17 Mar 2026 22:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787894; bh=VHYVcG46HDcvFMvnPYNK+XTdXj0sPBym+XtZyAEFC2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9dGKUuCdmTIFVIN8p79f8n/HoYP/FrAAPJsea2JO7/IgAUlFJuHz+bDQ++e1OaJN uucFILufRXwG4QS26FVQPIgUGDwpvGjdDb06ia8qXAVXmC1XAsVtBCsX8i2PXoa5xW 9YzHtwrdnVrku7HBboc/o4g2Pa1NW9oC1SV8K7T4KYBAByYBEoODFo3scSP31Ndeho GSWloLMay0XDavuTrYWPAzlNQBSr14Vrev+vEcxsDIk0+PRr5fbP1IVDlYClrnZVmc MibKcYQlxy54qGPNOMU7waOMBpzXSAdTRwCDI/rDEiYIPjchNfCWadhHdVtMLKX25Z MjBoKcliSAbFA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 04/12] crypto: arm64: Move data to .rodata Date: Tue, 17 Mar 2026 15:51:04 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Data embedded in .text pollutes i-cache and confuses objtool and other tools that try to disassemble it. Move it to .rodata. Signed-off-by: Josh Poimboeuf --- lib/crypto/arm64/sha2-armv8.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/crypto/arm64/sha2-armv8.pl b/lib/crypto/arm64/sha2-armv8.pl index 35ec9ae99fe1..8cd86768bf5c 100644 --- a/lib/crypto/arm64/sha2-armv8.pl +++ b/lib/crypto/arm64/sha2-armv8.pl @@ -237,7 +237,8 @@ $code.=3D<<___; ldp $E,$F,[$ctx,#4*$SZ] add $num,$inp,$num,lsl#`log(16*$SZ)/log(2)` // end of input ldp $G,$H,[$ctx,#6*$SZ] - adr $Ktbl,.LK$BITS + adrp $Ktbl,.LK$BITS + add $Ktbl,$Ktbl,:lo12:.LK$BITS stp $ctx,$num,[x29,#96] =20 .Loop: @@ -286,6 +287,7 @@ $code.=3D<<___; ret .size $func,.-$func =20 +.pushsection .rodata .align 6 .type .LK$BITS,%object .LK$BITS: @@ -365,6 +367,7 @@ $code.=3D<<___; #endif .asciz "SHA$BITS block transform for ARMv8, CRYPTOGAMS by " .align 2 +.popsection ___ =20 if ($SZ=3D=3D4) { @@ -385,7 +388,8 @@ sha256_block_armv8: add x29,sp,#0 =20 ld1.32 {$ABCD,$EFGH},[$ctx] - adr $Ktbl,.LK256 + adrp $Ktbl,.LK256 + add $Ktbl,$Ktbl,:lo12:.LK256 =20 .Loop_hw: ld1 {@MSG[0]-@MSG[3]},[$inp],#64 @@ -648,7 +652,8 @@ sha256_block_neon: mov x29, sp sub sp,sp,#16*4 =20 - adr $Ktbl,.LK256 + adrp $Ktbl,.LK256 + add $Ktbl,$Ktbl,:lo12:.LK256 add $num,$inp,$num,lsl#6 // len to point at the end of inp =20 ld1.8 {@X[0]},[$inp], #16 --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B4D93F880A; Tue, 17 Mar 2026 22:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787895; cv=none; b=dfMsMV+G1UEb+gQYVpKhduki/s9co9JknLrSu+/oWTiM7+cE1XnEReXWhrnEiG8rOBXve9lXtHRdOXcyrd4i2L3X/7Rjkwk2+Ojobb30IoZw/pv0ZYVUnB5eSeWf7yPoQYiA7Z4WhQ3ijc6t7844XXG8MQg7U+bSwkj47Bu2xnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787895; c=relaxed/simple; bh=TUaxduyimKBy3VNMssZhboEIRmy6Myd8d1LMjCjwrEk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Et7I/GcjdznP2IZRZUwj7Dftwz/o5X3RIcCgcGLnH5NaPsFoKTDJSlpkZW2E/XSkP3RkuKcfWivJ1R9/Ky47i+ef5LFq6V/XA/tFBe/jlo9KctkYSUHFZ99spbnAJY9OtH1oOwi+dOXm15FJSIToUXS+BKJPkUyPOHIPLdihyqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H25Tzxbc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H25Tzxbc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0D88C4AF0D; Tue, 17 Mar 2026 22:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787895; bh=TUaxduyimKBy3VNMssZhboEIRmy6Myd8d1LMjCjwrEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H25Tzxbcj2msmLBn45caCXnQrfG0h5THrjah7LuGH/RigZ62FA6ZRLfHZatejHhnW 3ePSGRyBhccA7SVXuomFM4uRyiyeio9tK/5fNn70V68Or0gYagpHoseu8E6sgd/tcI rdrh4T7NERJ83IeyBlxHAbkFuN2DWs2q11f5s3J2qxpkZIvKAWZCfmJKV8Ooekwe/H bpok87dt3Ii5gFBviWjBoThvChQ7I2TcYaKRhl7Wd3pzJpTmH75AgaeLDi7YX73JGJ 5VZz7j1JzzhwNgOUG/r33yri9wUuJUoLgFDMJhNls/w/lNRaPUFcp9eBu87115d07d i1ChgY7HZiAGA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 05/12] objtool: Extricate checksum calculation from validate_branch() Date: Tue, 17 Mar 2026 15:51:05 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for porting the checksum code to other arches, make its functionality independent from the CFG reverse engineering code. Now that it's no longer called by validate_insn(), checksum_update_insn() has to manually iterate the alternatives. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 71 +++++++++++++++++------- tools/objtool/include/objtool/checksum.h | 6 +- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 2301fb7ff3c8..d428d63b29c6 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2633,8 +2633,7 @@ static bool validate_branch_enabled(void) { return opts.stackval || opts.orc || - opts.uaccess || - opts.checksum; + opts.uaccess; } =20 static int decode_sections(struct objtool_file *file) @@ -3663,6 +3662,7 @@ static bool skip_alt_group(struct instruction *insn) return alt_insn->type =3D=3D INSN_CLAC || alt_insn->type =3D=3D INSN_STAC; } =20 +#ifdef BUILD_KLP static int checksum_debug_init(struct objtool_file *file) { char *dup, *s; @@ -3705,9 +3705,30 @@ static void checksum_update_insn(struct objtool_file= *file, struct symbol *func, struct instruction *insn) { struct reloc *reloc =3D insn_reloc(file, insn); + struct alternative *alt; unsigned long offset; struct symbol *sym; =20 + for (alt =3D insn->alts; alt; alt =3D alt->next) { + struct alt_group *alt_group =3D alt->insn->alt_group; + + checksum_update(func, insn, &alt->type, sizeof(alt->type)); + + if (alt_group && alt_group->orig_group) { + struct instruction *alt_insn; + + checksum_update(func, insn, &alt_group->feature, sizeof(alt_group->feat= ure)); + + for (alt_insn =3D alt->insn; alt_insn; alt_insn =3D next_insn_same_sec(= file, alt_insn)) { + checksum_update_insn(file, func, alt_insn); + if (alt_insn =3D=3D alt_group->last_insn) + break; + } + } else { + checksum_update(func, insn, &alt->insn->offset, sizeof(alt->insn->offse= t)); + } + } + if (insn->fake) return; =20 @@ -3716,9 +3737,11 @@ static void checksum_update_insn(struct objtool_file= *file, struct symbol *func, if (!reloc) { struct symbol *call_dest =3D insn_call_dest(insn); =20 - if (call_dest) + if (call_dest) { + /* intra-TU call without reloc */ checksum_update(func, insn, call_dest->demangled_name, strlen(call_dest->demangled_name)); + } return; } =20 @@ -3745,6 +3768,29 @@ static void checksum_update_insn(struct objtool_file= *file, struct symbol *func, checksum_update(func, insn, &offset, sizeof(offset)); } =20 +static int calculate_checksums(struct objtool_file *file) +{ + struct instruction *insn; + struct symbol *func; + + if (checksum_debug_init(file)) + return -1; + + for_each_sym(file->elf, func) { + if (!is_func_sym(func)) + continue; + + checksum_init(func); + + func_for_each_insn(file, func, insn) + checksum_update_insn(file, func, insn); + + checksum_finish(func); + } + return 0; +} +#endif /* BUILD_KLP */ + static int validate_branch(struct objtool_file *file, struct symbol *func, struct instruction *insn, struct insn_state state); static int do_validate_branch(struct objtool_file *file, struct symbol *fu= nc, @@ -4026,9 +4072,6 @@ static int do_validate_branch(struct objtool_file *fi= le, struct symbol *func, insn->trace =3D 0; next_insn =3D next_insn_to_validate(file, insn); =20 - if (opts.checksum && func && insn->sec) - checksum_update_insn(file, func, insn); - if (func && insn_func(insn) && func !=3D insn_func(insn)->pfunc) { /* Ignore KCFI type preambles, which always fall through */ if (is_prefix_func(func)) @@ -4094,9 +4137,6 @@ static int validate_unwind_hint(struct objtool_file *= file, struct symbol *func =3D insn_func(insn); int ret; =20 - if (opts.checksum) - checksum_init(func); - ret =3D validate_branch(file, func, insn, *state); if (ret) BT_INSN(insn, "<=3D=3D=3D (hint)"); @@ -4539,9 +4579,6 @@ static int validate_symbol(struct objtool_file *file,= struct section *sec, =20 func =3D insn_func(insn); =20 - if (opts.checksum) - checksum_init(func); - if (opts.trace && !fnmatch(opts.trace, sym->name, 0)) { trace_enable(); TRACE("%s: validation begin\n", sym->name); @@ -4554,9 +4591,6 @@ static int validate_symbol(struct objtool_file *file,= struct section *sec, TRACE("%s: validation %s\n\n", sym->name, ret ? "failed" : "end"); trace_disable(); =20 - if (opts.checksum) - checksum_finish(func); - return ret; } =20 @@ -5011,10 +5045,6 @@ int check(struct objtool_file *file) cfi_hash_add(&init_cfi); cfi_hash_add(&func_cfi); =20 - ret =3D checksum_debug_init(file); - if (ret) - goto out; - ret =3D decode_sections(file); if (ret) goto out; @@ -5105,6 +5135,9 @@ int check(struct objtool_file *file) warnings +=3D check_abs_references(file); =20 if (opts.checksum) { + ret =3D calculate_checksums(file); + if (ret) + goto out; ret =3D create_sym_checksum_section(file); if (ret) goto out; diff --git a/tools/objtool/include/objtool/checksum.h b/tools/objtool/inclu= de/objtool/checksum.h index 7fe21608722a..36a17688c716 100644 --- a/tools/objtool/include/objtool/checksum.h +++ b/tools/objtool/include/objtool/checksum.h @@ -32,11 +32,7 @@ static inline void checksum_finish(struct symbol *func) =20 #else /* !BUILD_KLP */ =20 -static inline void checksum_init(struct symbol *func) {} -static inline void checksum_update(struct symbol *func, - struct instruction *insn, - const void *data, size_t size) {} -static inline void checksum_finish(struct symbol *func) {} +static inline int calculate_checksums(struct objtool_file *file) { return = -ENOSYS; } =20 #endif /* !BUILD_KLP */ =20 --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9D9A3F8818; Tue, 17 Mar 2026 22:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787895; cv=none; b=rAFVB/TlMPVXE5SuN18etpW4ycTI/cQE4jxVeIzrWQfXWZ7bJ9C9yNpAW+ZW/0gruS4q5DT55cSAMbCP9Ez/UJ5X7W+010mlGoONCYvfvaINUqxMLDQPoyOsS7c1V6T4XedeCFeWBV8LP/yyOeWgtnwNuMkw6J18V+M4Cp83VNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787895; c=relaxed/simple; bh=ZNFy3T2ljWwS1cXqTSDWH3OzAYlfT/ejcAHXOO7W/u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UnOxGKQYvV71IkudhhCsYNrJ9/ofxF4wSNRgMzjKDfMKQk03Z17hSERK6wdpyNZEJ3TKTsWHs5X9QVpfXEXLXEl3nyoBJedFnKW4KQRfgDIn9LoK/149I5VJdylkBhxbHThPoy658xghF8Vig9hkxT/h43sz8H56lO8Shl/Z6V0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ToH5ZCrM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ToH5ZCrM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4439BC19425; Tue, 17 Mar 2026 22:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787895; bh=ZNFy3T2ljWwS1cXqTSDWH3OzAYlfT/ejcAHXOO7W/u0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ToH5ZCrMuabFXFe6yVOv0hFFBxF8DARKOazIF/k5JIlh1jstum9XHAAHik2UqpVAQ vgSTyZgSm4/fIcmhNxeIJ7ebJ4I6yjGyMYHyUscJgklBfyKeAPUHkoXck0cmY7NDSu 6m9QRx5f3u5UivZMKbbNqhhZCRe3SF8mM/GDwqZn75X4ShzFsZez2lkA4c+kSzBy51 i3FntVwRWlXSWoxxjrCCS8UL79HtgwEwtZxUHxZloxZQ6FTgwV/+e998ovaC/9YwWa z51rIPdBBX+bD2c6K7uiPa89oq6YQgK1+1VKvzW9Ltn+Zi97wlsY6deF3rZ4Fg4Hg6 5OEPeu7M9NWOQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 06/12] objtool: Allow setting --mnop without --mcount Date: Tue, 17 Mar 2026 15:51:06 -0700 Message-ID: <84977dbdf9e0b579cd5f8efe55fb38b0cc275198.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of returning an error for --mnop without --mcount, just silently ignore it. This will help simplify kbuild's handling of objtool args. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index b780df513715..f528a58aca74 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c @@ -145,11 +145,6 @@ int cmd_parse_options(int argc, const char **argv, con= st char * const usage[]) =20 static bool opts_valid(void) { - if (opts.mnop && !opts.mcount) { - ERROR("--mnop requires --mcount"); - return false; - } - if (opts.noinstr && !opts.link) { ERROR("--noinstr requires --link"); return false; --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BE0C3F8DF1; Tue, 17 Mar 2026 22:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787896; cv=none; b=lqSDbxR4JbP1u5Gtnm64LwOQD9aJVRLZHZqgXYuALc3kdRz0BLNAl9+kIKlCfl3FK1lT7xNKLu3tC9l8YREFLUvbklqsex8tX4aD0TxzFBcak0OCISOBeJGxra1A1bnzq8crDh4zbs4LhlcoWczax5JhQxx+/v8r/jP8HqmHkBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787896; c=relaxed/simple; bh=K2EF4WTRfHeASh1z8JUpsoYkCrO4xOH9SpbOyLu8+CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eeqOglc2JJVGgakzTKElfnJFQ2zoDqPxglIPo2F+8oBgak7nlGt2gKgTKhEdcCqhlL00vgJy10Qn8AvXcNXLGYNNV0MsLW64ehYDQuVMGwwWqP8BYoED5eNtWoVsp0WuMeGpMWUNDeQ9aVogZYEPZCzuLcFWs3Pb5ZJ4CFhAe0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M1i67/Mo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M1i67/Mo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6691C4AF09; Tue, 17 Mar 2026 22:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787896; bh=K2EF4WTRfHeASh1z8JUpsoYkCrO4xOH9SpbOyLu8+CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1i67/Mov8XDpflXD5q0rfdgzON3t0UT4lemySE51+WujWg/iCL4b9vZVF+4vic+A 740ymHe1YmgUmrVDCwLDb5BOwxzgS/myW2+v81rajqq1rcTrjh9+Sq1cupUoBz6Heg bhxVbtfQryBda/0svJrQxrRJSoKR8Ikct6hzUCPLtTjpqwUq595Bjf0tkeSJ6P81/t RnShf8zyZ8h/WMq4+DVtR5eQyPAuD5PVVgPOXjaZ/r9q0Ty+yZrBeF5xhDeJP2MBpe Cw6/vq8j9Y2iA3lnotGKezTD1nZO/+dLN3tXhBHxOp3TSdKZEWwTYQrr6BHGuk4T7q gz4iBTfUEohWQ== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 07/12] kbuild: Only run objtool if there is at least one command Date: Tue, 17 Mar 2026 15:51:07 -0700 Message-ID: <42418c5fa73a8876e91b3dfb38fa3f263e39f1c1.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Split the objtool args into commands and options, such that if no commands have been enabled, objtool doesn't run. This is in preparation in enabling objtool and klp-build for arm64. Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Josh Poimboeuf Reviewed-by: Nicolas Schier --- arch/x86/boot/startup/Makefile | 2 +- scripts/Makefile.build | 4 +-- scripts/Makefile.lib | 46 ++++++++++++++++++---------------- scripts/Makefile.vmlinux_o | 15 ++++------- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/arch/x86/boot/startup/Makefile b/arch/x86/boot/startup/Makefile index 5e499cfb29b5..a08297829fc6 100644 --- a/arch/x86/boot/startup/Makefile +++ b/arch/x86/boot/startup/Makefile @@ -36,7 +36,7 @@ $(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STA= NDARD :=3D y # relocations, even if other objtool actions are being deferred. # $(pi-objs): objtool-enabled =3D 1 -$(pi-objs): objtool-args =3D $(if $(delay-objtool),--dry-run,$(objtool-arg= s-y)) --noabs +$(pi-objs): objtool-args =3D $(if $(delay-objtool),--dry-run,$(objtool-cmd= s-y) $(objtool-opts-y)) --noabs =20 # # Confine the startup code by prefixing all symbols with __pi_ (for positi= on diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 3652b85be545..8a1bdfdb2fdb 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -277,7 +277,7 @@ endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT is-standard-object =3D $(if $(filter-out y%, $(OBJECT_FILES_NON_STANDARD_$= (target-stem).o)$(OBJECT_FILES_NON_STANDARD)n),$(is-kernel-object)) =20 ifdef CONFIG_OBJTOOL -$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= delay-objtool),$(is-single-obj-m),y)) +$(obj)/%.o: private objtool-enabled =3D $(if $(is-standard-object),$(if $(= objtool-cmds-y),$(if $(delay-objtool),$(is-single-obj-m),y))) endif =20 ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) @@ -501,7 +501,7 @@ define rule_ld_multi_m $(call cmd,gen_objtooldep) endef =20 -$(multi-obj-m): private objtool-enabled :=3D $(delay-objtool) +$(multi-obj-m): private objtool-enabled :=3D $(if $(objtool-cmds-y),$(dela= y-objtool)) $(multi-obj-m): private part-of-module :=3D y $(multi-obj-m): %.o: %.mod FORCE $(call if_changed_rule,ld_multi_m) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0718e39cedda..40a462581666 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -183,27 +183,31 @@ ifdef CONFIG_OBJTOOL =20 objtool :=3D $(objtree)/tools/objtool/objtool =20 -objtool-args-$(CONFIG_HAVE_JUMP_LABEL_HACK) +=3D --hacks=3Djump_label -objtool-args-$(CONFIG_HAVE_NOINSTR_HACK) +=3D --hacks=3Dnoinstr -objtool-args-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) +=3D --hacks=3Dskyla= ke -objtool-args-$(CONFIG_X86_KERNEL_IBT) +=3D --ibt -objtool-args-$(CONFIG_FINEIBT) +=3D --cfi -objtool-args-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) +=3D --mcount -ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL -objtool-args-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) +=3D --mnop -endif -objtool-args-$(CONFIG_UNWINDER_ORC) +=3D --orc -objtool-args-$(CONFIG_MITIGATION_RETPOLINE) +=3D --retpoline -objtool-args-$(CONFIG_MITIGATION_RETHUNK) +=3D --rethunk -objtool-args-$(CONFIG_MITIGATION_SLS) +=3D --sls -objtool-args-$(CONFIG_STACK_VALIDATION) +=3D --stackval -objtool-args-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D --static-call -objtool-args-$(CONFIG_HAVE_UACCESS_VALIDATION) +=3D --uaccess -objtool-args-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) +=3D --no-unreacha= ble -objtool-args-$(CONFIG_PREFIX_SYMBOLS) +=3D --prefix=3D$(CONFIG_FUNCTION_= PADDING_BYTES) -objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror +# objtool commands +objtool-cmds-$(CONFIG_HAVE_JUMP_LABEL_HACK) +=3D --hacks=3Djump_label +objtool-cmds-$(CONFIG_HAVE_NOINSTR_HACK) +=3D --hacks=3Dnoinstr +objtool-cmds-$(CONFIG_MITIGATION_CALL_DEPTH_TRACKING) +=3D --hacks=3Dskyla= ke +objtool-cmds-$(CONFIG_X86_KERNEL_IBT) +=3D --ibt +objtool-cmds-$(CONFIG_FINEIBT) +=3D --cfi +objtool-cmds-$(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL) +=3D --mcount +objtool-cmds-$(CONFIG_UNWINDER_ORC) +=3D --orc +objtool-cmds-$(CONFIG_MITIGATION_RETPOLINE) +=3D --retpoline +objtool-cmds-$(CONFIG_MITIGATION_RETHUNK) +=3D --rethunk +objtool-cmds-$(CONFIG_MITIGATION_SLS) +=3D --sls +objtool-cmds-$(CONFIG_STACK_VALIDATION) +=3D --stackval +objtool-cmds-$(CONFIG_HAVE_STATIC_CALL_INLINE) +=3D --static-call +objtool-cmds-$(CONFIG_HAVE_UACCESS_VALIDATION) +=3D --uaccess +objtool-cmds-$(CONFIG_PREFIX_SYMBOLS) +=3D --prefix=3D$(CONFIG_FUNCTION_= PADDING_BYTES) +objtool-cmds-y +=3D $(OBJTOOL_ARGS) =20 -objtool-args =3D $(objtool-args-y) \ +# objtool options +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL +objtool-opts-$(CONFIG_HAVE_OBJTOOL_NOP_MCOUNT) +=3D --mnop +endif +objtool-opts-$(or $(CONFIG_GCOV_KERNEL),$(CONFIG_KCOV)) +=3D --no-unreacha= ble +objtool-opts-$(CONFIG_OBJTOOL_WERROR) +=3D --werror + +objtool-args =3D $(objtool-cmds-y) $(objtool-opts-y) \ $(if $(delay-objtool), --link) \ $(if $(part-of-module), --module) =20 @@ -212,7 +216,7 @@ delay-objtool :=3D $(or $(CONFIG_LTO_CLANG),$(CONFIG_X8= 6_KERNEL_IBT),$(CONFIG_KLP_ cmd_objtool =3D $(if $(objtool-enabled), ; $(objtool) $(objtool-args) $@) cmd_gen_objtooldep =3D $(if $(objtool-enabled), { echo ; echo '$@: $$(wild= card $(objtool))' ; } >> $(dot-target).cmd) =20 -objtool-enabled :=3D y +objtool-enabled =3D $(if $(objtool-cmds-y),y) =20 endif # CONFIG_OBJTOOL =20 diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 527352c222ff..09af33203bd8 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -36,18 +36,13 @@ endif # For !delay-objtool + CONFIG_NOINSTR_VALIDATION, it runs on both translat= ion # units and vmlinux.o, with the latter only used for noinstr/unret validat= ion. =20 -objtool-enabled :=3D $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION)) - -ifeq ($(delay-objtool),y) -vmlinux-objtool-args-y +=3D $(objtool-args-y) -else -vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR) +=3D --werror +ifneq ($(delay-objtool),y) +objtool-cmds-y =3D +objtool-opts-y +=3D --link endif =20 -vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ - $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_S= RSO)), --unret) - -objtool-args =3D $(vmlinux-objtool-args-y) --link +objtool-cmds-$(CONFIG_NOINSTR_VALIDATION) +=3D --noinstr \ + $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SR= SO)), --unret) =20 # Link of vmlinux.o used for section mismatch analysis # ------------------------------------------------------------------------= --- --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10FF63F8E06; Tue, 17 Mar 2026 22:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787897; cv=none; b=JZPwWnTrPtE+HY33O7ADQBulOXLgoPuMkxp/j/3wWShxQKeCK91+oELXy0EU5yiN0aD5O+o/7Ce8CXIkMk2pKrxxVO6lGVawyAHlqksn9VJ8LDVyXtSsmwMQPV3xyA/uDvhM8v6S37WRSvcUb8S/aLmKoXZmxzfzqz4kKGD8jmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787897; c=relaxed/simple; bh=LneP7wGKv2nwzC48EGP/qa4m/tgR04JXHfdr5Hy2OTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uqGIIEosVqTBt1jKLpRHD0ljh+/s0qPNXeu42NQjCYIgL9q37nvImz4ErYO1uNInlDJptcAbBA7ummaA2YHXkgiuVtbmXZzpQ29JWFWYqfa379iH0HfxKUHpPD3djVlP1h8vd4IiVBPuBAeRSgwWRjeCflXg6U3CO+qqVQXiwao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qngo6z11; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qngo6z11" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75822C4CEF7; Tue, 17 Mar 2026 22:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787896; bh=LneP7wGKv2nwzC48EGP/qa4m/tgR04JXHfdr5Hy2OTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qngo6z11Y9Ew0q/w6MzKc0RDHuzv3zv3tiXXmAii/TUFdqaHGUiE77fX5laBcACdt jBK8X+ZL41ymUm5gnCm4tvn376vpm2pJcgtRELAmhSl7gdxnxq4PCRwODiMjhPJF1G v+lsWta3aS0+zy/Vopw3VMh0ddnhzp6yeJ+PzrOSY+qjni4yG/YrEVvuDOtJ+dW8dy r61VBS8lpeF0XSxQuuHQiqosUWnGyBNdOpzknYHAkClT4p4QeiMuTGKIU9d4FTkpsF hupC261b4CXaULZAnA5st3TPR4D0WnZ9UJTCcJUVlOth7LoPZ8WTBaUyKZ0pwqTrN5 HyhiNADADG70A== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 08/12] objtool: Ignore jumps to the end of the function for non-CFG arches Date: Tue, 17 Mar 2026 15:51:08 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Sometimes Clang arm64 code jumps to the end of the function for UB. No need to make that an error, arm64 doesn't reverse engineer the CFG anyway. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index d428d63b29c6..6e33a29bd3ed 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1630,10 +1630,12 @@ static int add_jump_destinations(struct objtool_fil= e *file) /* * GCOV/KCOV dead code can jump to the end of * the function/section. + * + * Clang on arm64 also does this sometimes for + * undefined behavior. */ - if (file->ignore_unreachables && func && - dest_sec =3D=3D insn->sec && - dest_off =3D=3D func->offset + func->len) + if ((file->ignore_unreachables || (!opts.stackval && !opts.orc)) && + func && dest_sec =3D=3D insn->sec && dest_off =3D=3D func->offset += func->len) continue; =20 ERROR_INSN(insn, "can't find jump dest instruction at %s", --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 150F93A6EE0; Tue, 17 Mar 2026 22:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787898; cv=none; b=kidDNeSFBadMn9GnV2pxkKxyS88jdbt0EGP9Xy5aMPDbBMQIwd8IjVOKMhnCzqRX1bl2KHGIf4C6okw+5Y13aNdF148il3OoeY/IPuiqWZGzuUuHCGAr+m0nSWeI3JgrnN0MZhFNEpb9ceuBzEFMjJ99IVhkd2zq8gPcZjdi6NM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787898; c=relaxed/simple; bh=R5UiZpTiDDGQeFvx+x5fyQyw1CckBBaOg4b13Rc2GFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z5wsdjCFiBrPagGlL7v5qPKXAbDb8NI9dwml+OXbsetkt3BtZw3eA4bmBBMpySgbZX+5ovB4aRrZuFNEzoYex5pmo8GKlp4+gGeFXsE3R0yzr6NfgsAk9UNLYgMYmcR9j3UsDCcrs0Atnbd3s0SLxotcdRrmdUdXCJOu1+SI+HM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O05cfDTO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O05cfDTO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16372C2BC9E; Tue, 17 Mar 2026 22:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787897; bh=R5UiZpTiDDGQeFvx+x5fyQyw1CckBBaOg4b13Rc2GFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O05cfDTOoUN0o/a5xAMBqeA6JBv53owzUYaz7WqDnkXpa361njl5XUGAkFaMMp3u+ 9uteSon8YEXqmi+jXEe1qpNPaCBqv4N/2HWOLQAP1ZR5U9HilJnpk5b9lQ8QQS3qP/ AchOaEvUekQtgTWU2jBME/yHKvRBqBZXm3g53CQc/XrVVXNtflKnNHmV0OgBHYTRu4 M6WvQGBAlW8nS2eVCAG1S3aDOLmpnJvxUofX1XOWQdqs3mxsyhHEZNZJq0Zq/4uvNs 7O2cyuQ2IV5vDquka3y+dNWifbssa+Kb/l7nm05PpS9XT5ALSB0X6RcXdggHJgc9cA UFb656RNfSzPw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 09/12] objtool: Allow empty alternatives Date: Tue, 17 Mar 2026 15:51:09 -0700 Message-ID: <1d74ee9e31727870266ffb69ce0d6a4a40b8e99a.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" arm64 can have empty alternatives, which are effectively no-ops. Ignore them. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6e33a29bd3ed..7297fb87f876 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1994,10 +1994,8 @@ static int add_special_section_alts(struct objtool_f= ile *file) } =20 if (special_alt->group) { - if (!special_alt->orig_len) { - ERROR_INSN(orig_insn, "empty alternative entry"); + if (!special_alt->orig_len) continue; - } =20 if (handle_group_alt(file, special_alt, orig_insn, &new_insn)) return -1; --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A61C33F789E; Tue, 17 Mar 2026 22:51:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787898; cv=none; b=NqHgIZnuwiMBT6angEkI9eqaCx6YQR3UVf5lS03whW2q0XSaY1UWPxHXEowNhN3LdDt7W6UhfairoITjB/l+9kabI/eekPOZNrbhroX9q32UTpuog+TK7OltiYBlzQEEwCZO8rASuhipWSSx2AancyCJPc5ain5pudnY9AHSjHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787898; c=relaxed/simple; bh=Z4h9ZFd5elXdJi4wGJjXHxGFSPzvcEc4LERNhrT0EmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ba02IWoHTej++wKTAI6x/ZEbfg41FDny9UY1S5pLCYczgZ47hfMPrScH9ex98/nTgg3xmPSXkYN+MjtkftZBxsfWzJf/CBaCaEG29tav05/YY5ZOG9PuNoKxz+nM1On+BmCvxVlkO+2Rqw/d4vfcMuri7U9V/+5NBxs09S6h9Eg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SEISourM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SEISourM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2B9AC2BCC9; Tue, 17 Mar 2026 22:51:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787898; bh=Z4h9ZFd5elXdJi4wGJjXHxGFSPzvcEc4LERNhrT0EmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SEISourMafINQsXcWHU2ATrORkFpttHBZjwLuKpsPpemhVE9HhqmUB/CM6T7M+htA DYR0J4BPPJCqkO96EfctVeIRhNhiRLAvPU5cmdOsi90QQyMQrniTmVNwycGCcxdZtP hUAS/YwgmhrOOeAMFmuLxT76aTwikXppqOtUIK3+2H4AgFwL2Ka+5/z9AvxduJ4KSH muy19v9dvnYxKctPAlxrXxOPWTPgau7SvFtbYeNssU2rgJd8uB0xiw/MssIc9cRMp9 eV/paCwa/QWLJSEsjjT7UXNvOhbYHqXo7B093waN/tT+DwUawc6WLzRPUJASZ2Sb6Z NlLQqnKt12HXw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 10/12] objtool: Reuse consecutive string references Date: Tue, 17 Mar 2026 15:51:10 -0700 Message-ID: <4d211040356fe169b4236b3deea1cdff80e9babc.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For duplicate strings, elf_add_string() just blindly adds duplicates. That can be a problem for arm64 which often uses two consecutive instructions (and corresponding relocations) to put an address into a register, like: d8: 90000001 adrp x1, 0 d8: R_AARCH= 64_ADR_PREL_PG_HI21 .rodata.meminfo_proc_show.str1.8 dc: 91000021 add x1, x1, #0x0 dc: R_AARCH64_ADD_ABS_LO12_= NC .rodata.meminfo_proc_show.str1.8 Referencing two different string addresses in the adrp+add pair can result in a corrupt string addresses. Detect such consecutive reuses and force them to use the same string. Acked-by: Song Liu Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index b911abe3a15e..5ccae2c937dc 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -1374,6 +1374,8 @@ struct elf *elf_create_file(GElf_Ehdr *ehdr, const ch= ar *name) =20 unsigned int elf_add_string(struct elf *elf, struct section *strtab, const= char *str) { + static unsigned int last_off; + static const char *last_str; unsigned int offset; =20 if (!strtab) @@ -1382,17 +1384,22 @@ unsigned int elf_add_string(struct elf *elf, struct= section *strtab, const char ERROR("can't find .strtab section"); return -1; } - if (!strtab->sh.sh_addralign) { ERROR("'%s': invalid sh_addralign", strtab->name); return -1; } =20 + if (last_str && !strcmp(last_str, str)) + return last_off; + offset =3D ALIGN(sec_size(strtab), strtab->sh.sh_addralign); =20 if (!elf_add_data(elf, strtab, str, strlen(str) + 1)) return -1; =20 + last_str =3D str; + last_off =3D offset; + return offset; } =20 --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41B6732C942; Tue, 17 Mar 2026 22:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787899; cv=none; b=rblaw3JtHUef8kRVPYdTdR9XFSbHPyXwKJOSj8vKZjknT2aQpAoNs4m0GcbQyOtWvqrdpNLbbnUqBfNVq2YpaitsIzlsPSdG4iDDvQOryMuxUDj9hedDwpWia7POOYai5H5R3hfP6bYAgYLWFWaK/8uN9E3TOQ+g6mEP2Gl448o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787899; c=relaxed/simple; bh=fEMGUpFDlhNRg1sLbKniP9b2BaEndplZSI3APG5mJWo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l0x9AfbmDpRjBOadNp6Dnxtrjy9+72VgDtBqOsQAXpKwxh87q7H83c4T32GaFcKeAZxqGa+ab3hOtt9Y5NiPxEWmBVr7t5iFN3RegT70LsXevJpzWHjVJCqYBCLF2/xH7ju5BJqS7gyM20Pxt+ywdyBgh/OzQSHW6128G2+H9Rc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=boUZfUw5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="boUZfUw5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91CCEC2BCB0; Tue, 17 Mar 2026 22:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787899; bh=fEMGUpFDlhNRg1sLbKniP9b2BaEndplZSI3APG5mJWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=boUZfUw5R1dpAOy9Qe91EuiTP6xOMtXCPYRckujVQmBIzyszZygpVfFeP9emiRV2+ pBW5W7+MuEaIwfoy8UgiP/K00+g8B6UGqr4Ix+siF42Rii4jt+mVuq8B/ZzrgXeKhL YakGD1LH+bcj9nGdJKB7JYUpKm8QK3EsqSejpT1LqbENU6DDQnY/CiCgnWCuA6wzDO 91yQX3yzBJ67pd5Q9k+WLtyD+zfs4kwXFbBmsUd3BqtL+msjPtzfEFK5xZoZS1LgsI 2bljO01g1RYvrRgI1iVXuPzywGnKdukXJ7RqT15X7yCT9OXYIn7JHgAaFUQyacFVRg 8JiSgYkLBPRLg== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 11/12] objtool: Introduce objtool for arm64 Date: Tue, 17 Mar 2026 15:51:11 -0700 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add basic support for arm64 on objtool. Only --checksum is currently supported. Signed-off-by: Josh Poimboeuf --- arch/arm64/Kconfig | 2 + tools/objtool/Makefile | 4 + tools/objtool/arch/arm64/Build | 2 + tools/objtool/arch/arm64/decode.c | 116 ++++++++++++++++++ .../arch/arm64/include/arch/cfi_regs.h | 11 ++ tools/objtool/arch/arm64/include/arch/elf.h | 13 ++ .../objtool/arch/arm64/include/arch/special.h | 21 ++++ tools/objtool/arch/arm64/special.c | 21 ++++ 8 files changed, 190 insertions(+) create mode 100644 tools/objtool/arch/arm64/Build create mode 100644 tools/objtool/arch/arm64/decode.c create mode 100644 tools/objtool/arch/arm64/include/arch/cfi_regs.h create mode 100644 tools/objtool/arch/arm64/include/arch/elf.h create mode 100644 tools/objtool/arch/arm64/include/arch/special.h create mode 100644 tools/objtool/arch/arm64/special.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 38dba5f7e4d2..354aa80c5b4b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -236,9 +236,11 @@ config ARM64 select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_IOREMAP_PROT select HAVE_IRQ_TIME_ACCOUNTING + select HAVE_KLP_BUILD select HAVE_LIVEPATCH select HAVE_MOD_ARCH_SPECIFIC select HAVE_NMI + select HAVE_OBJTOOL select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI select HAVE_PERF_REGS diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index b71d1886022e..66b04172b79a 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile @@ -11,6 +11,10 @@ ifeq ($(SRCARCH),loongarch) BUILD_ORC :=3D y endif =20 +ifeq ($(SRCARCH),arm64) + ARCH_HAS_KLP :=3D y +endif + ifeq ($(ARCH_HAS_KLP),y) HAVE_XXHASH =3D $(shell printf "$(pound)include \nXXH3_state_t = *state;int main() {}" | \ $(HOSTCC) $(HOSTCFLAGS) -xc - -o /dev/null -lxxhash 2> /dev/null &= & echo y || echo n) diff --git a/tools/objtool/arch/arm64/Build b/tools/objtool/arch/arm64/Build new file mode 100644 index 000000000000..d24d5636a5b8 --- /dev/null +++ b/tools/objtool/arch/arm64/Build @@ -0,0 +1,2 @@ +objtool-y +=3D decode.o +objtool-y +=3D special.o diff --git a/tools/objtool/arch/arm64/decode.c b/tools/objtool/arch/arm64/d= ecode.c new file mode 100644 index 000000000000..ee93c096243f --- /dev/null +++ b/tools/objtool/arch/arm64/decode.c @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include +#include +#include + +const char *arch_reg_name[CFI_NUM_REGS] =3D {}; + +int arch_ftrace_match(const char *name) +{ + return 0; +} + +s64 arch_insn_adjusted_addend(struct instruction *insn, struct reloc *relo= c) +{ + return reloc_addend(reloc); +} + +bool arch_callee_saved_reg(unsigned char reg) +{ + return false; +} + +int arch_decode_hint_reg(u8 sp_reg, int *base) +{ + exit(-1); +} + +const char *arch_nop_insn(int len) +{ + exit(-1); +} + +const char *arch_ret_insn(int len) +{ + exit(-1); +} + +int arch_decode_instruction(struct objtool_file *file, const struct sectio= n *sec, + unsigned long offset, unsigned int maxlen, + struct instruction *insn) +{ + u32 i =3D *((u32 *)(sec->data->d_buf + offset)); + + insn->len =3D 4; + + /* + * These are the bare minimum needed for static branch detection and + * checksum calculations. + */ + if (i =3D=3D 0xd503201f || i =3D=3D 0x2a1f03f7) { + /* For static branches */ + insn->type =3D INSN_NOP; + } else if ((i & 0xfc000000) =3D=3D 0x14000000) { + /* For static branches and intra-TU sibling calls */ + insn->type =3D INSN_JUMP_UNCONDITIONAL; + insn->immediate =3D sign_extend64(i & 0x03ffffff, 25); + } else if ((i & 0xfc000000) =3D=3D 0x94000000) { + /* For intra-TU calls */ + insn->type =3D INSN_CALL; + insn->immediate =3D sign_extend64(i & 0x03ffffff, 25); + } else if ((i & 0xff000000) =3D=3D 0x54000000) { + /* For intra-TU conditional sibling calls */ + insn->type =3D INSN_JUMP_CONDITIONAL; + insn->immediate =3D sign_extend64((i & 0xffffe0) >> 5, 18); + } else { + insn->type =3D INSN_OTHER; + } + + return 0; +} + +u64 arch_adjusted_addend(struct reloc *reloc) +{ + return reloc_addend(reloc); +} + +unsigned long arch_jump_destination(struct instruction *insn) +{ + return insn->offset + (insn->immediate << 2); +} + +bool arch_pc_relative_reloc(struct reloc *reloc) +{ + return false; +} + +void arch_initial_func_cfi_state(struct cfi_init_state *state) +{ + state->cfa.base =3D CFI_UNDEFINED; +} + +unsigned int arch_reloc_size(struct reloc *reloc) +{ + switch (reloc_type(reloc)) { + case R_AARCH64_ABS64: + case R_AARCH64_PREL64: + return 8; + default: + return 4; + } +} + +#ifdef DISAS +int arch_disas_info_init(struct disassemble_info *dinfo) +{ + return disas_info_init(dinfo, bfd_arch_aarch64, + bfd_mach_arm_unknown, bfd_mach_aarch64, + NULL); +} +#endif /* DISAS */ diff --git a/tools/objtool/arch/arm64/include/arch/cfi_regs.h b/tools/objto= ol/arch/arm64/include/arch/cfi_regs.h new file mode 100644 index 000000000000..49c81cbb6646 --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch/cfi_regs.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _OBJTOOL_ARCH_CFI_REGS_H +#define _OBJTOOL_ARCH_CFI_REGS_H + +/* These aren't actually used for arm64 */ +#define CFI_BP 0 +#define CFI_SP 0 +#define CFI_RA 0 +#define CFI_NUM_REGS 2 + +#endif /* _OBJTOOL_ARCH_CFI_REGS_H */ diff --git a/tools/objtool/arch/arm64/include/arch/elf.h b/tools/objtool/ar= ch/arm64/include/arch/elf.h new file mode 100644 index 000000000000..80a1bc479930 --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch/elf.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _OBJTOOL_ARCH_ELF_H +#define _OBJTOOL_ARCH_ELF_H + +#define R_NONE R_AARCH64_NONE +#define R_ABS64 R_AARCH64_ABS64 +#define R_ABS32 R_AARCH64_ABS32 +#define R_DATA32 R_AARCH64_PREL32 +#define R_DATA64 R_AARCH64_PREL64 +#define R_TEXT32 R_AARCH64_PREL32 +#define R_TEXT64 R_AARCH64_PREL64 + +#endif /* _OBJTOOL_ARCH_ELF_H */ diff --git a/tools/objtool/arch/arm64/include/arch/special.h b/tools/objtoo= l/arch/arm64/include/arch/special.h new file mode 100644 index 000000000000..8ae804a83ea4 --- /dev/null +++ b/tools/objtool/arch/arm64/include/arch/special.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef _OBJTOOL_ARCH_SPECIAL_H +#define _OBJTOOL_ARCH_SPECIAL_H + +#define EX_ENTRY_SIZE 12 +#define EX_ORIG_OFFSET 0 +#define EX_NEW_OFFSET 4 + +#define JUMP_ENTRY_SIZE 16 +#define JUMP_ORIG_OFFSET 0 +#define JUMP_NEW_OFFSET 4 +#define JUMP_KEY_OFFSET 8 + +#define ALT_ENTRY_SIZE 12 +#define ALT_ORIG_OFFSET 0 +#define ALT_NEW_OFFSET 4 +#define ALT_FEATURE_OFFSET 8 +#define ALT_ORIG_LEN_OFFSET 10 +#define ALT_NEW_LEN_OFFSET 11 + +#endif /* _OBJTOOL_ARCH_SPECIAL_H */ diff --git a/tools/objtool/arch/arm64/special.c b/tools/objtool/arch/arm64/= special.c new file mode 100644 index 000000000000..3c2b83d94939 --- /dev/null +++ b/tools/objtool/arch/arm64/special.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include + +bool arch_support_alt_relocation(struct special_alt *special_alt, + struct instruction *insn, + struct reloc *reloc) +{ + return false; +} + +struct reloc *arch_find_switch_table(struct objtool_file *file, + struct instruction *insn, + unsigned long *table_size) +{ + return NULL; +} + +const char *arch_cpu_feature_name(int feature_number) +{ + return NULL; +} --=20 2.53.0 From nobody Mon Apr 6 21:31:00 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF4793F7AB6; Tue, 17 Mar 2026 22:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787899; cv=none; b=P435hkDywTR92GgTogDSHPBz5IwX8bqnMU72OA2T8Vk+DtNFQxbqh7TqvVYffzw+bPbGGMw76zcRgg66MpPouX/+kF219UGV7x7CJibjZee5PxX3IBzr+ffRvEr9gj8CVWyhPwvOYG0Pdt2UtAl3laH/aheFcLrQne8AZJCgepA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773787899; c=relaxed/simple; bh=zRKnFKqm2URNigcW6ZVhyMqoLzUjkp7pt41hjdX3o4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oqhMOMcq6bYtPkYvHFsa1rjK/kdsqHuRQL28PRF+xHzxpdk4a1JmIZRnvvAXSHRtXgyahhmvDced9o03hKxINRnT0Uz1cBjnouX7oD0lRLftMrqcfNHKefhFfrRmUslmhXaGayxsHhISPX1gJS0TOH8z6tZOXJfNLqxUt7cwL/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ln2wjhQf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ln2wjhQf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30FA1C4CEF7; Tue, 17 Mar 2026 22:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773787899; bh=zRKnFKqm2URNigcW6ZVhyMqoLzUjkp7pt41hjdX3o4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ln2wjhQfxqa28dJgKDCHPfGBxeRw7EOtChpVpakFKvHrihIK+pCHDpeOJJCU3Kwg0 iusyhDjRSNHcR7Ruj3FDLqNg8bW2Bz6THfXuMVdfhzXG/USsY2TYeZ+0wm4caGad3i KEy2cP9mhX6AtCDN/nDxitjMbMeqXEDP9vcYFiPzoZNEdfuk8Wu/FrJr1NKMTQpaIp 1liSaWzZ0kB1BeZgvx/+j10icge2OrRrJ6W5Qu/VcihAoZ7W1yRHoDFTNdXtcIYPv1 bp1t3fegO5isq2rinS8dwud8ggyGncjLw3D9Br1YVS9kkgqze48aMbZOmcQfAWSSRW j3dtfKuJcutPw== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Peter Zijlstra , Joe Lawrence , Song Liu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Mark Rutland , Nathan Chancellor , Nicolas Schier , Herbert Xu Subject: [PATCH v2 12/12] klp-build: Support cross-compilation Date: Tue, 17 Mar 2026 15:51:12 -0700 Message-ID: <51f026e3ee15e2dc343f890c0dc1b926ad3d1c17.1773787568.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for cross-compilation. The user must export ARCH, and either CROSS_COMPILE or LLVM as needed. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index 809e198a561d..b6c057e2120f 100755 --- a/scripts/livepatch/klp-build +++ b/scripts/livepatch/klp-build @@ -404,6 +404,14 @@ validate_patches() { revert_patches } =20 +cross_compile_init() { + if [[ -v LLVM ]]; then + OBJCOPY=3Dllvm-objcopy + else + OBJCOPY=3D"${CROSS_COMPILE:-}objcopy" + fi +} + do_init() { # We're not yet smart enough to handle anything other than in-tree # builds in pwd. @@ -420,6 +428,7 @@ do_init() { validate_config set_module_name set_kernelversion + cross_compile_init } =20 # Refresh the patch hunk headers, specifically the line numbers and counts. @@ -783,7 +792,7 @@ build_patch_module() { cp -f "$kmod_file" "$kmod_file.orig" =20 # Work around issue where slight .config change makes corrupt BTF - objcopy --remove-section=3D.BTF "$kmod_file" + "$OBJCOPY" --remove-section=3D.BTF "$kmod_file" =20 # Fix (and work around) linker wreckage for klp syms / relocs "$SRC/tools/objtool/objtool" klp post-link "$kmod_file" || die "objtool k= lp post-link failed" --=20 2.53.0