Commit ea724ea4 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: SEV-ES: clean up kvm_sev_es_ins/outs

A few very small cleanups to the functions, smushed together because
the patch is already very small like this:

- inline emulator_pio_in_emulated and emulator_pio_out_emulated,
  since we already have the vCPU

- remove the data argument and pull setting vcpu->arch.sev_pio_data into
  the caller

- remove unnecessary clearing of vcpu->arch.pio.count when
  emulation is done by the kernel (and therefore vcpu->arch.pio.count
  is already clear on exit from emulator_pio_in and emulator_pio_out).

No functional change intended.

Cc: stable@vger.kernel.org
Fixes: 7ed9abfe ("KVM: SVM: Support string IO operations for an SEV-ES guest")
Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0d33b1ba
...@@ -12383,34 +12383,32 @@ static int complete_sev_es_emulated_ins(struct kvm_vcpu *vcpu) ...@@ -12383,34 +12383,32 @@ static int complete_sev_es_emulated_ins(struct kvm_vcpu *vcpu)
} }
static int kvm_sev_es_outs(struct kvm_vcpu *vcpu, unsigned int size, static int kvm_sev_es_outs(struct kvm_vcpu *vcpu, unsigned int size,
unsigned int port, void *data, unsigned int count) unsigned int port, unsigned int count)
{ {
int ret; int ret = emulator_pio_out(vcpu, size, port,
vcpu->arch.sev_pio_data, count);
ret = emulator_pio_out_emulated(vcpu->arch.emulate_ctxt, size, port, if (ret) {
data, count); /* Emulation done by the kernel. */
if (ret)
return ret; return ret;
}
vcpu->arch.pio.count = 0; vcpu->arch.pio.count = 0;
return 0; return 0;
} }
static int kvm_sev_es_ins(struct kvm_vcpu *vcpu, unsigned int size, static int kvm_sev_es_ins(struct kvm_vcpu *vcpu, unsigned int size,
unsigned int port, void *data, unsigned int count) unsigned int port, unsigned int count)
{ {
int ret; int ret = emulator_pio_in(vcpu, size, port,
vcpu->arch.sev_pio_data, count);
ret = emulator_pio_in_emulated(vcpu->arch.emulate_ctxt, size, port,
data, count);
if (ret) { if (ret) {
vcpu->arch.pio.count = 0; /* Emulation done by the kernel. */
} else { return ret;
vcpu->arch.sev_pio_data = data;
vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins;
} }
vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins;
return 0; return 0;
} }
...@@ -12418,8 +12416,9 @@ int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size, ...@@ -12418,8 +12416,9 @@ int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size,
unsigned int port, void *data, unsigned int count, unsigned int port, void *data, unsigned int count,
int in) int in)
{ {
return in ? kvm_sev_es_ins(vcpu, size, port, data, count) vcpu->arch.sev_pio_data = data;
: kvm_sev_es_outs(vcpu, size, port, data, count); return in ? kvm_sev_es_ins(vcpu, size, port, count)
: kvm_sev_es_outs(vcpu, size, port, count);
} }
EXPORT_SYMBOL_GPL(kvm_sev_es_string_io); EXPORT_SYMBOL_GPL(kvm_sev_es_string_io);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment