From patchwork Wed Nov 30 03:40:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13059414 X-Patchwork-Delegate: palmer@dabbelt.com 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6369C352A1 for ; Wed, 30 Nov 2022 03:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QTEGUlGdt6kMOXskxbjFRuPrq9ABLaoJclnBBXJcwA0=; b=z5JKe8uDVD9Eqr 7PDMJZjv5VlcaGdJfrL78SWdXZ8pcRHiHCQb8Np8v5U0Eet+lTjABWt7niBXGR6ZBQFCEn+KGMPdC qUbrznz3nQz6E7kCKaJ5xnUTsTePhvQ4ORufXJoCGFCWz1Rl9dTGH08G3OUca1OLRSgwrrnOFwXY7 p+e0S1p/bJvnmL7aeAEEgBZyxj2NWV8X+dwliiNA2167A8G8cHWbvmLhRNi4ujYLuZXP29Ff1Y+fe r8D/4sc1RFt5j/m/DRkfHJZ/tKlBy0FAkACL1WPugPvMURgLJDyW6Xi9X/KCkL467jPl30A8mw4+R gC2u0hqgxcFZgV6x89kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0Dz1-00Ce0F-RT; Wed, 30 Nov 2022 03:42:03 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0Dyy-00CdvI-Qy for linux-riscv@lists.infradead.org; Wed, 30 Nov 2022 03:42:02 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3636B81886; Wed, 30 Nov 2022 03:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52995C4347C; Wed, 30 Nov 2022 03:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669779715; bh=Rp2MUyQtxRgtLen/D9AxwqyQ4SMPFbQjQmCooVN6ibA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+H0TCip7J/GdXqeJB3/PshKOWVSgdxej0Gx0aW2VMcgQtndJjKnrIARYQ7PL6j2/ Km7MiBuPgy3wDtdkLX85r0I4EQ3SyzZpwveP0fzBLjIXg3glGg6dl/X1odMOa7DRsU i/9kk0MCt7V8/9Wwy5iIHWioXkMa3cNTn5CgeM0bBojBvzCEN0iKiL601f+dZx+Nbz GZpBBTPZdAUvCNSWyz70pwmwgqcU12EUm4xhU57CLVb1K5uxs2wP/YugwDfwFzgLPj rF1B6NfBALuzGXnBavYDi0MA8MN8qGZ9sqCG6TIEiZ/AG1BaagPJeziDunoll/tNP/ Qj7xpJxaaLhsQ== From: guoren@kernel.org To: arnd@arndb.de, guoren@kernel.org, palmer@rivosinc.com, tglx@linutronix.de, peterz@infradead.org, luto@kernel.org, conor.dooley@microchip.com, heiko@sntech.de, jszhang@kernel.org, lazyparser@gmail.com, falcon@tinylab.org, chenhuacai@kernel.org, apatel@ventanamicro.com, atishp@atishpatra.org, palmer@dabbelt.com, paul.walmsley@sifive.com, mark.rutland@arm.com, zouyipeng@huawei.com, bigeasy@linutronix.de, David.Laight@aculab.com, chenzhongjin@huawei.com, greentime.hu@sifive.com, andy.chiu@sifive.com, ben@decadent.org.uk Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Lai Jiangshan , Borislav Petkov , Miguel Ojeda , Kees Cook , Nick Desaulniers Subject: [PATCH -next V9 01/14] compiler_types.h: Add __noinstr_section() for noinstr Date: Tue, 29 Nov 2022 22:40:46 -0500 Message-Id: <20221130034059.826599-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221130034059.826599-1-guoren@kernel.org> References: <20221130034059.826599-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221129_194201_074906_19BA6CF9 X-CRM114-Status: GOOD ( 11.78 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Lai Jiangshan And it will be extended for C entry code. Cc: Borislav Petkov Reviewed-by: Miguel Ojeda Reviewed-by: Kees Cook Suggested-by: Nick Desaulniers Suggested-by: Peter Zijlstra Tested-by: Jisheng Zhang Tested-by: Guo Ren Signed-off-by: Guo Ren Signed-off-by: Lai Jiangshan --- include/linux/compiler_types.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index eb0466236661..41e4faa4cd95 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -230,12 +230,19 @@ struct ftrace_likely_data { #define __no_sanitize_or_inline __always_inline #endif -/* Section for code which can't be instrumented at all */ -#define noinstr \ - noinline notrace __attribute((__section__(".noinstr.text"))) \ - __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage \ +/* + * Using __noinstr_section() doesn't automatically disable all instrumentations + * on the section. Inhibition for some instrumentations requires extra code. + * I.E. KPROBES explicitly avoids instrumenting on .noinstr.text. + */ +#define __noinstr_section(section) \ + noinline notrace __section(section) __no_profile \ + __no_kcsan __no_sanitize_address __no_sanitize_coverage \ __no_sanitize_memory +/* Section for code which can't be instrumented at all */ +#define noinstr __noinstr_section(".noinstr.text") + #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */