Messages in this thread | | | Date | Wed, 07 May 2014 10:34:40 +0200 | From | Paolo Bonzini <> | Subject | Re: [RFC PATCH 2/4] KVM: emulate: avoid repeated calls to do_insn_fetch_bytes |
| |
Il 07/05/2014 06:21, Bandan Das ha scritto: >> > + if (rc != X86EMUL_CONTINNUE) >> > + goto done; >> > + } >> > + >> > while (size--) { >> > - if (unlikely(ctxt->_eip == fc->end)) { >> > - rc = do_insn_fetch_bytes(ctxt); >> > - if (rc != X86EMUL_CONTINUE) >> > - return rc; >> > - } >> > *dest++ = *src++; >> > ctxt->_eip++; >> > continue; >> > @@ -4273,7 +4282,7 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) >> > if (insn_len > 0) >> > memcpy(ctxt->fetch.data, insn, insn_len); >> > else { >> > - rc = do_insn_fetch_bytes(ctxt); >> > + rc = do_insn_fetch_bytes(ctxt, 1); > Is this saying that if the cache is full, then we fetch one more byte ? >
No, it is saying that if the instruction is being executed for the first time (we can execute it multiple times if we reenter a repeated instruction after a userspace exit) we try to get at least one byte from RIP. Most of the time, do_insn_fetch_bytes will fetch 15 bytes which are the maximum length of an instruction.
Passing op_size == 1 matches this change in do_insn_fetch_bytes:
- if (unlikely(size == 0)) + if (unlikely(size < op_size))
Paolo
| |