Skip to content

Commit

Permalink
KVM: Implement emulation of instruction "ret" (opcode 0xc3)
Browse files Browse the repository at this point in the history
Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
  • Loading branch information
Nitin A Kamble authored and Avi Kivity committed Jul 16, 2007
1 parent 7f0aaee commit d9413cd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/kvm/x86_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ static u8 opcode_table[256] = {
/* 0xB0 - 0xBF */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0xC0 - 0xC7 */
ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, 0, 0,
0, 0, ByteOp | DstMem | SrcImm | ModRM | Mov,
DstMem | SrcImm | ModRM | Mov,
ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM,
0, ImplicitOps, 0, 0,
ByteOp | DstMem | SrcImm | ModRM | Mov, DstMem | SrcImm | ModRM | Mov,
/* 0xC8 - 0xCF */
0, 0, 0, 0, 0, 0, 0, 0,
/* 0xD0 - 0xD7 */
Expand Down Expand Up @@ -1156,14 +1156,18 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
case 0xf4: /* hlt */
ctxt->vcpu->halt_request = 1;
goto done;
case 0xc3: /* ret */
dst.ptr = &_eip;
goto pop_instruction;
case 0x58 ... 0x5f: /* pop reg */
dst.ptr = (unsigned long *)&_regs[b & 0x7];

pop_instruction:
if ((rc = ops->read_std(register_address(ctxt->ss_base,
_regs[VCPU_REGS_RSP]), dst.ptr, op_bytes, ctxt)) != 0)
goto done;

register_address_increment(_regs[VCPU_REGS_RSP], dst.bytes);
register_address_increment(_regs[VCPU_REGS_RSP], op_bytes);
dst.orig_val = dst.val; /* Disable writeback. */
break;
}
Expand Down

0 comments on commit d9413cd

Please sign in to comment.