From 892054946474eac2b1395b0a415713c2271e8b52 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Fri, 12 Jun 2020 13:22:58 -0700 Subject: [PATCH] qemu_x86: propagate exit reason code to the shell This helps distingush between fatal errors if logging isn't enabled. As detailed in comments, pass a reason code which controls the QEMU process' return value. Signed-off-by: Andrew Boie --- arch/x86/core/fatal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/core/fatal.c b/arch/x86/core/fatal.c index f4c6ddb32a9..99968897238 100644 --- a/arch/x86/core/fatal.c +++ b/arch/x86/core/fatal.c @@ -18,8 +18,15 @@ FUNC_NORETURN void arch_system_halt(unsigned int reason) /* Causes QEMU to exit. We passed the following on the command line: * -device isa-debug-exit,iobase=0xf4,iosize=0x04 + * + * For any value of the first argument X, the return value of the + * QEMU process is (X * 2) + 1. + * + * It has been observed that if the emulator exits for a triple-fault + * (often due to bad page tables or other CPU structures) it will + * terminate with 0 error code. */ - sys_out32(0, 0xf4); + sys_out32(reason, 0xf4); CODE_UNREACHABLE; } #endif