diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-02 02:11:52 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-02 02:45:53 +0200 |
commit | 98bdbe54510835f3f4460a1739a6162241992912 (patch) | |
tree | a841cf40ade793eaeb8c02926dc1e898c6b18500 /src/tests/qemu/init.c | |
parent | 07aed68928f3e76fc7d43488ee2b6165b748ebaf (diff) |
qemu: add watchdog for not hanging on oops
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/tests/qemu/init.c')
-rw-r--r-- | src/tests/qemu/init.c | 23 |
1 files changed, 22 insertions, 1 deletions
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)) |