From patchwork Thu Nov 3 07:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 13029656 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 AEFA9C433FE for ; Thu, 3 Nov 2022 07:51:48 +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=zoirFHH08EVXzUmEqLEgfa5l6/tyaA+z3PPUiargO0o=; b=2rmbzfvIhfyoq+ J0COP5oWRp/Y9aIwXDZktY+JZx9JDnUYoelLOFU/O3vyILrlvWDdgun3NL3H+4UEHRdRIPkFrWAgC HWQyTBzOzRonVWZYPExAo9nEeVx8wgB67oUtAupNNcRLBIPLqRVJt9X/pdK8jpGCvusg3+Y7iNXwz jjolCc4tNEP1+JUaaCD5rxX1QYyxs/Hz8/ar+0u3mJ2zKLCc5vvfjUFrRPO1/6R5zRbWAnSy0TfQu GReZ7XHbAmTISo/9I6sU/uv1mM9XAssJvG0KmdmjzAVa2v6L9WzrvQJOoqS9j0WPIe4fPGscQMc7D 53wKOWsI/bgieiRwMWnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqV0m-00GVgR-Og; Thu, 03 Nov 2022 07:51:40 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqV0j-00GVed-Ry for linux-riscv@lists.infradead.org; Thu, 03 Nov 2022 07:51:39 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 698A661CE2; Thu, 3 Nov 2022 07:51:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 698ABC43140; Thu, 3 Nov 2022 07:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667461893; bh=UWRf6k1PfAUbHEUQLKgVZxCb/1ojBTqpB23hi56utv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y/pE4IVV9ZdY0yBXNVi0Cy4HZ1t3rBh3CX68I7smmg2d4/uLuKMu8clGHMpt2htSc qGd34wlhQBKQvIpvCq46u4zxSZvUnye+n3/JTJ6FthMpAOF5AeJBX96meuRhsZU3b3 qjBIDAhW+CwL837W62u4+ryj/NpLq7Yin61tqNow1SnlMhcF4O0Xlvf62eXdt3EqDH rj6wZPCaoUP0azyskiGG8TK4MNR0dP+7e8izAD1f99g0iU+ijka6j9j6mk9O/BgiiN MZIPW9KryRuck8FGUzbfM4nVvYjFN4imkM5b7JA42W6Iud4UpdgXx14+zaij5sPEBh PICw5wmn7oM4Q== 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 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 V8 01/14] compiler_types.h: Add __noinstr_section() for noinstr Date: Thu, 3 Nov 2022 03:50:34 -0400 Message-Id: <20221103075047.1634923-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221103075047.1634923-1-guoren@kernel.org> References: <20221103075047.1634923-1-guoren@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221103_005137_966101_0D8FCC20 X-CRM114-Status: GOOD ( 11.73 ) 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 Signed-off-by: Lai Jiangshan Signed-off-by: Guo Ren --- 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__ */