Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp10785082rwl; Thu, 12 Jan 2023 02:30:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtIF2yWJbMm0CAF/QSBkJQCAUbIjRv6BD8zi2g65Eg7kBx9pQB4wdYv6G9I2VbL7onSd0Ik X-Received: by 2002:aa7:91d4:0:b0:588:32ce:eea4 with SMTP id z20-20020aa791d4000000b0058832ceeea4mr13153706pfa.15.1673519405262; Thu, 12 Jan 2023 02:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673519405; cv=none; d=google.com; s=arc-20160816; b=W7klkt5sVSdB0YTGvo+I7ifFfBTSPABR+M4Jb9BR7ifAhajKe3FTRRFtb5yU0nXpQe vcULP6sjUz/u69mLhCyqBj/4F0BQzGiBDy/cPYv8EqFS7lux989g0o0DgWG7ZDPMXyGr PPilVlkzbFhmYkl1IA5CYMsqJXlePfBlFGl23xZu19fkwlrTtk6QU5Xs+jK89h5v6rJf 0/4DL+jZ41qULq+Pg6nTgjan446FLYIss5WHqoYaJRmX3ns02y/GfwDx0+6zzBYZ/i7B B1rV2QSr2IPfCKxBoPQgK4MIur6agQ/KMQNz9vm+rgvxGBSf/exycc2nHX97PfOX2/Bv 1Yeg== 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=882N5kPyz5Iu3B048L5CJXSWFwyMUDkDVuR5YzqG7H4=; b=1H28tBUYA+iVj9M3PxYXD/vhDAA1zdy/Mlxput/3tJJQPwVMM3wkeH5r87BaoqzV7F D8LUer7nGa/4B2Upr8w9U25IaCjFo+gQvD4xlsFLVppwzp/Q5f7jyn7CtZaEFaehCSD9 Bj3u88NoMM+DNv5Iho+r+dTcVB/SRBakLbERXxhleA4Op5CLW9cYkr+Z0X/UelpyEg+4 DOpbijjcYUjI1GeZUQS0H/QE3TF14+TirL5VcXwu2vycDyjp10QLVHHAoGrf5mU5sQng CZKAoYBrMoSYAOOPCDivqcakuJhB4rzh536sfeoRBx7eNdea42P5enf3l/YvFhDDBtY6 LRzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G3LUoS2y; 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 d145-20020a621d97000000b0056cb8f67eefsi16425842pfd.70.2023.01.12.02.29.59; Thu, 12 Jan 2023 02:30:05 -0800 (PST) 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=G3LUoS2y; 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 S236847AbjALKB1 (ORCPT + 51 others); Thu, 12 Jan 2023 05:01:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbjALKAj (ORCPT ); Thu, 12 Jan 2023 05:00:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0C92613; Thu, 12 Jan 2023 01:59:13 -0800 (PST) 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 F047761FC9; Thu, 12 Jan 2023 09:59:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4F8EC433F1; Thu, 12 Jan 2023 09:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673517552; bh=lEoTBcehc8n4upJA5LC+k+yiIJ7hxcNhFuHkvMT2WVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G3LUoS2yPQhhieChvQkuzMhUaKk2EO8QVQJltwWKfuWZ+SkkbXA5RK5CtTE7nc0A0 XAzoI6vnjxVWDwoce1t5aSAEbem8n6gB5HeQ+VO816eSfconfnXfEY1hVTUlV5Asgx VHC/dX3bPnFeD1WbtW5SgPoV+r70IrO8Xrs4pebhxhjtza71Nn9rX7pzqk/sGX0zBD 79RK7mOHm1yj17Vc5rYmwuRdmpxLsNjMI+hKQF56Pwrp/+NdaXyhhyMwV7jIkWpayj TF+UTsn4KxSqTRumiZ6F6ildmH/UVGa76/tA4cpcRotzezxXnQHv30hYFOQagyMlBq 3KR5+v3ZjdmGA== 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, mark.rutland@arm.com, ben@decadent.org.uk, bjorn@kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Lai Jiangshan , Borislav Petkov , Miguel Ojeda , Kees Cook , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Nick Desaulniers Subject: [PATCH -next V14 1/7] compiler_types.h: Add __noinstr_section() for noinstr Date: Thu, 12 Jan 2023 04:58:42 -0500 Message-Id: <20230112095848.1464404-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230112095848.1464404-1-guoren@kernel.org> References: <20230112095848.1464404-1-guoren@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.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 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. Cc: Borislav Petkov Reviewed-by: Miguel Ojeda Reviewed-by: Kees Cook Reviewed-by: Björn Töpel 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 7c1afe0f4129..0a2ca5755be7 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -231,12 +231,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