On Mon, Feb 13, 2012 at 08:50:56PM +0000, Ian Campbell wrote:
On Mon, 2012-02-13 at 23:21 +0900, Daniel Castro wrote:
I have encountered something a little strange, if I set up the debug lvl to 3 or more Y will get a Triple VCPU fault. If I set it to 1 the bios runs normally but I loose a lot of information that I need to debug. Sometimes if I try to print char * variables regardless of the debug level I still get the fault.
Any ideas why?
My guess is that there is a debug print at lvl>=3 which ends up dereferencing a NULL pointer in one of its arguments (probably a %s) and this leads to a page fault. This in turn leads to a double fault because SeaBIOS does not install a page fault handler and then a triple fault because it also does not install a double fault handler. Likewise when you are printing "char * variables regardless of the debug level".
SeaBIOS doesn't have paging enabled, so it should not need to install a page fault handler. SeaBIOS needs to write the real-mode interrupt descriptor table to address 0, so it should definitely have read/write access to the memory there. Thus, a null pointer dereference shouldn't cause a fault. Indeed, I can't think of much that should cause a fault (other than read/write to IO memory incorrectly, divide by zero, invalid opcode, etc.).
You could test this by adding an explicit check for null in the bit of bvprintf which handles %s, perhaps putc()ing "(null)" instead.
If you think it is specific to the Xen handling, one could also try running the same code on qemu to verify it.