From 97a5ef664a9950acfe5ee83f562407f06300b705 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 13 Oct 2017 22:15:30 +0200 Subject: qemu: phase out bitbanging Although I was secretly proud of having figured out these unholy hacks, it turns out -no-reboot lets us do things in a platform-independent way. Suggested-by: Jann Horn --- src/tests/qemu/Makefile | 2 +- src/tests/qemu/init.c | 30 +++--------------------------- src/tests/qemu/kernel.config | 1 + 3 files changed, 5 insertions(+), 28 deletions(-) (limited to 'src/tests') diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile index 58c183a..fc1115f 100644 --- a/src/tests/qemu/Makefile +++ b/src/tests/qemu/Makefile @@ -82,7 +82,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 \ + -no-reboot \ -monitor none \ -kernel $< \ -append "console=hvc0" diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index e8d3de7..626ce6a 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -24,12 +24,9 @@ __attribute__((noreturn)) static void poweroff(void) { fflush(stdout); fflush(stderr); -#if defined(__x86_64__) || defined(__i386__) - ioperm(0x604, 2, 1); - outw(1U << 13, 0x604); -#endif - kill(-1, SIGKILL); - reboot(RB_POWER_OFF); + reboot(RB_AUTOBOOT); + sleep(30); + fprintf(stderr, "\x1b[37m\x1b[41m\x1b[1mFailed to power off!!!\x1b[0m\n"); exit(1); } @@ -110,26 +107,6 @@ 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; @@ -225,7 +202,6 @@ 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 c29435d..6de2fbe 100644 --- a/src/tests/qemu/kernel.config +++ b/src/tests/qemu/kernel.config @@ -80,6 +80,7 @@ CONFIG_DETECT_HUNG_TASK=y CONFIG_BOOTPARAM_HARDLOCKUP_PANIC=y CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y CONFIG_BOOTPARAM_HUNG_TASK_PANIC=y +CONFIG_PANIC_TIMEOUT=-1 CONFIG_STACKTRACE=y CONFIG_EARLY_PRINTK=y CONFIG_WIREGUARD=y -- cgit v1.2.3-59-g8ed1b