endif
 endif
 
+# Initialize all stack variables with a pattern, if desired.
+ifdef CONFIG_INIT_STACK_ALL
+KBUILD_CFLAGS  += -ftrivial-auto-var-init=pattern
+endif
+
 DEBUG_CFLAGS   := $(call cc-option, -fno-var-tracking-assignments)
 
 ifdef CONFIG_DEBUG_INFO
 
 
 menu "Memory initialization"
 
+config CC_HAS_AUTO_VAR_INIT
+       def_bool $(cc-option,-ftrivial-auto-var-init=pattern)
+
 choice
        prompt "Initialize kernel stack variables at function entry"
        default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS
+       default INIT_STACK_ALL if COMPILE_TEST && CC_HAS_AUTO_VAR_INIT
        default INIT_STACK_NONE
        help
          This option enables initialization of stack variables at
                  of uninitialized stack variable exploits and information
                  exposures.
 
+       config INIT_STACK_ALL
+               bool "0xAA-init everything on the stack (strongest)"
+               depends on CC_HAS_AUTO_VAR_INIT
+               help
+                 Initializes everything on the stack with a 0xAA
+                 pattern. This is intended to eliminate all classes
+                 of uninitialized stack variable exploits and information
+                 exposures, even variables that were warned to have been
+                 left uninitialized.
+
 endchoice
 
 config GCC_PLUGIN_STRUCTLEAK_VERBOSE