@@ -279,3 +279,8 @@ endchoice
config FRAME_POINTER
depends on !UNWINDER_ORC && !UNWINDER_GUESS
bool
+
+config X86_CET_TEST
+ depends on m
+ depends on X86_KERNEL_IBT
+ tristate "in-kernel CET testing module"
@@ -149,6 +149,7 @@ obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o
obj-$(CONFIG_AMD_MEM_ENCRYPT) += sev.o
obj-$(CONFIG_X86_KERNEL_FINEIBT) += fineibt.o
+obj-$(CONFIG_X86_CET_TEST) += cet_test.o
###
# 64 bit specific files
new file mode 100644
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/module.h>
+
+static int cet_test_init(void)
+{
+ pr_info("CET test, expect faults\n");
+
+ // FIXME: use register_die_notifier
+
+ asm volatile(
+ "lea 1f(%%rip), %%rax\n"
+ "jmp *%%rax\n"
+ "nop\n"
+ "1:\n"
+ /* no endbranch */
+ "nop\n"
+ :::"rax"
+ );
+ return 0;
+}
+
+static void cet_test_exit(void)
+{
+}
+
+module_init(cet_test_init);
+module_exit(cet_test_exit);
+
+MODULE_LICENSE("GPL v2");