From: Dave Hansen <dave.han...@linux.intel.com>

Currently, all of the checks for KAISER are compile-time checks.

Runtime checks are needed for turning it on/off at runtime.

Add a function to do that.

Signed-off-by: Dave Hansen <dave.han...@linux.intel.com>
Cc: Moritz Lipp <moritz.l...@iaik.tugraz.at>
Cc: Daniel Gruss <daniel.gr...@iaik.tugraz.at>
Cc: Michael Schwarz <michael.schw...@iaik.tugraz.at>
Cc: Richard Fellner <richard.fell...@student.tugraz.at>
Cc: Andy Lutomirski <l...@kernel.org>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Kees Cook <keesc...@google.com>
Cc: Hugh Dickins <hu...@google.com>
Cc: x...@kernel.org
---

 b/arch/x86/include/asm/kaiser.h |    5 +++++
 b/include/linux/kaiser.h        |    5 +++++
 2 files changed, 10 insertions(+)

diff -puN arch/x86/include/asm/kaiser.h~kaiser-dynamic-check-func 
arch/x86/include/asm/kaiser.h
--- a/arch/x86/include/asm/kaiser.h~kaiser-dynamic-check-func   2017-11-22 
15:45:55.262619723 -0800
+++ b/arch/x86/include/asm/kaiser.h     2017-11-22 15:45:55.267619723 -0800
@@ -56,6 +56,11 @@ extern void kaiser_remove_mapping(unsign
  */
 extern void kaiser_init(void);
 
+static inline bool kaiser_active(void)
+{
+       extern int kaiser_enabled;
+       return kaiser_enabled;
+}
 #endif
 
 #endif /* __ASSEMBLY__ */
diff -puN include/linux/kaiser.h~kaiser-dynamic-check-func 
include/linux/kaiser.h
--- a/include/linux/kaiser.h~kaiser-dynamic-check-func  2017-11-22 
15:45:55.264619723 -0800
+++ b/include/linux/kaiser.h    2017-11-22 15:45:55.268619723 -0800
@@ -28,5 +28,10 @@ static inline int kaiser_add_mapping(uns
 static inline void kaiser_add_mapping_cpu_entry(int cpu)
 {
 }
+
+static inline bool kaiser_active(void)
+{
+       return 0;
+}
 #endif /* !CONFIG_KAISER */
 #endif /* _INCLUDE_KAISER_H */
_

Reply via email to