2022-11-03 08:08:25

by Guo Ren

[permalink] [raw]
Subject: [PATCH -next V8 01/14] compiler_types.h: Add __noinstr_section() for noinstr

From: Lai Jiangshan <[email protected]>

And it will be extended for C entry code.

Cc: Borislav Petkov <[email protected]>
Reviewed-by: Miguel Ojeda <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Suggested-by: Nick Desaulniers <[email protected]>
Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Lai Jiangshan <[email protected]>
Signed-off-by: Guo Ren <[email protected]>
---
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__ */
--
2.36.1



2022-12-05 09:34:42

by Björn Töpel

[permalink] [raw]
Subject: Re: [PATCH -next V8 01/14] compiler_types.h: Add __noinstr_section() for noinstr

[email protected] writes:

> From: Lai Jiangshan <[email protected]>
>
> And it will be extended for C entry code.

It would be nice with a more elaborative commit message.