Getting QEMU to dump registers on triple fault

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Getting QEMU to dump registers on triple fault

Post by ixos »

When I started testing my OS with qemu, it would produce a dump of the cpu registers when it triple faulted.

Code: Select all

qemu: fatal: triple fault
EAX=00000000 EBX=0000002a ECX=deadbeef EDX=00000000
... etc ...
Now it just silently reboots (or silently quits with -no-reboot).
I'm not sure what changed or when (I haven't had triple faults in a while), so I'm not sure how to fix this.
Is there a way to get the old, useful behavior back?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

Triple faults are occasionally used for intentional CPU resets and in such cases you don't want qemu to exit. So the old behaviour was wrong and you can't get exactly the same back.

If you need the information for debugging, use the debug log with -d cpu_reset (or actually you probably also want to log exceptions, so -d int,cpu_reset).
Developer of tyndur - community OS of Lowlevel (German)
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Re: Getting QEMU to dump registers on triple fault

Post by ixos »

I got this:

Code: Select all

CPU Reset (CPU 0)
EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000000
... snip ...
XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
Triple fault
Everything is zero and the debugging information ends up in /tmp/.
How do I get it print the CPU state before the triple fault?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

Ignore the first two resets, they are actually the inital state after the CPU is powered on. The CPU state dumped after the "Triple fault" message is the right one, and that works fine for me (except that -d cpu_reset is broken in current git master, reporting this now...)
Developer of tyndur - community OS of Lowlevel (German)
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Re: Getting QEMU to dump registers on triple fault

Post by ixos »

Kevin wrote:... -d cpu_reset is broken ...
I assume that is why I get no log output after "Triple fault"?
Well thanks for your help, at least; I'm going to try to find a version of qemu that reacts correctly to triple faults; I'll post here if I find anything.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

ixos wrote:
Kevin wrote:... -d cpu_reset is broken ...
I assume that is why I get no log output after "Triple fault"?
No, it wouldn't recognise cpu_reset as a valid logging option at all. The problem doesn't exist on releases or older git snapshots.

Which qemu version are you using?
Developer of tyndur - community OS of Lowlevel (German)
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Re: Getting QEMU to dump registers on triple fault

Post by ixos »

version 0.12.5

Code: Select all

qemu -fda image.bin -boot a -m 128 -no-reboot -d cpu_reset
No error for me; seems to be silently ignoreing it.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

Drop the -no-reboot. It makes qemu exit before the CPU reset happens, and therefore the reset isn't logged.
Developer of tyndur - community OS of Lowlevel (German)
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Re: Getting QEMU to dump registers on triple fault

Post by ixos »

Huh. That got it to sort-of work, but now I have several megabytes of identical log messages in /tmp/qemu.log. How do I get it quit on triple fault (and preferably print the dump to stderr)?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

By patching qemu? ;)

If you don't leave qemu running after you got the triple fault, you can certainly be quick enough with closing it before the log file grows to several megabytes. Yes, my log files sometimes do have the logs of five reboots. So what?
Developer of tyndur - community OS of Lowlevel (German)
ixos
Posts: 6
Joined: Mon Jul 02, 2012 9:39 pm

Re: Getting QEMU to dump registers on triple fault

Post by ixos »

My OS is crashing in the boot loader (I turned on optimization and it seems to have swapped the order of .text and .rodata); also I have fast cpu and a really slow brain (thats why I got into programming). :wink:
Thanks for your help though; hopefully I'll be able to add some junk to the test script to extract the dump from /tmp/qemu.log.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by Kevin »

ixos wrote:My OS is crashing in the boot loader (I turned on optimization and it seems to have swapped the order of .text and .rodata); also I have fast cpu and a really slow brain (thats why I got into programming). :wink:
Heh, good point. You needto put /tmp on a floppy, obviously, so it will match your speed again. ;)
Developer of tyndur - community OS of Lowlevel (German)
xyzzy
Member
Member
Posts: 391
Joined: Wed Jul 25, 2007 8:45 am
Libera.chat IRC: aejsmith
Location: London, UK
Contact:

Re: Getting QEMU to dump registers on triple fault

Post by xyzzy »

I patch my QEMU because I like the exit on triple fault behaviour:

Code: Select all

diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index 2862ea4..c8f2c2a 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -1440,7 +1440,8 @@ static int check_exception(int intno, int *error_code)
         if (env->hflags & HF_SVMI_MASK)
             helper_vmexit(SVM_EXIT_SHUTDOWN, 0); /* does not return */
 
-        qemu_log_mask(CPU_LOG_RESET, "Triple fault\n");
+        //qemu_log_mask(CPU_LOG_RESET, "Triple fault\n");
+        cpu_abort(env, "triple fault");
 
         qemu_system_reset_request();
         return EXCP_HLT;
Post Reply