[haiku-development] Re: Virtual 8086 mode support

  • From: Jan Klötzke <jan.kloetzke@xxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 26 Apr 2008 15:46:34 +0200

Hi Kernel Hackers,

Good news is that I have the in-kernel vm86 mode call working. :-) But at the 
moment I'm a bit stuck on the error handling part. Let me first explain the 
current solution:

There are now two functions:

status_t x86_vm86_enter(struct vm86_iframe *frame);
void x86_vm86_return(struct vm86_iframe *frame, status_t retval);

To enter vm86 mode the caller has to prepare an appropriate iframe and then 
call x86_vm86_enter(). Exceptions handlers (such as for #GP) can call 
x86_vm86_return() which will leave vm86 mode and cause the original 
x86_vm86_enter() call to return. Nothing fancy so far.

So when the BIOS is called the invocation of vm86 mode should not be 
interrupted, expect for fatal exceptions. The only problem here is the page 
fault exception. If the page fault could not be handled then vm86 mode must 
be left, otherwise not. Unfortunately the arch code has no clue what happened 
because vm_page_fault() always returns B_HANDLED_INTERRUPT. I thought 
checking for a pending SIGSEGV in the arch page fault exception handler could 
also be an options but apparently the SIGSEGV signal is dispatched to the 
main thread of the team and not to the thread who caused it. Therefore I have 
two questions:

* May it be an option to change the return value of vm_page_fault() to know in 
the arch code if the page fault could be handled or not?
* Why are all signals sent to the team (main thread) and not to the causing 
thread?

/Jan

Other related posts: