Skip to content

Commit 1b94f6f

Browse files
uudiinbonzini
authored andcommitted
KVM: Remove redundant argument to kvm_arch_vcpu_ioctl_run
In earlier versions of kvm, 'kvm_run' was an independent structure and was not included in the vcpu structure. At present, 'kvm_run' is already included in the vcpu structure, so the parameter 'kvm_run' is redundant. This patch simplifies the function definition, removes the extra 'kvm_run' parameter, and extracts it from the 'kvm_vcpu' structure if necessary. Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Message-Id: <20200416051057.26526-1-tianjia.zhang@linux.alibaba.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 4f23337 commit 1b94f6f

7 files changed

Lines changed: 17 additions & 13 deletions

File tree

‎arch/mips/kvm/mips.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,9 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
438438
return -ENOIOCTLCMD;
439439
}
440440

441-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
441+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
442442
{
443+
struct kvm_run *run = vcpu->run;
443444
int r = -EINTR;
444445

445446
vcpu_load(vcpu);

‎arch/powerpc/kvm/powerpc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,8 +1764,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
17641764
return r;
17651765
}
17661766

1767-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
1767+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
17681768
{
1769+
struct kvm_run *run = vcpu->run;
17691770
int r;
17701771

17711772
vcpu_load(vcpu);

‎arch/s390/kvm/kvm-s390.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4333,8 +4333,9 @@ static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
43334333
store_regs_fmt2(vcpu, kvm_run);
43344334
}
43354335

4336-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
4336+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
43374337
{
4338+
struct kvm_run *kvm_run = vcpu->run;
43384339
int rc;
43394340

43404341
if (kvm_run->immediate_exit)

‎arch/x86/kvm/x86.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8710,8 +8710,9 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
87108710
trace_kvm_fpu(0);
87118711
}
87128712

8713-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
8713+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
87148714
{
8715+
struct kvm_run *kvm_run = vcpu->run;
87158716
int r;
87168717

87178718
vcpu_load(vcpu);
@@ -8729,18 +8730,18 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
87298730
r = -EAGAIN;
87308731
if (signal_pending(current)) {
87318732
r = -EINTR;
8732-
vcpu->run->exit_reason = KVM_EXIT_INTR;
8733+
kvm_run->exit_reason = KVM_EXIT_INTR;
87338734
++vcpu->stat.signal_exits;
87348735
}
87358736
goto out;
87368737
}
87378738

8738-
if (vcpu->run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) {
8739+
if (kvm_run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) {
87398740
r = -EINVAL;
87408741
goto out;
87418742
}
87428743

8743-
if (vcpu->run->kvm_dirty_regs) {
8744+
if (kvm_run->kvm_dirty_regs) {
87448745
r = sync_regs(vcpu);
87458746
if (r != 0)
87468747
goto out;
@@ -8770,7 +8771,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
87708771

87718772
out:
87728773
kvm_put_guest_fpu(vcpu);
8773-
if (vcpu->run->kvm_valid_regs)
8774+
if (kvm_run->kvm_valid_regs)
87748775
store_regs(vcpu);
87758776
post_kvm_run_save(vcpu);
87768777
kvm_sigset_deactivate(vcpu);

‎include/linux/kvm_host.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
866866
struct kvm_mp_state *mp_state);
867867
int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
868868
struct kvm_guest_debug *dbg);
869-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
869+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu);
870870

871871
int kvm_arch_init(void *opaque);
872872
void kvm_arch_exit(void);

‎virt/kvm/arm/arm.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,16 +639,16 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu)
639639
/**
640640
* kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code
641641
* @vcpu: The VCPU pointer
642-
* @run: The kvm_run structure pointer used for userspace state exchange
643642
*
644643
* This function is called through the VCPU_RUN ioctl called from user space. It
645644
* will execute VM code in a loop until the time slice for the process is used
646645
* or some emulation is needed from user space in which case the function will
647646
* return with return value 0 and with the kvm_run structure filled in with the
648647
* required data for the requested emulation.
649648
*/
650-
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
649+
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
651650
{
651+
struct kvm_run *run = vcpu->run;
652652
int ret;
653653

654654
if (unlikely(!kvm_vcpu_initialized(vcpu)))
@@ -659,7 +659,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
659659
return ret;
660660

661661
if (run->exit_reason == KVM_EXIT_MMIO) {
662-
ret = kvm_handle_mmio_return(vcpu, vcpu->run);
662+
ret = kvm_handle_mmio_return(vcpu, run);
663663
if (ret)
664664
return ret;
665665
}

‎virt/kvm/kvm_main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3129,7 +3129,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
31293129
synchronize_rcu();
31303130
put_pid(oldpid);
31313131
}
3132-
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
3132+
r = kvm_arch_vcpu_ioctl_run(vcpu);
31333133
trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
31343134
break;
31353135
}

0 commit comments

Comments
 (0)