Message ID | 20230222033021.983168-2-guoren@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp363282wrd; Tue, 21 Feb 2023 19:37:20 -0800 (PST) X-Google-Smtp-Source: AK7set9yrszBuqFoGP7qIz2uceTu3jytLJNnGhz0cpHqU3U3C80kObKSPz2VlF57X6oAwMxTqgxK X-Received: by 2002:a17:903:245:b0:19a:973b:b60b with SMTP id j5-20020a170903024500b0019a973bb60bmr7059860plh.25.1677037039732; Tue, 21 Feb 2023 19:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677037039; cv=none; d=google.com; s=arc-20160816; b=TH1QWKXLhMvK0X0daq4+8VY6QilKtPioWwmTbIvuDyh0nwc3qs22Z7FGdrmkQsd3oX zRppITs1NSHTQ0jYoqd8GcCXcsxBicjMMWo2qPUKaMiR8LmbAZKIiG2/EOYMK/JYuV3l wcR/j75Bmi85qyyK5oclYSzaafCuf4eIfkwr1E11FzeXWooj1D9OyuMLyiOXE9ivK69Y EMLDqYHwBp5dcKyGzKxAY8kpagR7iJOVpbxm2VcDZgOuQ6wZYYdr6zKfOwBu3Kdz7m7V MrrujJbkzmx0NxjHRxUtg5++RWL2agCvwcQq4hWS7+ax2C9DLKncLTUPtdkYzauQMgk1 82wA== 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=W2XfLVhA5KD8s9oguGExPFEEwTaOR3vnnXMv3ypjECxE7zxh61otqO+Bsp1GXnAaJn pyOQu8FQxqkKzmKMG6xOGKMGAKrnZqqotVEW/oa6B+z8nIjHXq3pVQgX3YqFQaNNez3V 5txv+X8OVYWE0YWi112iQqkQ1CGr6pmOVrMPlHLJyxrXuP8qWH5Xho9CKkOfuY9gDcOi G5CzI2eN4bQtKlo3KT0qlU0zdrHDlRdsX+b/y3nV51qW6sQVax/nPLCamxqku2NgsDOW FucyZDR10WbBySd+xl5tBZ+ZUr687IzCszG9mB6yABq6vjn42pvb4nIF67C+JCSU2UnD CNgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H6160hfc; 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 21-20020a170902c21500b00198de88a67fsi13568058pll.39.2023.02.21.19.37.07; Tue, 21 Feb 2023 19:37:19 -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=H6160hfc; 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 S230154AbjBVDbF (ORCPT <rfc822;hanasaki@gmail.com> + 99 others); Tue, 21 Feb 2023 22:31:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbjBVDbA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Feb 2023 22:31:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C64305EF; Tue, 21 Feb 2023 19:30:58 -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 93CE561200; Wed, 22 Feb 2023 03:30:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67812C4339E; Wed, 22 Feb 2023 03:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677036657; bh=YqOQcx7krUe87k6vBeiLe+HR095OSbjNEu/uluKhLMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H6160hfcKH01BiNRi4e+qr/N58FoomeLjiCUX7L8MAxJK1UflNFYnO/sSQhci37UW nnXKpGANVGHDCmP5YMek6z3zbRhK1sRA2En66Vp2kZITdBtdvegcFMCe+Xyczuuoye sXpOHTRE7IkuB/JKtbit9njwr4iYGeOg/UH4eGdPy5k0OXm9RiaeIjgjK0+qaMszZH sZVUZW4mXbHQeo3p8WkeknGAE8P4uqbT6+Hs532rkWXDm5bNEhVb60vHso+7C1KeEE v+5rp6LUgjBhRHkPkDy1cRjxmg8rI37PiszFIVC/eiEAQSnQR9Gl4cKlKXxeA3Cjgm BbGL2IVVhkLew== 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, palmer@dabbelt.com Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Lai Jiangshan <laijs@linux.alibaba.com>, Nick Desaulniers <ndesaulniers@google.com>, Miguel Ojeda <ojeda@kernel.org>, Kees Cook <keescook@chromium.org>, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn@rivosinc.com> Subject: [PATCH -next V17 1/7] compiler_types.h: Add __noinstr_section() for noinstr Date: Tue, 21 Feb 2023 22:30:15 -0500 Message-Id: <20230222033021.983168-2-guoren@kernel.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20230222033021.983168-1-guoren@kernel.org> References: <20230222033021.983168-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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758500790878803388?= X-GMAIL-MSGID: =?utf-8?q?1758500790878803388?= |
Series |
riscv: Add GENERIC_ENTRY support
|
|
Commit Message
Guo Ren
Feb. 22, 2023, 3:30 a.m. UTC
From: Lai Jiangshan <laijs@linux.alibaba.com> 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 <ndesaulniers@google.com> Suggested-by: Peter Zijlstra <peterz@infradead.org> Reviewed-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Tested-by: Jisheng Zhang <jszhang@kernel.org> Tested-by: Guo Ren <guoren@kernel.org> Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> --- include/linux/compiler_types.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
Comments
guoren@kernel.org writes: > From: Lai Jiangshan <laijs@linux.alibaba.com> > > 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. Guo, the generic entry series doesn't apply cleanly on riscv/for-next >6.2-rc1, and this patch is the issue. Could you do a respin (potentially w/o this patch)? Cheers, Björn
On Wed, Feb 22, 2023 at 11:56 AM <guoren@kernel.org> wrote: > > From: Lai Jiangshan <laijs@linux.alibaba.com> > > 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 <ndesaulniers@google.com> > Suggested-by: Peter Zijlstra <peterz@infradead.org> > Reviewed-by: Miguel Ojeda <ojeda@kernel.org> > Reviewed-by: Kees Cook <keescook@chromium.org> > Reviewed-by: Björn Töpel <bjorn@rivosinc.com> > Tested-by: Jisheng Zhang <jszhang@kernel.org> > Tested-by: Guo Ren <guoren@kernel.org> > Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> > Signed-off-by: Guo Ren <guoren@kernel.org> Hello The change has been made upstream as a part of the commit 2b5a0e425e6e(objtool/idle: Validate __cpuidle code as noinstr). https://lore.kernel.org/r/20230112195540.373461409@infradead.org Thanks Lai > --- > 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 >
On Wed, Mar 22, 2023 at 10:46 PM Björn Töpel <bjorn@kernel.org> wrote: > > guoren@kernel.org writes: > > > From: Lai Jiangshan <laijs@linux.alibaba.com> > > > > 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. > > Guo, the generic entry series doesn't apply cleanly on > riscv/for-next >6.2-rc1, and this patch is the issue. It has been merged in palmer/for-next. Thx for taking care. 54b3948f381c (HEAD -> for-next, palmer/for-next) Merge patch series "riscv: Add GENERIC_ENTRY support" 45b32b946a97 riscv: entry: Consolidate general regs saving/restoring ab9164dae273 riscv: entry: Consolidate ret_from_kernel_thread into ret_from_fork 0bf298ad2b61 riscv: entry: Remove extra level wrappers of trace_hardirqs_{on,off} f0bddf50586d riscv: entry: Convert to generic entry d0db02c62879 riscv: entry: Add noinstr to prevent instrumentation inserted 8574bf8d0ddd riscv: ptrace: Remove duplicate operation > > Could you do a respin (potentially w/o this patch)? > > > Cheers, > Björn
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__ */