|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] [PATCH] Calculate correct instruction length for data-fa
On 28 Apr 2006, at 19:10, Khoa Huynh wrote:
For these instructions, on Intel VT-x, the instruction length is valid
in VMCS. On AMD, there is a simple look-up function which determines
the length of the instruction which is passed in as a parameter.
We are good here.
The Intel code only uses the instr-len field because it happens to be
handy. Going to a look-up function in a separate file when you *know*
at compile time what the instruction length must be is stupid, imo. We
should only have to do that if the instruction needs some decoding for
us to know its length (perhaps because of prefix bytes or effective
address suffixes) and we are not otherwise going to be decoding the
instruction as part of emulation.
I guess we can have a wrapper that takes as input the guest instruction
pointer (rip), fetches the whole MAX_INST_LEN (15-byte) buffer starting
at rip (make sure that we don't cross a page boundary), and then passes
that to the emulator. The emulator would decode, emulate, and would
include in its return the updated guest instruction pointer (rip) and
instruction length. This info will be stuffed back into
vmcs/vmcb/stack
as appropriate. Is this more or less what you have in mind ?
Yes, exactly. It gets a bit trickier though -- we'll have to fill the
buffer with up to 15 bytes. If we fail to get all of 15 bytes (perhaps
because the instruction straddles a page boundary and the second page
has been evicted since the instruction faulted) then we ought to tell
the emulator how many bytes we actually copied and it shoudl return
error if it ends up going off the end of teh instruction buffer.
Alternatively we could re-enter the guest immediately if we cannot read
15 bytes from the EIP -- but that'll cause an infinite loop if the
instruction itself doesn't straddle the page boundary as it won't
trigger paging in the guest. But I/O instructions are unlikely to be in
paged memory.
-- Keir
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|