On 11/20/2010 01:05 PM, Kevin O'Connor wrote:
On Sat, Nov 20, 2010 at 12:58:56PM -0500, Stefan Berger wrote:
On 11/20/2010 12:50 PM, Kevin O'Connor wrote:
I suppose one could implement a simple SMM gateway - write a magic IO bit to invoke the SMM handler, have the SMM handler backup the cpu state somewhere in BIOS owned memory, and then leave SMM mode with execution at a BIOS handler running in 32bit flat mode. The BIOS handler could then do its work and manually return the CPU to its initial state before returning to the guest. The BIOS would need to ensure that it didn't allow interrupts (or NMIs) while in this mode, but that's possible. One would probably want to ensure that the BIOS didn't touch any non-BIOS owned memory in this state as well, but that's also possible.
FWIW, I am currently working on a gateway for calling 32 bit functions in the relocated 32bit code from 16 bit code, opening up that are for more than the init functions. It works fine from what I can see also considering the mixture of register and stack passing of arguments. Would that be helpful here?
Is it something like stacks.c:call32() or is it via SMM?
The way it works is that there is a jumptable with entries to the function in the 'high bios'. That jumptable along with all the other 32 bit code gets relocated to upper memory and in the 'lower BIOS' I keep a pointer to the jumptable in the 'high bios' for the upcall code to see. It's basically similar to what I have previously contributed to Bochs BIOS in Xen, just that the upcall code can deal with parameter passed via registers or a limited number on the stack.
http://xenbits.xensource.com/xen-4.0-testing.hg?file/e9156d9d996b/tools/firm...
BTW, are you reserving the relocated code or are you only doing this during the init phase?
The 'high bios' functions should be accessible all the time basically. So, the relocated code needs to be marked as e820-reserved memory -- I suppose that should do the trick then?
Stefan
-Kevin