diff options
Diffstat (limited to 'src/tests/qemu')
-rw-r--r-- | src/tests/qemu/Makefile | 1 | ||||
-rw-r--r-- | src/tests/qemu/init.c | 23 | ||||
-rw-r--r-- | src/tests/qemu/kernel.config | 1 |
3 files changed, 24 insertions, 1 deletions
diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile index 225bb1c..24952bd 100644 --- a/src/tests/qemu/Makefile +++ b/src/tests/qemu/Makefile @@ -81,6 +81,7 @@ qemu: $(KERNEL_BZIMAGE) -device virtconsole,chardev=stdio \ -chardev file,id=status,path=$(BUILD_PATH)/result \ -device virtserialport,chardev=status \ + -watchdog ib700 -watchdog-action poweroff \ -monitor none \ -kernel $< \ -append "console=hvc0" diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index ea578c1..130fd0e 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -20,7 +20,7 @@ #include <linux/random.h> #include <linux/version.h> - __attribute__((noreturn)) static void poweroff(void) +__attribute__((noreturn)) static void poweroff(void) { fflush(stdout); fflush(stderr); @@ -112,6 +112,26 @@ static void enable_logging(void) close(fd); } +static void watchdog(void) +{ + pretty_message("[+] Enabling watchdog timer..."); + + ioperm(0x443, 1, 1); + outb(14, 0x443); + + if (fork()) + return; + + setpriority(PRIO_PROCESS, 0, -20); + + for (;;) { + outb(14, 0x443); + sleep(1); + } + + _exit(0); +} + static void kmod_selftests(void) { FILE *file; @@ -191,6 +211,7 @@ int main(int argc, char *argv[]) if (uname(&utsname) < 0) panic("uname"); print_banner(&utsname); + watchdog(); mount_filesystems(); kmod_selftests(); if (!linux_4_8_or_higher(&utsname)) diff --git a/src/tests/qemu/kernel.config b/src/tests/qemu/kernel.config index e6016d0..10de485 100644 --- a/src/tests/qemu/kernel.config +++ b/src/tests/qemu/kernel.config @@ -70,5 +70,6 @@ CONFIG_PRINTK_TIME=y CONFIG_BLK_DEV_INITRD=y CONFIG_LEGACY_VSYSCALL_NONE=y CONFIG_KERNEL_GZIP=y +CONFIG_PANIC_ON_OOPS=y CONFIG_WIREGUARD=y CONFIG_WIREGUARD_DEBUG=y |