KVM: x86 emulator: drop vcpu argument from pio callbacks
Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
@@ -155,11 +155,13 @@ struct x86_emulate_ops {
|
|||||||
unsigned int bytes,
|
unsigned int bytes,
|
||||||
struct x86_exception *fault);
|
struct x86_exception *fault);
|
||||||
|
|
||||||
int (*pio_in_emulated)(int size, unsigned short port, void *val,
|
int (*pio_in_emulated)(struct x86_emulate_ctxt *ctxt,
|
||||||
unsigned int count, struct kvm_vcpu *vcpu);
|
int size, unsigned short port, void *val,
|
||||||
|
unsigned int count);
|
||||||
|
|
||||||
int (*pio_out_emulated)(int size, unsigned short port, const void *val,
|
int (*pio_out_emulated)(struct x86_emulate_ctxt *ctxt,
|
||||||
unsigned int count, struct kvm_vcpu *vcpu);
|
int size, unsigned short port, const void *val,
|
||||||
|
unsigned int count);
|
||||||
|
|
||||||
bool (*get_cached_descriptor)(struct desc_struct *desc, u32 *base3,
|
bool (*get_cached_descriptor)(struct desc_struct *desc, u32 *base3,
|
||||||
int seg, struct kvm_vcpu *vcpu);
|
int seg, struct kvm_vcpu *vcpu);
|
||||||
|
@@ -1125,7 +1125,7 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt,
|
|||||||
if (n == 0)
|
if (n == 0)
|
||||||
n = 1;
|
n = 1;
|
||||||
rc->pos = rc->end = 0;
|
rc->pos = rc->end = 0;
|
||||||
if (!ops->pio_in_emulated(size, port, rc->data, n, ctxt->vcpu))
|
if (!ops->pio_in_emulated(ctxt, size, port, rc->data, n))
|
||||||
return 0;
|
return 0;
|
||||||
rc->end = n * size;
|
rc->end = n * size;
|
||||||
}
|
}
|
||||||
@@ -3892,8 +3892,8 @@ special_insn:
|
|||||||
case 0xef: /* out dx,(e/r)ax */
|
case 0xef: /* out dx,(e/r)ax */
|
||||||
c->dst.val = c->regs[VCPU_REGS_RDX];
|
c->dst.val = c->regs[VCPU_REGS_RDX];
|
||||||
do_io_out:
|
do_io_out:
|
||||||
ops->pio_out_emulated(c->src.bytes, c->dst.val,
|
ops->pio_out_emulated(ctxt, c->src.bytes, c->dst.val,
|
||||||
&c->src.val, 1, ctxt->vcpu);
|
&c->src.val, 1);
|
||||||
c->dst.type = OP_NONE; /* Disable writeback. */
|
c->dst.type = OP_NONE; /* Disable writeback. */
|
||||||
break;
|
break;
|
||||||
case 0xf4: /* hlt */
|
case 0xf4: /* hlt */
|
||||||
|
@@ -4060,9 +4060,12 @@ static int kernel_pio(struct kvm_vcpu *vcpu, void *pd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int emulator_pio_in_emulated(int size, unsigned short port, void *val,
|
static int emulator_pio_in_emulated(struct x86_emulate_ctxt *ctxt,
|
||||||
unsigned int count, struct kvm_vcpu *vcpu)
|
int size, unsigned short port, void *val,
|
||||||
|
unsigned int count)
|
||||||
{
|
{
|
||||||
|
struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
|
||||||
|
|
||||||
if (vcpu->arch.pio.count)
|
if (vcpu->arch.pio.count)
|
||||||
goto data_avail;
|
goto data_avail;
|
||||||
|
|
||||||
@@ -4090,10 +4093,12 @@ static int emulator_pio_in_emulated(int size, unsigned short port, void *val,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int emulator_pio_out_emulated(int size, unsigned short port,
|
static int emulator_pio_out_emulated(struct x86_emulate_ctxt *ctxt,
|
||||||
const void *val, unsigned int count,
|
int size, unsigned short port,
|
||||||
struct kvm_vcpu *vcpu)
|
const void *val, unsigned int count)
|
||||||
{
|
{
|
||||||
|
struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
|
||||||
|
|
||||||
trace_kvm_pio(1, port, size, count);
|
trace_kvm_pio(1, port, size, count);
|
||||||
|
|
||||||
vcpu->arch.pio.port = port;
|
vcpu->arch.pio.port = port;
|
||||||
@@ -4614,7 +4619,8 @@ EXPORT_SYMBOL_GPL(x86_emulate_instruction);
|
|||||||
int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port)
|
int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port)
|
||||||
{
|
{
|
||||||
unsigned long val = kvm_register_read(vcpu, VCPU_REGS_RAX);
|
unsigned long val = kvm_register_read(vcpu, VCPU_REGS_RAX);
|
||||||
int ret = emulator_pio_out_emulated(size, port, &val, 1, vcpu);
|
int ret = emulator_pio_out_emulated(&vcpu->arch.emulate_ctxt,
|
||||||
|
size, port, &val, 1);
|
||||||
/* do not return to emulator after return from userspace */
|
/* do not return to emulator after return from userspace */
|
||||||
vcpu->arch.pio.count = 0;
|
vcpu->arch.pio.count = 0;
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user