From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JlnfF-00010E-3Y for qemu-devel@nongnu.org; Tue, 15 Apr 2008 12:05:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JlnfD-0000yx-8Q for qemu-devel@nongnu.org; Tue, 15 Apr 2008 12:05:44 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JlnfC-0000yr-V4 for qemu-devel@nongnu.org; Tue, 15 Apr 2008 12:05:42 -0400 Received: from gecko.sbs.de ([194.138.37.40]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JlnfC-0003U7-Ff for qemu-devel@nongnu.org; Tue, 15 Apr 2008 12:05:42 -0400 Received: from mail2.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m3FG5dMj010772 for ; Tue, 15 Apr 2008 18:05:39 +0200 Received: from [139.21.95.225] (mchn012c.mchh.siemens.de [139.21.95.225] (may be forged)) by mail2.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m3FG5dhH012532 for ; Tue, 15 Apr 2008 18:05:39 +0200 Message-ID: <4804D254.5040301@siemens.com> Date: Tue, 15 Apr 2008 18:05:40 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <47EE86E0.4070703@reactos.org> <9C7667CB-2CF0-4AC0-843B-6EF442196CAC@csgraf.de> <47F0B445.4030806@suse.de> In-Reply-To: <47F0B445.4030806@suse.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH] Reboot CPU on triple fault 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: > Alexander Graf schrieb: >> On Mar 29, 2008, at 7:13 PM, Herv=E9 Poussineau wrote: >> >>> Hi, >>> >>> On i386/x86-64, CPU must reboot when a triple fault is detected. >>> Attached patch implements this behaviour. >> So what exactly does check_exception() in target-i386/helper.c do then= ? >> Should the cpu_reset call go in there? >=20 > It definitely should. Besides, I'd really like to have the CPU dump on > triple faults retained. In most cases, this will be a lot more useful > than a silent reboot. As the same requirement came up here, I worked out the following patch. I feel a bit uneasy about it because o I'm unsure if breaking out of the exception loop is OK this way. o including necessary headers fails, mostly due to stdio redefinitions in dyngen-exec.h. This patch behaves as it should, but only in one specific test case. Feedback is welcome. (BTW, the original patch didn't work at all.) Signed-off-by: Jan Kiszka --- dyngen-exec.h | 1 + target-i386/helper.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) Index: b/dyngen-exec.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 Index: b/target-i386/helper.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1231,6 +1231,8 @@ void do_interrupt(int intno, int is_int, } } =20 +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,8 +1250,21 @@ static int check_exception(int intno, in fprintf(logfile, "check_exception old: %x new %x\n", env->old_exception, intno); =20 - if (env->old_exception =3D=3D EXCP08_DBLE) - cpu_abort(env, "triple fault"); + if (env->old_exception =3D=3D EXCP08_DBLE) { + fprintf(stderr, "qemu: warning: triple fault\n"); + 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); + } + cpu_dump_state(env, stderr, fprintf, X86_DUMP_FPU | X86_DUMP_CCO= P); + if (logfile) { + fprintf(logfile, "qemu: warning: triple fault\n"); + cpu_dump_state(env, logfile, fprintf, X86_DUMP_FPU | X86_DUM= P_CCOP); + } + qemu_system_reset_request(); + return 0; + } =20 if ((first_contributory && second_contributory) || (env->old_exception =3D=3D EXCP0E_PAGE &&