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>
This commit is contained in:
Tianjia Zhang 2020-04-16 13:10:57 +08:00 committed by Paolo Bonzini
parent 4f233371f6
commit 1b94f6f810
7 changed files with 17 additions and 13 deletions

View File

@ -438,8 +438,9 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
int r = -EINTR; int r = -EINTR;
vcpu_load(vcpu); vcpu_load(vcpu);

View File

@ -1764,8 +1764,9 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
return r; return r;
} }
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
int r; int r;
vcpu_load(vcpu); vcpu_load(vcpu);

View File

@ -4333,8 +4333,9 @@ static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
store_regs_fmt2(vcpu, kvm_run); store_regs_fmt2(vcpu, kvm_run);
} }
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *kvm_run = vcpu->run;
int rc; int rc;
if (kvm_run->immediate_exit) if (kvm_run->immediate_exit)

View File

@ -8710,8 +8710,9 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
trace_kvm_fpu(0); trace_kvm_fpu(0);
} }
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *kvm_run = vcpu->run;
int r; int r;
vcpu_load(vcpu); vcpu_load(vcpu);
@ -8729,18 +8730,18 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
r = -EAGAIN; r = -EAGAIN;
if (signal_pending(current)) { if (signal_pending(current)) {
r = -EINTR; r = -EINTR;
vcpu->run->exit_reason = KVM_EXIT_INTR; kvm_run->exit_reason = KVM_EXIT_INTR;
++vcpu->stat.signal_exits; ++vcpu->stat.signal_exits;
} }
goto out; goto out;
} }
if (vcpu->run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) { if (kvm_run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) {
r = -EINVAL; r = -EINVAL;
goto out; goto out;
} }
if (vcpu->run->kvm_dirty_regs) { if (kvm_run->kvm_dirty_regs) {
r = sync_regs(vcpu); r = sync_regs(vcpu);
if (r != 0) if (r != 0)
goto out; goto out;
@ -8770,7 +8771,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
out: out:
kvm_put_guest_fpu(vcpu); kvm_put_guest_fpu(vcpu);
if (vcpu->run->kvm_valid_regs) if (kvm_run->kvm_valid_regs)
store_regs(vcpu); store_regs(vcpu);
post_kvm_run_save(vcpu); post_kvm_run_save(vcpu);
kvm_sigset_deactivate(vcpu); kvm_sigset_deactivate(vcpu);

View File

@ -866,7 +866,7 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
struct kvm_mp_state *mp_state); struct kvm_mp_state *mp_state);
int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
struct kvm_guest_debug *dbg); struct kvm_guest_debug *dbg);
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run); int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu);
int kvm_arch_init(void *opaque); int kvm_arch_init(void *opaque);
void kvm_arch_exit(void); void kvm_arch_exit(void);

View File

@ -639,7 +639,6 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu)
/** /**
* kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code * kvm_arch_vcpu_ioctl_run - the main VCPU run function to execute guest code
* @vcpu: The VCPU pointer * @vcpu: The VCPU pointer
* @run: The kvm_run structure pointer used for userspace state exchange
* *
* This function is called through the VCPU_RUN ioctl called from user space. It * This function is called through the VCPU_RUN ioctl called from user space. It
* will execute VM code in a loop until the time slice for the process is used * will execute VM code in a loop until the time slice for the process is used
@ -647,8 +646,9 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu)
* return with return value 0 and with the kvm_run structure filled in with the * return with return value 0 and with the kvm_run structure filled in with the
* required data for the requested emulation. * required data for the requested emulation.
*/ */
int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
int ret; int ret;
if (unlikely(!kvm_vcpu_initialized(vcpu))) if (unlikely(!kvm_vcpu_initialized(vcpu)))
@ -659,7 +659,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
return ret; return ret;
if (run->exit_reason == KVM_EXIT_MMIO) { if (run->exit_reason == KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, vcpu->run); ret = kvm_handle_mmio_return(vcpu, run);
if (ret) if (ret)
return ret; return ret;
} }

View File

@ -3129,7 +3129,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
synchronize_rcu(); synchronize_rcu();
put_pid(oldpid); put_pid(oldpid);
} }
r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run); r = kvm_arch_vcpu_ioctl_run(vcpu);
trace_kvm_userspace_exit(vcpu->run->exit_reason, r); trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
break; break;
} }