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/init.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src/tests/qemu/init.c') 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)) -- cgit v1.2.3-59-g8ed1b