x86 emulator: Simplify String I/O emulation
PATCH 1/1 x86 emulator: Simplify String I/O emulation
Simplify ins/insb and outs/outsb instructions
Signed-off-by Mohammed Gamal <[email protected]>
--- arch/x86/kvm/x86_emulate.c | 22 ++++++---------------- 1 files changed, 6 insertions(+), 16 deletions(-)
arch/x86/kvm/x86_emulate.c +6 -16
@@ -1434,24 +1434,14 @@ special_insn:break ;case 0x6c :/* insb */ case 0x6d :/* insw/insd */ -if (kvm_emulate_pio_string (ctxt->vcpu,NULL , -1 , - (c->d & ByteOp) ?1 : c->op_bytes, - c->rep_prefix ? -address_mask (c, c->regs[VCPU_REGS_RCX ]) :1 , - (ctxt->eflags &EFLG_DF ), -register_address (c,es_base (ctxt), - c->regs[VCPU_REGS_RDI ]), - c->rep_prefix, - c->regs[VCPU_REGS_RDX ]) ==0 ) { - c->eip = saved_eip; -return -1 ; - } -return 0 ; + io_direction =1 ; + goto do_string_io;case 0x6e :/* outsb */ case 0x6f :/* outsw/outsd */ + io_direction =0 ; + do_string_io: if (kvm_emulate_pio_string(ctxt->vcpu, NULL, - 0, + io_direction, (c->d & ByteOp) ? 1 : c->op_bytes, c->rep_prefix ? address_mask(c, c->regs[VCPU_REGS_RCX]) : 1,
@@ -1462,7 +1452,7 @@ special_insn: c->rep_prefix, c->regs[VCPU_REGS_RDX]) == 0) { c->eip = saved_eip; -return -1 ; + goto cannot_emulate; }return 0 ; case 0x70 ... 0x7f: /* jcc (short) */ {
Signature · 1 line
1.5.4.3
Avi Kivity
AppliedQuoted 3 lines · Mohammed Gamal
Simplify ins/insb and outs/outsb instructions
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 3 lines · Mohammed Gamal
Simplify ins/insb and outs/outsb instructions
This is broken (ins uses es:rdi, outs uses ds:rsi), so I reverted it.
Signature · 1 line
error compiling committee.c: too many arguments to function