From patchwork Sat Feb 4 07:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guo Ren X-Patchwork-Id: 52743 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1235382wrn; Fri, 3 Feb 2023 23:05:21 -0800 (PST) X-Google-Smtp-Source: AK7set9ZQLcZs1Aj2IHBfRRlXuB7WeUDewjCGjVRyz/SjJbYkGbcg01/pKqVOoZnqlyY7xFDwDLv X-Received: by 2002:a17:902:ecc9:b0:196:3e2c:4741 with SMTP id a9-20020a170902ecc900b001963e2c4741mr15690230plh.12.1675494321580; Fri, 03 Feb 2023 23:05:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675494321; cv=none; d=google.com; s=arc-20160816; b=y8A2JJ+onIGbti0I2leTlHfCiXAdjQAOHaW7qNuIynsYlrsdZI3Jpmcq9i42kMZOc7 RdBKLPQ7Pp5K3nRH1nPwj+c8bPeC+Euf3R4bYWEs2EvBI1WgdW7atBlyUM/I51WoSZHE lc49H/8e6F7qoepbJCPQakpzbbMwUMZ05jbllV1SLt+P4g1fA/hRXHIzOZ8D2T+orCg4 0k5nrNjQLDmwOZgMMj1q0mhxVLlV0dsAVv4kRVkdNKVfUc/yDgjRQWz31sevUheOvLXc E9IO6xtI7S94K5bUFEzRqU4IpONEMc4+OKF7FXljM0KHxS7ToS0pAI/FLMvB5bXsiMOm Abfg== 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=yGm1XHCAblFq80FL+2s1Kr+GMT+ihBh1vdI2wJAQgOU=; b=sLDztOdB2yvZDtIml859BSQ2luPVmY9OjHMMEBts+H55pOUqDaQbuzaO4Ejt1auvS4 v3c1JQoLtOEJjFO5U4JJtYgDjv59nc/mnKHbUkCERmARoPHtv7Ki1qcpvfMTaPzm5Cwv DDscP7vkSKbmixvonjakTYMIdyqAx8G+QG3ObfTQoa3C3opUVWzjuBAdpkr5QSpLdEx6 BHZRWXMBSGei6mlD2OPgSuwuSWhZ8nGnT3qZYa+NjTYxy0gFEeVMMlgypygiily4SRe7 wAmWeUj1hKtdABVcW8xUZ4sL0ekqRSUndVcJDk/SvVke46D0TQ9hqlNtX0bHlg8vXbX0 //ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g8KA3ZA1; 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 j3-20020a170903028300b00198e0aa6c41si4864299plr.450.2023.02.03.23.05.09; Fri, 03 Feb 2023 23:05:21 -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=g8KA3ZA1; 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 S231654AbjBDHDQ (ORCPT + 99 others); Sat, 4 Feb 2023 02:03:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjBDHDM (ORCPT ); Sat, 4 Feb 2023 02:03:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0851DB94; Fri, 3 Feb 2023 23:03:10 -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 DBDD560917; Sat, 4 Feb 2023 07:03:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88A48C4339E; Sat, 4 Feb 2023 07:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675494189; bh=YqOQcx7krUe87k6vBeiLe+HR095OSbjNEu/uluKhLMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g8KA3ZA1hhMqEu+tI6Z8FSQm7L/FGKauZbpLMV+Phc6ePXF/JYuG+H6QW6faK39Qt wGeO6PJ+wvwNHzGpx9dqbnFxEch0iOxaskMzAaT2efIuMr6KBE4DHDnl1XhC0zHWj2 1F6wvJdZxkXNMEBnT3sw39PYU8ofbFOyiAZqAnUAy6q0vMJVC+iLVobN+MS9Vbx8t8 v2+bpgihmJipnAVKTjwDmjCiA8YrzKk3djbrnWugwFK5W/vgZClzyoHuRzUtUSGGRu RC/gLBCmH1RM+Vxt87WVQ1CWDTOTm0R5ToDRX/57coPl04xmF/99XGoRq75ue/29Wz 4I5oX4MiBDrtQ== 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, miguel.ojeda.sandonis@gmail.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Lai Jiangshan , Nick Desaulniers , Miguel Ojeda , Kees Cook , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= Subject: [PATCH -next V16 1/7] compiler_types.h: Add __noinstr_section() for noinstr Date: Sat, 4 Feb 2023 02:02:07 -0500 Message-Id: <20230204070213.753369-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230204070213.753369-1-guoren@kernel.org> References: <20230204070213.753369-1-guoren@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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?1756883133432496453?= X-GMAIL-MSGID: =?utf-8?q?1756883133432496453?= 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. Suggested-by: Nick Desaulniers Suggested-by: Peter Zijlstra Reviewed-by: Miguel Ojeda Reviewed-by: Kees Cook Reviewed-by: Björn Töpel Tested-by: Jisheng Zhang Tested-by: Guo Ren 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 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__ */