From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA975C433F5 for ; Thu, 26 May 2022 11:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347130AbiEZLDm (ORCPT ); Thu, 26 May 2022 07:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347104AbiEZLDP (ORCPT ); Thu, 26 May 2022 07:03:15 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCC9CEBB1 for ; Thu, 26 May 2022 04:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=ahCkEUxJhRK4hVH+4uEu4Zy1YkpDUahrDlA6QHnqYn8=; b=VBE83Hd4eytECO94kruW1UuKSc 2WI3mvsU/TIWy8PuSiezJKbYSVu2vrql7iDaYT9vR22bxcXupaeD6bGmbN75ZXokikrHgKGVbFMrM FTWGjHlJDlRgS+q28NyFrsn5MDRRUn/Bcfb2+26JX2xQjr3/Zd3k+4AUDgBbFrLx1920YCNiBtlWj jmWb+ohJoYo8MAcRjGlsN691mXZgBGrzZK/OfrK5LqlqyPAb0vcp0TX0N55A7vLTD6JV1pgwEFbvO v/sgzlDvd21SIW56whktjMdaGO+qO3KdS+KYriZxBVboad6LrOgcSu0hl7UND/ORRyXZ7+c1NH3Jk T9JS6Fbw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001Bjo-5l; Thu, 26 May 2022 11:02:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 932EE30031D; Thu, 26 May 2022 13:02:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 6B11E202C3166; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105957.754830839@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:53 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com Subject: [PATCH 1/7] x86/entry: Anchor annotation References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" x86_64-allmodconfig gives: vmlinux.o: warning: objtool: entry_SYSCALL_compat+0x0: ANNOTATE_NOENDBR o= n ENDBR This is due to: ANNOTATE_NOENDBR SYM_CODE_END(entry_SYSENTER_compat) SYM_CODE_START(entry_SYSCALL_compat) UNWIND_HINT_EMPTY ENDBR And the hint then landing on the first instruction of the next symbol, which happens to be ENDBR. Stick in an int3 to anchor the annotation in the previous symbol. Fixes: 3e3f06950434 ("x86/ibt: Annotate text references") Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/entry/entry_64_compat.S | 1 + 1 file changed, 1 insertion(+) --- a/arch/x86/entry/entry_64_compat.S +++ b/arch/x86/entry/entry_64_compat.S @@ -124,6 +124,7 @@ SYM_INNER_LABEL(entry_SYSENTER_compat_af jmp .Lsysenter_flags_fixed SYM_INNER_LABEL(__end_entry_SYSENTER_compat, SYM_L_GLOBAL) ANNOTATE_NOENDBR // is_sysenter_singlestep + int3 SYM_CODE_END(entry_SYSENTER_compat) =20 /* From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D311EC433EF for ; Thu, 26 May 2022 11:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237382AbiEZLE5 (ORCPT ); Thu, 26 May 2022 07:04:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347117AbiEZLD1 (ORCPT ); Thu, 26 May 2022 07:03:27 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A600CEBB1 for ; Thu, 26 May 2022 04:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=r2eMVpFl0Aac8ZRjWQ0+nV5mtEZevDgIYgdhVMNcaMU=; b=ddtwCTdp7TmAveVJV4GZ6oZ2EW DZ6hSBOhETw366mfCbUmUSceZ3TcxCj1fpTmOpY8gfM1z1Y7S+noMvxjDxra8ZlPQNAXnO8XephSN W12Ytvs7Ypz5/b4VPlcQYIGOqsw1qL7PQHp6e4RNKcNBWBV9XXwSNKb8faWL6D7JMj58j6LdmIW5Z 5l8lnknUq6946GsSfPeM6bj1znYJahzyHUR6jbFsSW4R7p6nYCNaOU3tG35Aoz6LISKPOeIEF+8fv l1RbiDQB8ecgVD4ZxgeU77SoIz3EA9AGWSngaLToKvIwOZLdPBi4gw8eFEqZk0b1HGisItOD2n9ti NMljld9g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001sVg-Jc; Thu, 26 May 2022 11:02:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 932E030003C; Thu, 26 May 2022 13:02:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 6DCBF2025FE5B; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105957.817269865@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:54 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com Subject: [PATCH 2/7] objtool: Extend UNWIND_HINT based ENDBR rules References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend the UNWIND hint driven rules for ENDBR placement. Currently objtool expects an ENDBR at any UNWINT_HINT_IRET_REGS that is at +0 of an STB_GLOBAL symbol, with the expectation that this is an exception entry point. Extend this to also expect ENDBR at UNWIND_HINT_EMPTY at +0 for STB_GLOBAL symbols, with the expectation that these are also machine entry points (SYSCALL et. al.). This guarantees all machine entry points are covered by objtool rules at the expense of a few additional false positives: vmlinux.o: warning: objtool: startup_64+0x0: UNWIND_HINT_EMPTY without EN= DBR vmlinux.o: warning: objtool: start_cpu0+0x0: UNWIND_HINT_EMPTY without EN= DBR Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/kernel/head_64.S | 2 ++ tools/objtool/check.c | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -43,6 +43,7 @@ L3_START_KERNEL =3D pud_index(__START_KERN .code64 SYM_CODE_START_NOALIGN(startup_64) UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR /* * At this point the CPU runs in 64bit mode CS.L =3D 1 CS.D =3D 0, * and someone has loaded an identity mapped page table @@ -371,6 +372,7 @@ SYM_CODE_END(secondary_startup_64) */ SYM_CODE_START(start_cpu0) UNWIND_HINT_EMPTY + ANNOTATE_NOENDBR movq initial_stack(%rip), %rsp jmp .Ljump_to_C_code SYM_CODE_END(start_cpu0) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1947,14 +1947,27 @@ static int read_unwind_hints(struct objt =20 insn->hint =3D true; =20 - if (opts.ibt && hint->type =3D=3D UNWIND_HINT_TYPE_REGS_PARTIAL) { + if (opts.ibt) { struct symbol *sym =3D find_symbol_by_offset(insn->sec, insn->offset); =20 - if (sym && sym->bind =3D=3D STB_GLOBAL && - insn->type !=3D INSN_ENDBR && !insn->noendbr) { - WARN_FUNC("UNWIND_HINT_IRET_REGS without ENDBR", - insn->sec, insn->offset); + if (!sym || sym->bind !=3D STB_GLOBAL) + goto no_entry; + + if (hint->type =3D=3D UNWIND_HINT_TYPE_CALL && !hint->sp_reg) { + if (insn->type !=3D INSN_ENDBR && !insn->noendbr) { + WARN_FUNC("UNWIND_HINT_EMPTY without ENDBR", + insn->sec, insn->offset); + } + } + + if (hint->type =3D=3D UNWIND_HINT_TYPE_REGS_PARTIAL) { + if (insn->type !=3D INSN_ENDBR && !insn->noendbr) { + WARN_FUNC("UNWIND_HINT_IRET_REGS without ENDBR", + insn->sec, insn->offset); + } } + +no_entry: ; } =20 if (hint->type =3D=3D UNWIND_HINT_TYPE_FUNC) { From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9277C433EF for ; Thu, 26 May 2022 11:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347137AbiEZLFO (ORCPT ); Thu, 26 May 2022 07:05:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347140AbiEZLDr (ORCPT ); Thu, 26 May 2022 07:03:47 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74227CEBBC for ; Thu, 26 May 2022 04:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=KxQbiJqE39w/Lon9YPgjSqo+uuElTNOmGV5qdrOKQk4=; b=OfWcQTauF2cUYKfuw8V3lKOLxH q32aVFzEkb1trFn6LQo00OUWp1SgVsxSk0M9jVmQTGYCRTldUr0BpKwSIeIjnWSB9x+24u/u+0VlX DBESt37jPYSB1UDFSsDR1XzBjhxeu6+n1VZbsD+4413bkHWqQAo4qlIGUWLdhwweFvh6Vfccqf266 XWNg1OaCan2swqRx+w6qHSIgA+nqjusrokCtEYuA3wRVyokiXwqa+0LbDysGXi0E2zrDq3C3IhNWU yaSCtiP363AhFqs6VbMMgTd9eyOM4FJ2pB5+70LmcP3Pp0gDHJLdSz7EJmDS/QvocFs8tYdZn7zIo wCXiHD/Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001sVe-Jm; Thu, 26 May 2022 11:02:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 94D8A300331; Thu, 26 May 2022 13:02:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 708B6202226AF; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105957.879581277@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:55 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com, kernel test robot Subject: [PATCH 3/7] objtool: Mark __ubsan_handle_builtin_unreachable() as noreturn References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" fs/ntfs3/ntfs3.prelink.o: warning: objtool: ni_read_frame() falls through= to next function ni_readpage_cmpr.cold() That is in fact: 000000000000124a : 124a: 44 89 e0 mov %r12d,%eax 124d: 0f b6 55 98 movzbl -0x68(%rbp),%edx 1251: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 1254: R_X86= _64_32S .data+0x1380 1258: 48 89 c6 mov %rax,%rsi 125b: e8 00 00 00 00 call 1260 125c: R_X86_64_PLT32 __ubsan_handle_shift_out_of_bounds-0x4 1260: 48 8d 7d cc lea -0x34(%rbp),%rdi 1264: e8 00 00 00 00 call 1269 1265: R_X86_64_PLT32 __tsan_read4-0x4 1269: 8b 45 cc mov -0x34(%rbp),%eax 126c: e9 00 00 00 00 jmp 1271 126d: R_X86_64_PC32 .text+0x19109 1271: 48 8b 75 a0 mov -0x60(%rbp),%rsi 1275: 48 63 d0 movslq %eax,%rdx 1278: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 127b: R_X86= _64_32S .data+0x13a0 127f: 89 45 88 mov %eax,-0x78(%rbp) 1282: e8 00 00 00 00 call 1287 1283: R_X86_64_PLT32 __ubsan_handle_shift_out_of_bounds-0x4 1287: 8b 45 88 mov -0x78(%rbp),%eax 128a: e9 00 00 00 00 jmp 128f 128b: R_X86_64_PC32 .text+0x19098 128f: 48 c7 c7 00 00 00 00 mov $0x0,%rdi 1292: R_X86= _64_32S .data+0x11f0 1296: e8 00 00 00 00 call 129b = 1297: R_X86_64_PLT32 __ubsan_handle_builtin_unreachable-0x4 000000000000129b : Tell objtool that __ubsan_handle_builtin_unreachable() is a noreturn. Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220502091514.GB479834@worktop.programming= .kicks-ass.net Acked-by: Marco Elver --- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -185,6 +185,7 @@ static bool __dead_end_function(struct o "stop_this_cpu", "__invalid_creds", "cpu_startup_entry", + "__ubsan_handle_builtin_unreachable", }; =20 if (!func) From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D641C433F5 for ; Thu, 26 May 2022 11:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344270AbiEZLFR (ORCPT ); Thu, 26 May 2022 07:05:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347107AbiEZLDq (ORCPT ); Thu, 26 May 2022 07:03:46 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DCCCEBB7 for ; Thu, 26 May 2022 04:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=wvAvvbNo0hvEaZFKbTa+ygMbbyVcho85Qv3DLuAb9qY=; b=Aiv+eZWJXCR+Oh1l2J65HSodgM kjBrssVNXSJNT0pVn1nRP+qCAaEKSdXfQ3KCQ7kZJ1MioBXVZPfLqjA8KX/R6cJjruvgExPItSk4r s7EH1DnlhuvM4M3LnGW+ek6Ziog8nnU6jsRSqgbRQ26/5cyvUnH2/NGMWcw9L7JDHxf91WjZrduYe JhhQkRUeLvTfEQ5bZpMYBCRbzuTFF4/0IUXBF9suSIcf03eiCyFOf+emBe+IjHFnfPPj5DnciaJLm yXK87a6Y2U6/JALtdxpyR7S6Gbu+LVZbp9XuJM1cWM/00lt0cRP8MLIsIxRWutxb0nW3NTKtDc2hW a8CKUr/A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001sVf-K3; Thu, 26 May 2022 11:02:54 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 9B32930047E; Thu, 26 May 2022 13:02:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7659C202226B8; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105957.944756116@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:56 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com, kernel test robot Subject: [PATCH 4/7] x86/cpu: Elide KCSAN for cpu_has() and friends References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As x86 uses the headers, the regular forms of all bitops are instrumented with explicit calls to KASAN and KCSAN checks. As these are explicit calls, these are not suppressed by the noinstr function attribute. This can result in calls to those check functions in noinstr code, which objtool warns about: vmlinux.o: warning: objtool: enter_from_user_mode+0x24: call to __kcsan_che= ck_access() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x28: call to __k= csan_check_access() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x24: cal= l to __kcsan_check_access() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x24: call to __= kcsan_check_access() leaves .noinstr.text section Prevent this by using the arch_*() bitops, which are the underlying bitops without explciit instrumentation. Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220502111216.290518605@infradead.org Acked-by: Marco Elver --- arch/x86/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -51,7 +51,7 @@ extern const char * const x86_power_flag extern const char * const x86_bug_flags[NBUGINTS*32]; =20 #define test_cpu_cap(c, bit) \ - test_bit(bit, (unsigned long *)((c)->x86_capability)) + arch_test_bit(bit, (unsigned long *)((c)->x86_capability)) =20 /* * There are 32 bits/features in each mask word. The high bits From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E629DC433F5 for ; Thu, 26 May 2022 11:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347112AbiEZLFK (ORCPT ); Thu, 26 May 2022 07:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347139AbiEZLDr (ORCPT ); Thu, 26 May 2022 07:03:47 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EB77CEBBB for ; Thu, 26 May 2022 04:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=h4yugi7MGC9HhqK+P+Qy2uOSAxdRIB0BRd6ZZtQsZsM=; b=G7vO3GgrwlwPwOubwtwibc3V2t ZRQqn2BH+yop7kEiZ5Cl99V9gBI97QgugG+Bmlt2aq/3ZFe0xIENhd+RExxDCGArhSTA9jrY3Ggdi woODtkpLUrQC8FmaRGwz1VLP1+dzGxf+IAPPXB842qcfIYDVd/slUSP+rXhWGq2g87XNwKQN+jxgd Yq2OWtCIWSRFYd/zQWEjMPNzVGpHj7w4PKGJnF3VHCS9A8rd6oIUYsrHbp1EJdjOOXEWtbUO+riRX sOdmjbOO9cXkFfr6oYsV8/rWE9sqaWP5nkxU+9/F+/Gh79TBn0DU3uIwAZRp5H81vPB/j4FjrbB+N 5tm/uDQw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001sVl-NF; Thu, 26 May 2022 11:02:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8FC353004AD; Thu, 26 May 2022 13:02:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7A4CA20221FA2; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105958.007232892@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:57 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com, kernel test robot Subject: [PATCH 5/7] jump_label,noinstr: Avoid instrumentation for JUMP_LABEL=n builds References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When building x86_64 with JUMP_LABEL=3Dn it's possible for instrumentation to sneak into noinstr: vmlinux.o: warning: objtool: exit_to_user_mode+0x14: call to static_key_cou= nt.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_exit_to_user_mode+0x2d: call to static= _key_count.constprop.0() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_exit_to_user_mode+0x1b: call to stati= c_key_count.constprop.0() leaves .noinstr.text section Switch to arch_ prefixed atomic to avoid the explicit instrumentation. Reported-by: kernel test robot Signed-off-by: Peter Zijlstra (Intel) Acked-by: Marco Elver --- include/linux/jump_label.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -256,9 +256,9 @@ extern void static_key_disable_cpuslocke #include #include =20 -static inline int static_key_count(struct static_key *key) +static __always_inline int static_key_count(struct static_key *key) { - return atomic_read(&key->enabled); + return arch_atomic_read(&key->enabled); } =20 static __always_inline void jump_label_init(void) From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECF54C433FE for ; Thu, 26 May 2022 11:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347090AbiEZLFG (ORCPT ); Thu, 26 May 2022 07:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345989AbiEZLDq (ORCPT ); Thu, 26 May 2022 07:03:46 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6C8CEBB9 for ; Thu, 26 May 2022 04:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=y5WjWRMaXuygUCB3tJA7/SRRsya1xYS0w6rnGVnFGLU=; b=CIXsMEYq9AGcMx1A4XI3hi3Yw8 x/puLJ9kQULe4YtHWE0IfXTr3R8eoHA+ecaa10yMZcux8Mkm127aRoWRVPuZPRnxQ/g9nRDNxv5aM PkuU5CJ5gCH2kZ4fsfFkts7oVmivOPwTGXHdNYN3e/gkAvPszvLrD45x/G2wDVB2XtjzbCIhuw2mu ajUFLa215yncBYeIQUP03bwmjfX03WaSjnMBk24MTkd4SQJgifiGHwKKkVJnF5vuw4KyHFvSMsjID PeClrI06RNPFmJFm4iOnEzCYbSJvsv2U65hQkzawfrIPQQ2RjWgkj27PzCDliQeg2UT+9pZbsM4Yp rzcXHYpA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001sVm-Nj; Thu, 26 May 2022 11:02:56 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8FC4F30066D; Thu, 26 May 2022 13:02:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 7EE6A20321F81; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105958.071435483@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:58 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com Subject: [PATCH 6/7] x86: Always inline on_thread_stack() and current_top_of_stack() References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Becaues GCC clearly lost it's marbles again... vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to on_thread_s= tack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to on_= thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: cal= l to on_thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to on= _thread_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: enter_from_user_mode+0x4e: call to current_top= _of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x53: call to cur= rent_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x4e: cal= l to current_top_of_stack() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x4e: call to cu= rrent_top_of_stack() leaves .noinstr.text section Signed-off-by: Peter Zijlstra (Intel) Acked-by: Marco Elver --- arch/x86/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -559,7 +559,7 @@ static __always_inline void native_swapg #endif } =20 -static inline unsigned long current_top_of_stack(void) +static __always_inline unsigned long current_top_of_stack(void) { /* * We can't read directly from tss.sp0: sp0 on x86_32 is special in @@ -569,7 +569,7 @@ static inline unsigned long current_top_ return this_cpu_read_stable(cpu_current_top_of_stack); } =20 -static inline bool on_thread_stack(void) +static __always_inline bool on_thread_stack(void) { return (unsigned long)(current_top_of_stack() - current_stack_pointer) < THREAD_SIZE; From nobody Wed Apr 29 00:33:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F527C433EF for ; Thu, 26 May 2022 11:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347133AbiEZLDp (ORCPT ); Thu, 26 May 2022 07:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347107AbiEZLDQ (ORCPT ); Thu, 26 May 2022 07:03:16 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F8ACEB9E for ; Thu, 26 May 2022 04:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=hrWj1TQzRXXNfBbwlPL8fBv3Cv5xKmT4kRjYFjpA0b8=; b=LPhC0XIJeHPEL3lzMrp71EjaRT RHi6MwUpTtIu0qZ31jnbU0JSDb9onf1s8LW5s+2l9mtA45ongpIt6MsVvs2gOTiJRzkbqkBC7r6i0 0aKqo+PiNl2gN1noyDODwhG8P5mtyWgW/orvwUHZD47dVEinEPbzs0TgYPJwzna5VMprvEMLrqCXo SgiS201R+1NAyluMckoCOq4PCcVbaj2pwbPf1qPPSPD1M9m5OES/1HMZn0rMENq5y8uscFrFLveA7 kyULDQSSIyUtfSYG3oTOsTskNosMPNpSnbWoJG7vDB3cal5t0K0IeLVH2uDJDxSFZjwXyic3rlwIr eIu9Xwlw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuBGX-001Bjx-Nq; Thu, 26 May 2022 11:02:53 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8FC1F3002AF; Thu, 26 May 2022 13:02:51 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 856332021C964; Thu, 26 May 2022 13:02:50 +0200 (CEST) Message-ID: <20220526105958.134113388@infradead.org> User-Agent: quilt/0.66 Date: Thu, 26 May 2022 12:52:59 +0200 From: Peter Zijlstra To: x86@kernel.org, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, elver@google.com, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, mark.rutland@arm.com Subject: [PATCH 7/7] context_tracking: Always inline empty stubs References: <20220526105252.440440893@infradead.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because GCC is seriously challenged.. vmlinux.o: warning: objtool: enter_from_user_mode+0x85: call to context_tra= cking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode+0x8f: call to con= text_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: syscall_enter_from_user_mode_prepare+0x85: cal= l to context_tracking_enabled() leaves .noinstr.text section vmlinux.o: warning: objtool: irqentry_enter_from_user_mode+0x85: call to co= ntext_tracking_enabled() leaves .noinstr.text section Signed-off-by: Peter Zijlstra (Intel) --- include/linux/context_tracking_state.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/include/linux/context_tracking_state.h +++ b/include/linux/context_tracking_state.h @@ -46,10 +46,10 @@ static __always_inline bool context_trac return __this_cpu_read(context_tracking.state) =3D=3D CONTEXT_USER; } #else -static inline bool context_tracking_in_user(void) { return false; } -static inline bool context_tracking_enabled(void) { return false; } -static inline bool context_tracking_enabled_cpu(int cpu) { return false; } -static inline bool context_tracking_enabled_this_cpu(void) { return false;= } +static __always_inline bool context_tracking_in_user(void) { return false;= } +static __always_inline bool context_tracking_enabled(void) { return false;= } +static __always_inline bool context_tracking_enabled_cpu(int cpu) { return= false; } +static __always_inline bool context_tracking_enabled_this_cpu(void) { retu= rn false; } #endif /* CONFIG_CONTEXT_TRACKING */ =20 #endif