summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2024-02-05 16:48:43 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-07-18 13:18:31 +0200
commit6ac66ef65320d193ec8c9eae46963848678eda1a (patch)
treee45ca12bef05d7ed7d75d998cb646c0a7c214ff5 /include
parentcac15753b8ceb505a3c646f83a86dccbab9e33a3 (diff)
downloadlinux-6ac66ef65320d193ec8c9eae46963848678eda1a.tar.gz
linux-6ac66ef65320d193ec8c9eae46963848678eda1a.tar.bz2
linux-6ac66ef65320d193ec8c9eae46963848678eda1a.zip
Compiler Attributes: Add __uninitialized macro
commit fd7eea27a3aed79b63b1726c00bde0d50cf207e2 upstream. With INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO enabled the kernel will be compiled with -ftrivial-auto-var-init=<...> which causes initialization of stack variables at function entry time. In order to avoid the performance impact that comes with this users can use the "uninitialized" attribute to prevent such initialization. Therefore provide the __uninitialized macro which can be used for cases where INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO is enabled, but only selected variables should not be initialized. Acked-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20240205154844.3757121-2-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/compiler_attributes.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index ae4c9579ca5f..efe5e8067652 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -322,6 +322,18 @@
#define __section(section) __attribute__((__section__(section)))
/*
+ * Optional: only supported since gcc >= 12
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-uninitialized-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#uninitialized
+ */
+#if __has_attribute(__uninitialized__)
+# define __uninitialized __attribute__((__uninitialized__))
+#else
+# define __uninitialized
+#endif
+
+/*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-unused-type-attribute
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute