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: 14719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp378798wru; Thu, 3 Nov 2022 00:54:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Oo7IxvX07qcALKSVWsiNo3iiz1tzR5EP299e8iRDPcDf0G77Uwgmy21P/Pyd0zY56mw2z X-Received: by 2002:a05:6a00:4ac3:b0:56d:6e51:60eb with SMTP id ds3-20020a056a004ac300b0056d6e5160ebmr20471884pfb.58.1667462057004; Thu, 03 Nov 2022 00:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667462056; cv=none; d=google.com; s=arc-20160816; b=RYz9fMwqsuOmeQJti5zJCgZQJgHn8SXC0j6+GXSzw3xQuCONvTcVO/8qm7OOaOpoUC kNdATGILm5EVZIQwSiZ+0sRxuJO/01zsJCWkX2qW24r8xvHvPre28ccWTFUbhC35kC7H 7cL4jdO2z+LAbFASWlGziDuvhIHZ2P0W3ROOuRiCTNXsQtyyBWGCU/VMcXluVgQb5vZr VsVg/KMK31POu24VNbF76FRF/fKz/5JL+OIXNUg1Ov1TPnwyCUQgf+aQIUU9zhR6QZZp tnVfW8Pjcah+5d3ld282TDxdc1PfK+2DHfArXnkRxTr6hfcFswN6d0kaibOvrgr3l8b5 yvOA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a17090a760b00b00205d58e9125si380260pjk.68.2022.11.03.00.54.03; Thu, 03 Nov 2022 00:54:16 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748460694084921188?= X-GMAIL-MSGID: =?utf-8?q?1748460694084921188?= 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__ */