KVM: x86 emulator: Let compiler know insn_fetch() rarely fails
Fetching the instruction which was to be executed by the guest cannot fail normally. So compiler should always predict that it will succeed. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
e85a10852c
commit
7d88bb4803
@ -672,11 +672,11 @@ static int do_insn_fetch_byte(struct x86_emulate_ctxt *ctxt, u8 *dest)
|
|||||||
size = min(15UL - cur_size,
|
size = min(15UL - cur_size,
|
||||||
PAGE_SIZE - offset_in_page(ctxt->_eip));
|
PAGE_SIZE - offset_in_page(ctxt->_eip));
|
||||||
rc = __linearize(ctxt, addr, size, false, true, &linear);
|
rc = __linearize(ctxt, addr, size, false, true, &linear);
|
||||||
if (rc != X86EMUL_CONTINUE)
|
if (unlikely(rc != X86EMUL_CONTINUE))
|
||||||
return rc;
|
return rc;
|
||||||
rc = ctxt->ops->fetch(ctxt, linear, fc->data + cur_size,
|
rc = ctxt->ops->fetch(ctxt, linear, fc->data + cur_size,
|
||||||
size, &ctxt->exception);
|
size, &ctxt->exception);
|
||||||
if (rc != X86EMUL_CONTINUE)
|
if (unlikely(rc != X86EMUL_CONTINUE))
|
||||||
return rc;
|
return rc;
|
||||||
fc->end += size;
|
fc->end += size;
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* x86 instructions are limited to 15 bytes. */
|
/* x86 instructions are limited to 15 bytes. */
|
||||||
if (ctxt->_eip + size - ctxt->eip > 15)
|
if (unlikely(ctxt->_eip + size - ctxt->eip > 15))
|
||||||
return X86EMUL_UNHANDLEABLE;
|
return X86EMUL_UNHANDLEABLE;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
rc = do_insn_fetch_byte(ctxt, dest++);
|
rc = do_insn_fetch_byte(ctxt, dest++);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user