Skip to content
Permalink
Browse files
x86/cpu: Enable Key Locker and add a chicken bit
Introduce a new config option to include the enabling codes at build-time.

Also, add a new command-line parameter -- 'nokeylocker' to disable the
feature at boot-time.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Cc: x86@kernel.org
Cc: linux-doc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
  • Loading branch information
ChangSeokBae authored and nanli2x committed Dec 2, 2021
1 parent f892866 commit a3595cf89d33d08bb53ff3e31160e3f1fb45a1e5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
@@ -3226,6 +3226,8 @@

nohugeiomap [KNL,X86,PPC,ARM64] Disable kernel huge I/O mappings.

nokeylocker [X86] Disables Key Locker hardware feature.

nosmt [KNL,S390] Disable symmetric multithreading (SMT).
Equivalent to smt=1.

@@ -1886,6 +1886,20 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS

If unsure, say y.

config X86_KL
prompt "Key Locker" if EXPERT
def_bool y
depends on CPU_SUP_INTEL
help
Key Locker is a new security feature to protect a data-encryption
key for the Advanced Encryption Standard (AES) algorithm.

When enabled, every CPU has a unique internal key to wrap the AES
key into an encoded format. The internal key is not accessible
to software once loaded.

If unsure, say y.

choice
prompt "TSX enable mode"
depends on CPU_SUP_INTEL
@@ -44,7 +44,11 @@
# define DISABLE_OSPKE (1<<(X86_FEATURE_OSPKE & 31))
#endif /* CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS */

#define DISABLE_KL (1<<(X86_FEATURE_KL & 31))
#ifdef CONFIG_X86_KL
# define DISABLE_KL 0
#else
# define DISABLE_KL (1<<(X86_FEATURE_KL & 31))
#endif

#ifdef CONFIG_X86_5LEVEL
# define DISABLE_LA57 0
@@ -355,6 +355,23 @@ static __always_inline void setup_umip(struct cpuinfo_x86 *c)
/* These bits should not change their value after CPU init is finished. */
static const unsigned long cr4_pinned_mask =
X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP | X86_CR4_FSGSBASE;

static __init int x86_nokeylocker_setup(char *arg)
{
/* Expect an exact match without trailing characters */
if (strlen(arg))
return 0;

if (!cpu_feature_enabled(X86_FEATURE_KL) ||
!boot_cpu_has(X86_FEATURE_KL))
return 1;

setup_clear_cpu_cap(X86_FEATURE_KL);
pr_info("x86/keylocker: Disabled by kernel command line\n");
return 1;
}
__setup("nokeylocker", x86_nokeylocker_setup);

static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);
static unsigned long cr4_pinned_bits __ro_after_init;

0 comments on commit a3595cf

Please sign in to comment.