lkml.org 
[lkml]   [2014]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2014-05-07 11:21    [W:0.052 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site