diff options
-rw-r--r-- | arch/x86/include/asm/kvm_emulate.h | 10 | ||||
-rw-r--r-- | arch/x86/kvm/emulate.c | 6 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 18 |
3 files changed, 21 insertions, 13 deletions
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index b4d846708a4b..1348bdf14a43 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h | |||
@@ -155,11 +155,13 @@ struct x86_emulate_ops { | |||
155 | unsigned int bytes, | 155 | unsigned int bytes, |
156 | struct x86_exception *fault); | 156 | struct x86_exception *fault); |
157 | 157 | ||
158 | int (*pio_in_emulated)(int size, unsigned short port, void *val, | 158 | int (*pio_in_emulated)(struct x86_emulate_ctxt *ctxt, |
159 | unsigned int count, struct kvm_vcpu *vcpu); | 159 | int size, unsigned short port, void *val, |
160 | unsigned int count); | ||
160 | 161 | ||
161 | int (*pio_out_emulated)(int size, unsigned short port, const void *val, | 162 | int (*pio_out_emulated)(struct x86_emulate_ctxt *ctxt, |
162 | unsigned int count, struct kvm_vcpu *vcpu); | 163 | int size, unsigned short port, const void *val, |
164 | unsigned int count); | ||
163 | 165 | ||
164 | bool (*get_cached_descriptor)(struct desc_struct *desc, u32 *base3, | 166 | bool (*get_cached_descriptor)(struct desc_struct *desc, u32 *base3, |
165 | int seg, struct kvm_vcpu *vcpu); | 167 | int seg, struct kvm_vcpu *vcpu); |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index ff64b17df772..8af08a16f4dd 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1125,7 +1125,7 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt, | |||
1125 | if (n == 0) | 1125 | if (n == 0) |
1126 | n = 1; | 1126 | n = 1; |
1127 | rc->pos = rc->end = 0; | 1127 | rc->pos = rc->end = 0; |
1128 | if (!ops->pio_in_emulated(size, port, rc->data, n, ctxt->vcpu)) | 1128 | if (!ops->pio_in_emulated(ctxt, size, port, rc->data, n)) |
1129 | return 0; | 1129 | return 0; |
1130 | rc->end = n * size; | 1130 | rc->end = n * size; |
1131 | } | 1131 | } |
@@ -3892,8 +3892,8 @@ special_insn: | |||
3892 | case 0xef: /* out dx,(e/r)ax */ | 3892 | case 0xef: /* out dx,(e/r)ax */ |
3893 | c->dst.val = c->regs[VCPU_REGS_RDX]; | 3893 | c->dst.val = c->regs[VCPU_REGS_RDX]; |
3894 | do_io_out: | 3894 | do_io_out: |
3895 | ops->pio_out_emulated(c->src.bytes, c->dst.val, | 3895 | ops->pio_out_emulated(ctxt, c->src.bytes, c->dst.val, |
3896 | &c->src.val, 1, ctxt->vcpu); | 3896 | &c->src.val, 1); |
3897 | c->dst.type = OP_NONE; /* Disable writeback. */ | 3897 | c->dst.type = OP_NONE; /* Disable writeback. */ |
3898 | break; | 3898 | break; |
3899 | case 0xf4: /* hlt */ | 3899 | case 0xf4: /* hlt */ |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 274652ae6d52..e9040a9b25c6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4060,9 +4060,12 @@ static int kernel_pio(struct kvm_vcpu *vcpu, void *pd) | |||
4060 | } | 4060 | } |
4061 | 4061 | ||
4062 | 4062 | ||
4063 | static int emulator_pio_in_emulated(int size, unsigned short port, void *val, | 4063 | static int emulator_pio_in_emulated(struct x86_emulate_ctxt *ctxt, |
4064 | unsigned int count, struct kvm_vcpu *vcpu) | 4064 | int size, unsigned short port, void *val, |
4065 | unsigned int count) | ||
4065 | { | 4066 | { |
4067 | struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); | ||
4068 | |||
4066 | if (vcpu->arch.pio.count) | 4069 | if (vcpu->arch.pio.count) |
4067 | goto data_avail; | 4070 | goto data_avail; |
4068 | 4071 | ||
@@ -4090,10 +4093,12 @@ static int emulator_pio_in_emulated(int size, unsigned short port, void *val, | |||
4090 | return 0; | 4093 | return 0; |
4091 | } | 4094 | } |
4092 | 4095 | ||
4093 | static int emulator_pio_out_emulated(int size, unsigned short port, | 4096 | static int emulator_pio_out_emulated(struct x86_emulate_ctxt *ctxt, |
4094 | const void *val, unsigned int count, | 4097 | int size, unsigned short port, |
4095 | struct kvm_vcpu *vcpu) | 4098 | const void *val, unsigned int count) |
4096 | { | 4099 | { |
4100 | struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); | ||
4101 | |||
4097 | trace_kvm_pio(1, port, size, count); | 4102 | trace_kvm_pio(1, port, size, count); |
4098 | 4103 | ||
4099 | vcpu->arch.pio.port = port; | 4104 | vcpu->arch.pio.port = port; |
@@ -4614,7 +4619,8 @@ EXPORT_SYMBOL_GPL(x86_emulate_instruction); | |||
4614 | int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port) | 4619 | int kvm_fast_pio_out(struct kvm_vcpu *vcpu, int size, unsigned short port) |
4615 | { | 4620 | { |
4616 | unsigned long val = kvm_register_read(vcpu, VCPU_REGS_RAX); | 4621 | unsigned long val = kvm_register_read(vcpu, VCPU_REGS_RAX); |
4617 | int ret = emulator_pio_out_emulated(size, port, &val, 1, vcpu); | 4622 | int ret = emulator_pio_out_emulated(&vcpu->arch.emulate_ctxt, |
4623 | size, port, &val, 1); | ||
4618 | /* do not return to emulator after return from userspace */ | 4624 | /* do not return to emulator after return from userspace */ |
4619 | vcpu->arch.pio.count = 0; | 4625 | vcpu->arch.pio.count = 0; |
4620 | return ret; | 4626 | return ret; |