As of now, I have not been successful on installing my on vecbase. Even if I generate a trivial vecbase that just jumps to the code in the original vecbase, it does not work.
The following code crashes if an NMI happens after my vecbase is installed. Any ideas?
__asm__ __volatile__ (
"j function_entry\n" // jump over the vecbase
".align 16\n"
"vecbase_mod:\n" // root of the modified vecbase
"nop\n"
".align 16\n" // vecbase + 0x10 - debug exception
"debug_exception_mod:\n"
"j 0x40100010\n"
".align 16\n"
"nmi_exception_mod:\n" // vecbase + 0x20 - NMI exception
"j 0x40100020\n"
".align 16\n" // vecbase + 0x30 - kernel exception
"kernel_exception_mod:\n"
"j 0x40100030\n"
".align 16\n"
"nop\n"
".align 16\n" // vecbase + 0x50 - user exception
"user_exception_mod:\n"
"j 0x40100050\n"
".align 16\n" // vecbase + 0x70 - user exception
"nop\n"
".align 16\n"
"double_exception_mod:\n"
"j 0x40100070\n"
".align 16\n" // vecbase + 0x90 - reset vector (?)
"nop\n"
".align 16\n"
"panic_exception_mod:\n"
"j 0x40100090\n"
"function_entry:\n"
"movi a2, vecbase_mod\n"
"wsr.vecbase a2" // install modified vecbase
:
:
: "a2", "memory"
);