Skip to content

Commit ea724ea

Browse files
committed
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: [email protected] Fixes: 7ed9abf ("KVM: SVM: Support string IO operations for an SEV-ES guest") Reviewed-by: Maxim Levitsky <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0d33b1b commit ea724ea

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

arch/x86/kvm/x86.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12383,43 +12383,42 @@ static int complete_sev_es_emulated_ins(struct kvm_vcpu *vcpu)
1238312383
}
1238412384

1238512385
static int kvm_sev_es_outs(struct kvm_vcpu *vcpu, unsigned int size,
12386-
unsigned int port, void *data, unsigned int count)
12386+
unsigned int port, unsigned int count)
1238712387
{
12388-
int ret;
12388+
int ret = emulator_pio_out(vcpu, size, port,
12389+
vcpu->arch.sev_pio_data, count);
1238912390

12390-
ret = emulator_pio_out_emulated(vcpu->arch.emulate_ctxt, size, port,
12391-
data, count);
12392-
if (ret)
12391+
if (ret) {
12392+
/* Emulation done by the kernel. */
1239312393
return ret;
12394+
}
1239412395

1239512396
vcpu->arch.pio.count = 0;
12396-
1239712397
return 0;
1239812398
}
1239912399

1240012400
static int kvm_sev_es_ins(struct kvm_vcpu *vcpu, unsigned int size,
12401-
unsigned int port, void *data, unsigned int count)
12401+
unsigned int port, unsigned int count)
1240212402
{
12403-
int ret;
12403+
int ret = emulator_pio_in(vcpu, size, port,
12404+
vcpu->arch.sev_pio_data, count);
1240412405

12405-
ret = emulator_pio_in_emulated(vcpu->arch.emulate_ctxt, size, port,
12406-
data, count);
1240712406
if (ret) {
12408-
vcpu->arch.pio.count = 0;
12409-
} else {
12410-
vcpu->arch.sev_pio_data = data;
12411-
vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins;
12407+
/* Emulation done by the kernel. */
12408+
return ret;
1241212409
}
1241312410

12411+
vcpu->arch.complete_userspace_io = complete_sev_es_emulated_ins;
1241412412
return 0;
1241512413
}
1241612414

1241712415
int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size,
1241812416
unsigned int port, void *data, unsigned int count,
1241912417
int in)
1242012418
{
12421-
return in ? kvm_sev_es_ins(vcpu, size, port, data, count)
12422-
: kvm_sev_es_outs(vcpu, size, port, data, count);
12419+
vcpu->arch.sev_pio_data = data;
12420+
return in ? kvm_sev_es_ins(vcpu, size, port, count)
12421+
: kvm_sev_es_outs(vcpu, size, port, count);
1242312422
}
1242412423
EXPORT_SYMBOL_GPL(kvm_sev_es_string_io);
1242512424

0 commit comments

Comments
 (0)