Kevin Lawton wrote:
> One of Ramon's ideas was to extend the SBE strategy to optimize the
> handling of branch instructions. The idea is that instead of virtualizing
> instructions by replacing them with INT3 instructions, a 5-byte call
> instruction to a special handler routine could be inserted. The
> handler routine would then find the address of the calling instruction,
> deal with the branch and then return to execution of the virtualized
> code.
Actually no, my idea was a hybrid between this and your quasi-dynamic
translation idea. I don't use a static handler but actually generate
pieces of in-place code in a code cache, which I then jump to. This
gives the possibility to do dynamic translation as well as emulation,
without the disadvantage of having to replace *all* of the code (the
disadvantage with repsect to this method is a slightly larger overhead).
So, looking at your pros and cons:
> The pros of this strategy:
>
> - We can virtualize branches by calls to code at the same
> privilege level, and the handling code can be specific and optimized
> for handling guest branches. This should be a very big performance
> gain.
>
> - Instructions of any length could be virtualized, so we could potentially
> have handling routines specific to IO, selector reads, eflags register
> manipulations, etc. Again a performance win.
>
> - We could monitor the behaviour of certain instructions (tendencies to
> access video memory, page tables, etc) and dynamically reorient the
> generated code based on these behaviours, for potential performance
> gains.
All of these work for my method.
> - The ability to inline extra calls in the generated code to gather
> instrumentation data.
This would require virtualising all instructions in my method, which is
not practical.
> The cons:
>
> - Requires extra meta information.
I need this too, but it should be minimal.
> - Have to manage (save/restore) any guest state which is modified by
> the generated instruction stream. This is good reason to pass-through
> instructions as-is whenever possible.
I have no problems here.
> - Guest can 'see' translated code and/or handler code? Maybe who cares?
This is no problem in my approach either.
I'm currently working on getting my approach to work under linux. I hope
to mail some results soon (I'm spending christmas behind the computer coding
it! :))
-- Ramon