qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH] Reboot CPU on triple fault


From: Jan Kiszka
Subject: [Qemu-devel] Re: [PATCH] Reboot CPU on triple fault
Date: Tue, 15 Apr 2008 18:05:40 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080226)

Kevin Wolf wrote:
> Alexander Graf schrieb:
>> On Mar 29, 2008, at 7:13 PM, Hervé 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?
> 
> 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 <address@hidden>
---
 dyngen-exec.h        |    1 +
 target-i386/helper.c |   19 +++++++++++++++++--
 2 files changed, 18 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,8 @@ void do_interrupt(int intno, int is_int,
     }
 }
 
+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);
 
-    if (env->old_exception == EXCP08_DBLE)
-        cpu_abort(env, "triple fault");
+    if (env->old_exception == 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_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 0;
+    }
 
     if ((first_contributory && second_contributory)
         || (env->old_exception == EXCP0E_PAGE &&




reply via email to

[Prev in Thread] Current Thread [Next in Thread]