On Wed, Sep 22, 2010 at 06:33:46PM -0700, H. Peter Anvin wrote:
On 09/22/2010 06:16 PM, Kevin O'Connor wrote:
using an SMI to get out of vm86 mode requires the BIOS to emulate all memory accesses to user memory (manually walking the page table, forcing page faults) which is tricky;
Actually you can switch to protected mode and turn the page tables on if you want.
That's a good idea. Though it still sounds tricky to handle page faults.
I didn't think there was a way for the user code to know it was running in vm86 mode - I thought it appeared just like regular real-mode. One could try to go into protected mode and try to catch the failure, but I'd guess most OSs that run code in vm86 mode would trap and abort in that situation.
No, the SMSW instruction can be used to distinguish protected mode and therefore V86 mode.
Thanks. Do you know of a way to backup the hidden segment registers? The BIOS can be invoked in real mode or bigreal mode. I didn't see a way for the BIOS to determine this so that it can properly return in the same mode (real vs bigreal).
A related call is INT 0x15 ah=0x87 which does a highmem capable memcpy. Unfortunately this handler does a 16bit memcpy (rep movsw), and the OHCI spec requires the cmdstatus register be accessed with a 32bit memory access.
That might be a problem if that is actually done that way (which it generally won't.) Still, you do have the issue of what happens in a V86 environment if it doesn't just pass code to the original BIOS.
-Kevin