From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jm70H-0003Pm-HB for qemu-devel@nongnu.org; Wed, 16 Apr 2008 08:44:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jm70F-0003Ow-Qh for qemu-devel@nongnu.org; Wed, 16 Apr 2008 08:44:44 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jm70F-0003Ot-IP for qemu-devel@nongnu.org; Wed, 16 Apr 2008 08:44:43 -0400 Received: from lizzard.sbs.de ([194.138.37.39]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Jm70F-0002Yk-50 for qemu-devel@nongnu.org; Wed, 16 Apr 2008 08:44:43 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by lizzard.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m3GCieSs019349 for ; Wed, 16 Apr 2008 14:44:41 +0200 Received: from [139.21.95.227] (mchn012c.mchh.siemens.de [139.21.95.227] (may be forged)) by mail1.sbs.de (8.12.6/8.12.6) with ESMTP id m3GCieQh014660 for ; Wed, 16 Apr 2008 14:44:40 +0200 Message-ID: <4805F4B0.5020802@siemens.com> Date: Wed, 16 Apr 2008 14:44:32 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <47EE86E0.4070703@reactos.org> <9C7667CB-2CF0-4AC0-843B-6EF442196CAC@csgraf.de> <47F0B445.4030806@suse.de> <4804D254.5040301@siemens.com> In-Reply-To: <4804D254.5040301@siemens.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] x86: Reboot CPU on triple fault - Version 3 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Here comes a version that may hopefully make everyone happy: :) Reset on triple fault, but only dump the CPU state to stderr and logfile if -triple-fault was given as command line option. Signed-off-by: Jan Kiszka --- dyngen-exec.h | 1 + target-i386/helper.c | 24 ++++++++++++++++++++++-- vl.c | 9 +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) Index: b/dyngen-exec.h =================================================================== --- a/dyngen-exec.h +++ b/dyngen-exec.h @@ -86,6 +86,7 @@ typedef struct FILE FILE; extern int fprintf(FILE *, const char *, ...); extern int fputs(const char *, FILE *); extern int printf(const char *, ...); +extern FILE *stderr; #undef NULL #define NULL 0 Index: b/target-i386/helper.c =================================================================== --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1231,6 +1231,10 @@ void do_interrupt(int intno, int is_int, } } +/* This should come from sysemu.h - if we could include it here... */ +void qemu_system_reset_request(void); +extern int warn_on_triple_fault; + /* * Check nested exceptions and change to double or triple fault if * needed. It should only be called, if this is not an interrupt. @@ -1248,8 +1252,24 @@ static int check_exception(int intno, in fprintf(logfile, "check_exception old: %x new %x\n", env->old_exception, intno); - if (env->old_exception == EXCP08_DBLE) - cpu_abort(env, "triple fault"); + if (env->old_exception == EXCP08_DBLE) { + if(env->intercept & INTERCEPT_SVM_MASK) { + /* most probably the virtual machine should not + be shut down but rather caught by the VMM */ + vmexit(SVM_EXIT_SHUTDOWN, 0); + } + if (warn_on_triple_fault) { + fprintf(stderr, "qemu: warning: triple fault\n"); + cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP); + if (logfile) { + fprintf(logfile, "qemu: warning: triple fault\n"); + cpu_dump_state(env, logfile, fprintf, + X86_DUMP_FPU | X86_DUMP_CCOP); + } + } + qemu_system_reset_request(); + return EXCP_HLT; + } if ((first_contributory && second_contributory) || (env->old_exception == EXCP0E_PAGE && Index: b/vl.c =================================================================== --- a/vl.c +++ b/vl.c @@ -200,6 +200,7 @@ CharDriverState *serial_hds[MAX_SERIAL_P CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; #ifdef TARGET_I386 int win2k_install_hack = 0; +int warn_on_triple_fault = 0; #endif int usb_enabled = 0; static VLANState *first_vlan; @@ -7730,6 +7731,7 @@ static void help(int exitcode) "-std-vga simulate a standard VGA card with VESA Bochs Extensions\n" " (default is CL-GD5446 PCI VGA)\n" "-no-acpi disable ACPI\n" + "-triple-fault enable CPU state dump on triple fault\n" #endif #ifdef CONFIG_CURSES "-curses use a curses/ncurses interface instead of SDL\n" @@ -7852,6 +7854,7 @@ enum { QEMU_OPTION_old_param, QEMU_OPTION_clock, QEMU_OPTION_startdate, + QEMU_OPTION_triple_fault, }; typedef struct QEMUOption { @@ -7964,6 +7967,9 @@ const QEMUOption qemu_options[] = { #endif { "clock", HAS_ARG, QEMU_OPTION_clock }, { "startdate", HAS_ARG, QEMU_OPTION_startdate }, +#if defined(TARGET_I386) + { "triple-fault", 0, QEMU_OPTION_triple_fault }, +#endif { NULL }, }; @@ -8702,6 +8708,9 @@ int main(int argc, char **argv) case QEMU_OPTION_win2k_hack: win2k_install_hack = 1; break; + case QEMU_OPTION_triple_fault: + warn_on_triple_fault = 1; + break; #endif #ifdef USE_KQEMU case QEMU_OPTION_no_kqemu: