x86/retbleed: Add fine grained Kconfig knobs
[platform/kernel/linux-rpi.git] / arch / x86 / Kconfig
index bd70e8a..a170cfd 100644 (file)
@@ -459,15 +459,6 @@ config GOLDFISH
        def_bool y
        depends on X86_GOLDFISH
 
        def_bool y
        depends on X86_GOLDFISH
 
-config RETPOLINE
-       bool "Avoid speculative indirect branches in kernel"
-       default y
-       help
-         Compile kernel with the retpoline compiler options to guard against
-         kernel-to-user data leaks by avoiding speculative indirect
-         branches. Requires a compiler with -mindirect-branch=thunk-extern
-         support for full protection. The kernel may run slower.
-
 config X86_CPU_RESCTRL
        bool "x86 CPU resource control support"
        depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
 config X86_CPU_RESCTRL
        bool "x86 CPU resource control support"
        depends on X86 && (CPU_SUP_INTEL || CPU_SUP_AMD)
@@ -1256,7 +1247,8 @@ config TOSHIBA
 
 config I8K
        tristate "Dell i8k legacy laptop support"
 
 config I8K
        tristate "Dell i8k legacy laptop support"
-       select HWMON
+       depends on HWMON
+       depends on PROC_FS
        select SENSORS_DELL_SMM
        help
          This option enables legacy /proc/i8k userspace interface in hwmon
        select SENSORS_DELL_SMM
        help
          This option enables legacy /proc/i8k userspace interface in hwmon
@@ -1310,7 +1302,7 @@ config MICROCODE
 
 config MICROCODE_INTEL
        bool "Intel microcode loading support"
 
 config MICROCODE_INTEL
        bool "Intel microcode loading support"
-       depends on MICROCODE
+       depends on CPU_SUP_INTEL && MICROCODE
        default MICROCODE
        help
          This options enables microcode patch loading support for Intel
        default MICROCODE
        help
          This options enables microcode patch loading support for Intel
@@ -1322,7 +1314,7 @@ config MICROCODE_INTEL
 
 config MICROCODE_AMD
        bool "AMD microcode loading support"
 
 config MICROCODE_AMD
        bool "AMD microcode loading support"
-       depends on MICROCODE
+       depends on CPU_SUP_AMD && MICROCODE
        help
          If you select this option, microcode patch loading support for AMD
          processors will be enabled.
        help
          If you select this option, microcode patch loading support for AMD
          processors will be enabled.
@@ -1518,6 +1510,7 @@ config AMD_MEM_ENCRYPT
        select ARCH_HAS_FORCE_DMA_UNENCRYPTED
        select INSTRUCTION_DECODER
        select ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
        select ARCH_HAS_FORCE_DMA_UNENCRYPTED
        select INSTRUCTION_DECODER
        select ARCH_HAS_RESTRICTED_VIRTIO_MEMORY_ACCESS
+       select ARCH_HAS_CC_PLATFORM
        help
          Say yes to enable support for the encryption of system memory.
          This requires an AMD processor that supports Secure Memory
        help
          Say yes to enable support for the encryption of system memory.
          This requires an AMD processor that supports Secure Memory
@@ -1525,7 +1518,6 @@ config AMD_MEM_ENCRYPT
 
 config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
        bool "Activate AMD Secure Memory Encryption (SME) by default"
 
 config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
        bool "Activate AMD Secure Memory Encryption (SME) by default"
-       default y
        depends on AMD_MEM_ENCRYPT
        help
          Say yes to have system memory encrypted by default if running on
        depends on AMD_MEM_ENCRYPT
        help
          Say yes to have system memory encrypted by default if running on
@@ -1918,6 +1910,7 @@ config EFI
        depends on ACPI
        select UCS2_STRING
        select EFI_RUNTIME_WRAPPERS
        depends on ACPI
        select UCS2_STRING
        select EFI_RUNTIME_WRAPPERS
+       select ARCH_USE_MEMREMAP_PROT
        help
          This enables the kernel to use EFI runtime services that are
          available (such as the EFI variable services).
        help
          This enables the kernel to use EFI runtime services that are
          available (such as the EFI variable services).
@@ -2393,6 +2386,88 @@ source "kernel/livepatch/Kconfig"
 
 endmenu
 
 
 endmenu
 
+config CC_HAS_SLS
+       def_bool $(cc-option,-mharden-sls=all)
+
+config CC_HAS_RETURN_THUNK
+       def_bool $(cc-option,-mfunction-return=thunk-extern)
+
+menuconfig SPECULATION_MITIGATIONS
+       bool "Mitigations for speculative execution vulnerabilities"
+       default y
+       help
+         Say Y here to enable options which enable mitigations for
+         speculative execution hardware vulnerabilities.
+
+         If you say N, all mitigations will be disabled. You really
+         should know what you are doing to say so.
+
+if SPECULATION_MITIGATIONS
+
+config PAGE_TABLE_ISOLATION
+       bool "Remove the kernel mapping in user mode"
+       default y
+       depends on (X86_64 || X86_PAE)
+       help
+         This feature reduces the number of hardware side channels by
+         ensuring that the majority of kernel addresses are not mapped
+         into userspace.
+
+         See Documentation/x86/pti.rst for more details.
+
+config RETPOLINE
+       bool "Avoid speculative indirect branches in kernel"
+       default y
+       help
+         Compile kernel with the retpoline compiler options to guard against
+         kernel-to-user data leaks by avoiding speculative indirect
+         branches. Requires a compiler with -mindirect-branch=thunk-extern
+         support for full protection. The kernel may run slower.
+
+config RETHUNK
+       bool "Enable return-thunks"
+       depends on RETPOLINE && CC_HAS_RETURN_THUNK
+       default y
+       help
+         Compile the kernel with the return-thunks compiler option to guard
+         against kernel-to-user data leaks by avoiding return speculation.
+         Requires a compiler with -mfunction-return=thunk-extern
+         support for full protection. The kernel may run slower.
+
+config CPU_UNRET_ENTRY
+       bool "Enable UNRET on kernel entry"
+       depends on CPU_SUP_AMD && RETHUNK
+       default y
+       help
+         Compile the kernel with support for the retbleed=unret mitigation.
+
+config CPU_IBPB_ENTRY
+       bool "Enable IBPB on kernel entry"
+       depends on CPU_SUP_AMD
+       default y
+       help
+         Compile the kernel with support for the retbleed=ibpb mitigation.
+
+config CPU_IBRS_ENTRY
+       bool "Enable IBRS on kernel entry"
+       depends on CPU_SUP_INTEL
+       default y
+       help
+         Compile the kernel with support for the spectre_v2=ibrs mitigation.
+         This mitigates both spectre_v2 and retbleed at great cost to
+         performance.
+
+config SLS
+       bool "Mitigate Straight-Line-Speculation"
+       depends on CC_HAS_SLS && X86_64
+       default n
+       help
+         Compile the kernel with straight-line-speculation options to guard
+         against straight line speculation. The kernel image might be slightly
+         larger.
+
+endif
+
 config ARCH_HAS_ADD_PAGES
        def_bool y
        depends on X86_64 && ARCH_ENABLE_MEMORY_HOTPLUG
 config ARCH_HAS_ADD_PAGES
        def_bool y
        depends on X86_64 && ARCH_ENABLE_MEMORY_HOTPLUG
@@ -2796,6 +2871,11 @@ config IA32_AOUT
 config X86_X32
        bool "x32 ABI for 64-bit mode"
        depends on X86_64
 config X86_X32
        bool "x32 ABI for 64-bit mode"
        depends on X86_64
+       # llvm-objcopy does not convert x86_64 .note.gnu.property or
+       # compressed debug sections to x86_x32 properly:
+       # https://github.com/ClangBuiltLinux/linux/issues/514
+       # https://github.com/ClangBuiltLinux/linux/issues/1141
+       depends on $(success,$(OBJCOPY) --version | head -n1 | grep -qv llvm)
        help
          Include code to run binaries for the x32 native 32-bit ABI
          for 64-bit processors.  An x32 process gets access to the
        help
          Include code to run binaries for the x32 native 32-bit ABI
          for 64-bit processors.  An x32 process gets access to the