kasan: replicate x86 xen failure Kasan does not work on Xen right now. It does work on bare metal and kvm though. The reason for this is it does not have the same setup work as done on early init for x86, as x86's bare metal early init. It needs some work. Additionally, you currently cannot disable kasan at run time and even if you could we wouldn't know that Xen was the reason why this would be failing. We have no way to annotate this at run time on bootup for users or even developers. We'd want to annotate this to create developer awareness over the requirements of such features which require mucking with different init entries and to prevent code which should be dead from running. The work we'll do next will transform kasan to the use the table init work, we'll also make use of the existing boot protocol subarch work added through x86 boot protocol 2.08, and add capability support to the init tables to be able to annotate when a general x86 feature currenly lacks support for a boot run time environment, identified through the subarch. Current simulation which shows sucess on x86 and a replicated issue when booting xen: Bare metal simulation: mcgrof@ergon ~/devel/table-init (git::master)$ ./main Initializing x86 bare metal world Number of init entries: 4 Initializing Memory ... Completed initializing Memory ! Initializing PCI buses ... Completed initializing PCI buses ! Initializing ACME(TM) Driver ... Completed initializing ACME(TM) Driver ! Early init for Kasan... Booting bare metal Calling start_kernel()... Calling setup_arch work for Kasan... Xen simulation: mcgrof@ergon ~/devel/table-init (git::master)$ ./main -x Number of init entries: 4 Initializing Memory ... Completed initializing Memory ! Initializing PCI buses ... Completed initializing PCI buses ! Initializing ACME(TM) Driver ... Completed initializing ACME(TM) Driver ! Initializing Xen Driver ... Completed initializing Xen Driver ! Initializing Xen guest Booting a Xen guest Calling start_kernel()... Kasan was not set up... ---------------------------------------------------------- BUG on kasan_init at kasan.c: 24 Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
diff --git a/kasan.c b/kasan.c index 5f6ef85..8a22998 100644 --- a/kasan.c +++ b/kasan.c
@@ -2,6 +2,7 @@ #include <unistd.h> #include <errno.h> #include "init.h" +#include "kernel.h" static bool __is_kasan_setup = false; @@ -16,8 +17,15 @@ return __is_kasan_setup; } -void setup_arch_kasan(void) { - if (!is_kasan_setup()) - return; +int kasan_init(void) +{ + if (!__is_kasan_setup) { + printf("Kasan was not set up...\n"); + BUG(); + return -EINVAL; + } + printf("Calling setup_arch work for Kasan...\n"); + + return 0; }
diff --git a/kasan.h b/kasan.h index 9f7656b..2c0971b 100644 --- a/kasan.h +++ b/kasan.h
@@ -1,5 +1,5 @@ #include <stdbool.h> int kasan_early_init(void); -void setup_arch_kasan(void); +int kasan_init(void); bool is_kasan_setup(void);
diff --git a/kernel.h b/kernel.h new file mode 100644 index 0000000..76a15c3 --- /dev/null +++ b/kernel.h
@@ -0,0 +1,7 @@ +#include <stdio.h> + +#define BUG() do { \ + fprintf(stderr, "----------------------------------------------------------\n"); \ + fprintf (stderr, "BUG on %s at %s: %i\n", __func__, __FILE__, __LINE__); \ +} \ +while (0)
diff --git a/x86.c b/x86.c index 3c2b8b9..6c46649 100644 --- a/x86.c +++ b/x86.c
@@ -66,6 +66,5 @@ void setup_arch(void) { setup_arch_init(); - if (is_kasan_setup()) - setup_arch_kasan(); + kasan_init(); }