From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JmrEK-0002mK-4p for qemu-devel@nongnu.org; Fri, 18 Apr 2008 10:06:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JmrEH-0002kK-WC for qemu-devel@nongnu.org; Fri, 18 Apr 2008 10:06:19 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmrEH-0002k8-Sx for qemu-devel@nongnu.org; Fri, 18 Apr 2008 10:06:17 -0400 Received: from wr-out-0506.google.com ([64.233.184.225]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JmrEH-0000qZ-No for qemu-devel@nongnu.org; Fri, 18 Apr 2008 10:06:17 -0400 Received: by wr-out-0506.google.com with SMTP id c49so349033wra.19 for ; Fri, 18 Apr 2008 07:06:16 -0700 (PDT) Message-ID: <4808AAD3.5080405@codemonkey.ws> Date: Fri, 18 Apr 2008 09:06:11 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] x86: Reboot CPU on triple fault - Version 6 References: <47EE86E0.4070703@reactos.org> <9C7667CB-2CF0-4AC0-843B-6EF442196CAC@csgraf.de> <47F0B445.4030806@suse.de> <4804D254.5040301@siemens.com> <4805F4B0.5020802@siemens.com> <4806009E.8060407@suse.de> <48060ACC.2020309@siemens.com> <48060E28.7000606@suse.de> <480613D3.3080509@suse.de> In-Reply-To: <480613D3.3080509@suse.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 Kevin Wolf wrote: > Quite a few rounds for such a short patch. But surely a CPU dump without > any explanation isn't optimal. We should put a "CPU Reset" line in the > log before the dump. > > Signed-off-by: Kevin Wolf > > Index: dyngen-exec.h > =================================================================== > --- dyngen-exec.h (Revision 4215) > +++ dyngen-exec.h (Arbeitskopie) > @@ -86,6 +86,7 @@ > extern int fprintf(FILE *, const char *, ...); > extern int fputs(const char *, FILE *); > extern int printf(const char *, ...); > +extern FILE *stderr; > This is unnecessary. > #undef NULL > #define NULL 0 > > Index: exec.c > =================================================================== > --- exec.c (Revision 4215) > +++ exec.c (Arbeitskopie) > @@ -1259,6 +1259,8 @@ > #ifdef TARGET_I386 > { CPU_LOG_PCALL, "pcall", > "show protected mode far calls/returns/exceptions" }, > + { CPU_LOG_RESET, "cpu_reset", > + "show CPU state before CPU resets" }, > #endif > #ifdef DEBUG_IOPORT > { CPU_LOG_IOPORT, "ioport", > Index: target-i386/helper.c > =================================================================== > --- target-i386/helper.c (Revision 4215) > +++ target-i386/helper.c (Arbeitskopie) > @@ -1231,6 +1231,9 @@ > } > } > > +/* This should come from sysemu.h - if we could include it here... */ > +void qemu_system_reset_request(void); > + > /* > * Check nested exceptions and change to double or triple fault if > * needed. It should only be called, if this is not an interrupt. > @@ -1248,9 +1251,20 @@ > 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 (loglevel & CPU_LOG_RESET) > + fprintf(logfile, "Triple fault\n"); > + > + qemu_system_reset_request(); > This isn't the right function to use here. If we supported ACPI shutdown, this would generate an ACPI shutdown request. You probably want to just do: cpu_interrupt(env, CPU_INTERRUPT_EXIT); Regards, Anthony Liguori > + return EXCP_HLT; > + } > + > if ((first_contributory && second_contributory) > || (env->old_exception == EXCP0E_PAGE && > (second_contributory || (intno == EXCP0E_PAGE)))) { > Index: target-i386/helper2.c > =================================================================== > --- target-i386/helper2.c (Revision 4215) > +++ target-i386/helper2.c (Arbeitskopie) > @@ -362,6 +362,11 @@ > void cpu_reset(CPUX86State *env) > { > int i; > + > + if (loglevel & CPU_LOG_RESET) { > + fprintf(logfile, "CPU Reset (CPU %d)\n", env->cpu_index); > + cpu_dump_state(env, logfile, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP); > + } > > memset(env, 0, offsetof(CPUX86State, breakpoints)); > > Index: cpu-all.h > =================================================================== > --- cpu-all.h (Revision 4215) > +++ cpu-all.h (Arbeitskopie) > @@ -779,6 +779,7 @@ > #define CPU_LOG_PCALL (1 << 6) > #define CPU_LOG_IOPORT (1 << 7) > #define CPU_LOG_TB_CPU (1 << 8) > +#define CPU_LOG_RESET (1 << 9) > > /* define log items */ > typedef struct CPULogItem { >