[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220516131739.521817-2-jiangshanlai@gmail.com>
Date: Mon, 16 May 2022 21:17:32 +0800
From: Lai Jiangshan <jiangshanlai@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
Lai Jiangshan <jiangshan.ljs@...group.com>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
Joerg Roedel <jroedel@...e.de>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Miguel Ojeda <ojeda@...nel.org>,
Kees Cook <keescook@...omium.org>,
Nathan Chancellor <nathan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexei Starovoitov <ast@...nel.org>,
Marco Elver <elver@...gle.com>, Hao Luo <haoluo@...gle.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: [PATCH V2 1/7] x86/entry: Introduce __entry_text for entry code written in C
From: Lai Jiangshan <jiangshan.ljs@...group.com>
Some entry code will be implemented in C files.
Introduce __entry_text to set them in .entry.text section.
The new __entry_text disables instrumentation like noinstr, so
__noinstr_section() is added for noinstr and the new __entry_text.
Note, entry code can not access to %gs before the %gs base is switched
to kernel %gs base, so stack protector can not be used on the C entry
code. But __entry_text doesn't disable stack protector since some
compilers might not support function level granular attribute to
disable stack protector. It will be disabled in C file level.
Cc: Borislav Petkov <bp@...en8.de>
Reviewed-by: Miguel Ojeda <ojeda@...nel.org>
Reviewed-by: Kees Cook <keescook@...omium.org>
Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
Suggested-by: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Lai Jiangshan <jiangshan.ljs@...group.com>
---
arch/x86/include/asm/idtentry.h | 3 +++
include/linux/compiler_types.h | 8 +++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h
index 72184b0b2219..acc4c99f801c 100644
--- a/arch/x86/include/asm/idtentry.h
+++ b/arch/x86/include/asm/idtentry.h
@@ -13,6 +13,9 @@
#include <asm/irq_stack.h>
+/* Entry code written in C. */
+#define __entry_text __noinstr_section(".entry.text")
+
/**
* DECLARE_IDTENTRY - Declare functions for simple IDT entry points
* No error code pushed by hardware
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 1c2c33ae1b37..1d6580ccb081 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -225,9 +225,11 @@ struct ftrace_likely_data {
#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
+#define __noinstr_section(section) \
+ noinline notrace __section(section) __no_kcsan \
+ __no_sanitize_address __no_profile __no_sanitize_coverage
+
+#define noinstr __noinstr_section(".noinstr.text")
#endif /* __KERNEL__ */
--
2.19.1.6.gb485710b
Powered by blists - more mailing lists