Blob Blame History Raw
From 3f36c94239658a79a4deeb84a2e0ebf005f083fc Mon Sep 17 00:00:00 2001
From: Michael Ellerman <mpe@ellerman.id.au>
Date: Fri, 13 Apr 2018 23:54:36 +1000
Subject: [PATCH] x86/pkeys: Add arch_pkeys_enabled()

References: FATE#322447, bsc#1078248
Patch-mainline: v4.18-rc1
Git-commit: 3f36c94239658a79a4deeb84a2e0ebf005f083fc

This will be used in future patches to check for arch support for
pkeys in generic code.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
 arch/x86/include/asm/pkeys.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/include/asm/pkeys.h b/arch/x86/include/asm/pkeys.h
index 0e5f749158e4..c1957f8f7c1b 100644
--- a/arch/x86/include/asm/pkeys.h
+++ b/arch/x86/include/asm/pkeys.h
@@ -7,6 +7,11 @@
 extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
 		unsigned long init_val);
 
+static inline bool arch_pkeys_enabled(void)
+{
+	return boot_cpu_has(X86_FEATURE_OSPKE);
+}
+
 /*
  * Try to dedicate one of the protection keys to be used as an
  * execute-only protection key.
-- 
2.13.6