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: 27578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp710930wrr; Tue, 29 Nov 2022 19:45:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pcpnaqOK3Gd78gckY7ZxDeNBAMteASK5y6HmRW7/kAv3GPPaJZIz8VH+h7fFoLS8rJ0PE X-Received: by 2002:a63:7143:0:b0:46f:918e:7338 with SMTP id b3-20020a637143000000b0046f918e7338mr36401269pgn.8.1669779906044; Tue, 29 Nov 2022 19:45:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669779906; cv=none; d=google.com; s=arc-20160816; b=E8BbFKDMrmAnVHLltslkLwGPRtWc8+434hAAf2qeFmwCgtLb9U4kdvZrEWIlqau+6O ZCW2x1kfoh0dzSw+B2eCEzK2neMgXGpzVd02gEpdmnACTu7hONwSbMtJAkb2WAN0/bJf qoHcju3mJUrnlj6YNpJRN2LDICXRNapdo/2jKrHTx/+kRe+klnVCtNJHDWRY6Ej8I4R+ 4wAisGiqqKQdmwGoRy3+tWYuo5jM+Ai6D04eUPN1n5IxL7iCX5fApDmNbeXgItoBN2bC pdkb9RjuDQYA+fb2Na2/EdzMQSm3tRtPc/fxZ1SL18jC4HC7fzbv+zOQIHWbceFenreJ xWZA== 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=dbmkjF25LLt/ETXimVIxv5KnZq8TU3Qg+CLQrCkyO1Q=; b=Hc4YDXE9hRuhgyp69hr88REGtSTGymC4/Ry5WUgclhVV//9uIxLbMuCgvWCtY2lb2R ZrGugWQMoumanH/5nUROyTD77gI37feuVMg0DJuOyevtsNmwAki0cWueeEPrBNfym/vF m30ZHGhvESJO4Kh9yVO/fz9deAEe+1yDgACTAwR1z94ZCvPwRWGnJUuDUnRwh+N6cy3j Q+pkY9Ca15ZW7KZZs+FWF8picEgGYCYr755NpJq+ntpicXkRUAB3BAKaoCNGJ5S0OZx8 tjp6fEeMrEl08TJxxg0VEAaGgtyPQF+NHP0mRswaCGNqJTolZu3dT1HpQe8LK61hmuu8 B0AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q+H0TCip; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 78-20020a630751000000b0047857ac64aesi168110pgh.352.2022.11.29.19.44.52; Tue, 29 Nov 2022 19:45:06 -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=Q+H0TCip; 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 S232938AbiK3DmG (ORCPT + 99 others); Tue, 29 Nov 2022 22:42:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbiK3Dl5 (ORCPT ); Tue, 29 Nov 2022 22:41:57 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BADF74607; Tue, 29 Nov 2022 19:41:56 -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 9DC1E619E3; Wed, 30 Nov 2022 03:41:55 +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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750891134442186558?= X-GMAIL-MSGID: =?utf-8?q?1750891134442186558?= 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__ */