Skip to content
Commit 5cfc7e0f authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

KVM: emulate: avoid repeated calls to do_insn_fetch_bytes



do_insn_fetch_bytes will only be called once in a given insn_fetch and
insn_fetch_arr, because in fact it will only be called at most twice
for any instruction and the first call is explicit in x86_decode_insn.
This observation lets us hoist the call out of the memory copying loop.
It does not buy performance, because most fetches are one byte long
anyway, but it prepares for the next patch.

The overflow check is tricky, but correct.  Because do_insn_fetch_bytes
has already been called once, we know that fc->end is at least 15.  So
it is okay to subtract the number of bytes we want to read.

Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 285ca9e9
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment