Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1127871rwi; Thu, 3 Nov 2022 01:08:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7H+q4GUC45MUAnuWtdF3pc4D4HzMqg5OLxYi+Z3tnbgJOMWUcZlmMbfTN5D2pneED+Hken X-Received: by 2002:a17:906:66ce:b0:7ad:d178:c252 with SMTP id k14-20020a17090666ce00b007add178c252mr19776873ejp.158.1667462905628; Thu, 03 Nov 2022 01:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667462905; cv=none; d=google.com; s=arc-20160816; b=ZMb5gvEKuDCTpwhY/P/rYpVCq15mpGmHV5WLcZSLhi4fEOwB7kd8Ebc7hXV9DFt/T6 V8NhPOnK0D/ZYPtSoDFtjRUoW3GBl0VultQlmkjtYfYvRUGyxpx/Fk3K8MoBCIN0Fhey qwk4WQOYcByQt43FcXXcbvsEF6dlOlwFUNgT2RBP+0FmSnwhXfd0Epu8GsKxsPkWv4JK ZCSWiuzsYzvG6w8JYVmQXZRqymFtp/5juNGUYfZI8lxUA6sdD3lWH/WeBGNJY6M9t3uE hk1UtubUcg5kpXvXLxyoNIOXWUIttK8ikdgqer+hAhX0xORaoj9Zinb3ZKl5IDW94M5U /VzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T2ZPedmY9IUVfxN2G2k0uSKKzQZ4WKyz61rKsnBT4g4=; b=RqKBrg885rUvZ8IXxeVxu+7swu9uvFvUq2hpk3LJXLNjGw7f+a7RofQyeK5YSmDrIr OgPJXKI1A+2FnzWl9jv+oed8zWjChP0aUMh0a5rUF74C1VFz5aMuGflW6m03HSZ+5TMd mAG5QRSHiyrKEZVgvtbNNfKmwI6IAdyq7HbbrCl4etQQ178Lqsyz3AsJv1VolVUlklO/ 4kVOGGnOUK6aYyLGX8gCyr6LKHdCnrO9EZ92mRry66SxB84ZbLQLxnb2CXFIY4WHCEnE BDjxo1+WekvMSncRz0DunBOJe1DCEpb11kgpj9yBm8TNDMjXzJQVevYs9d/mnld59XZB hznA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Y/pE4IVV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm6-20020a0564020b0600b00461a32e0e38si424175edb.306.2022.11.03.01.08.00; Thu, 03 Nov 2022 01:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Y/pE4IVV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231290AbiKCHvq (ORCPT + 98 others); Thu, 3 Nov 2022 03:51:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbiKCHvh (ORCPT ); Thu, 3 Nov 2022 03:51:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F675FC8; Thu, 3 Nov 2022 00:51:36 -0700 (PDT) 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 2C9BEB8269B; Thu, 3 Nov 2022 07:51:35 +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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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__ */ -- 2.36.1