History

KVM: x86: Decoding guest instructions which cross page boundary may fail

Once an instruction crosses a page boundary, the size read from the second page disregards the common case that part of the operand resides on the first page. As a result, fetch of long insturctions may fail, and thereby cause the decoding to fail as well.

Nadav Amit committed 12 years ago

Commit 08da44a1 parent 2bc19dc1 file · +4 −2Browse files

Unified · Split

arch/x86/kvm/emulate.c+4−2
@@ -778,8 +778,10 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size) · 777 unmodified lines
778static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,778static __always_inline int do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt,
779 unsigned size)779 unsigned size)
780{780{
781 if (unlikely(ctxt->fetch.end - ctxt->fetch.ptr < size))781 unsigned done_size = ctxt->fetch.end - ctxt->fetch.ptr;
782 return __do_insn_fetch_bytes(ctxt, size);782
783 if (unlikely(done_size < size))
784 return __do_insn_fetch_bytes(ctxt, size - done_size);
783 else785 else
784 return X86EMUL_CONTINUE;786 return X86EMUL_CONTINUE;
785}787}