OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 1:53 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Getting QEMU to dump registers on triple fault
PostPosted: Mon Jul 02, 2012 11:53 pm 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
When I started testing my OS with qemu, it would produce a dump of the cpu registers when it triple faulted.
Code:
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?


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 2:26 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 3:08 am 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
I got this:
Code:
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?


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 4:09 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 4:30 am 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
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.


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 6:25 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 6:48 am 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
version 0.12.5
Code:
qemu -fda image.bin -boot a -m 128 -no-reboot -d cpu_reset
No error for me; seems to be silently ignoreing it.


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 9:11 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Tue Jul 03, 2012 8:02 pm 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
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)?


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Wed Jul 04, 2012 3:48 pm 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Wed Jul 04, 2012 4:52 pm 
Offline

Joined: Mon Jul 02, 2012 9:39 pm
Posts: 6
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.


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Wed Jul 04, 2012 5:00 pm 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Getting QEMU to dump registers on triple fault
PostPosted: Thu Jul 05, 2012 8:03 am 
Offline
Member
Member

Joined: Wed Jul 25, 2007 8:45 am
Posts: 391
Location: London, UK
I patch my QEMU because I like the exit on triple fault behaviour:

Code:
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;

_________________
http://alex-smith.me.uk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 492 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group