forked from mirrors/linux
		
	KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_run(). Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> # s390 parts Reviewed-by: Cornelia Huck <cohuck@redhat.com> [Rebased. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									8a32dd60ec
								
							
						
					
					
						commit
						accb757d79
					
				
					 6 changed files with 32 additions and 12 deletions
				
			
		| 
						 | 
					@ -446,6 +446,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int r = -EINTR;
 | 
						int r = -EINTR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_load(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvm_sigset_activate(vcpu);
 | 
						kvm_sigset_activate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (vcpu->mmio_needed) {
 | 
						if (vcpu->mmio_needed) {
 | 
				
			||||||
| 
						 | 
					@ -480,6 +482,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	kvm_sigset_deactivate(vcpu);
 | 
						kvm_sigset_deactivate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_put(vcpu);
 | 
				
			||||||
	return r;
 | 
						return r;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1408,6 +1408,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int r;
 | 
						int r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_load(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (vcpu->mmio_needed) {
 | 
						if (vcpu->mmio_needed) {
 | 
				
			||||||
		vcpu->mmio_needed = 0;
 | 
							vcpu->mmio_needed = 0;
 | 
				
			||||||
		if (!vcpu->mmio_is_write)
 | 
							if (!vcpu->mmio_is_write)
 | 
				
			||||||
| 
						 | 
					@ -1422,7 +1424,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
			r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
 | 
								r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
 | 
				
			||||||
			if (r == RESUME_HOST) {
 | 
								if (r == RESUME_HOST) {
 | 
				
			||||||
				vcpu->mmio_needed = 1;
 | 
									vcpu->mmio_needed = 1;
 | 
				
			||||||
				return r;
 | 
									goto out;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -1456,6 +1458,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvm_sigset_deactivate(vcpu);
 | 
						kvm_sigset_deactivate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
						vcpu_put(vcpu);
 | 
				
			||||||
	return r;
 | 
						return r;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3373,9 +3373,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 | 
				
			||||||
	if (kvm_run->immediate_exit)
 | 
						if (kvm_run->immediate_exit)
 | 
				
			||||||
		return -EINTR;
 | 
							return -EINTR;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_load(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (guestdbg_exit_pending(vcpu)) {
 | 
						if (guestdbg_exit_pending(vcpu)) {
 | 
				
			||||||
		kvm_s390_prepare_debug_exit(vcpu);
 | 
							kvm_s390_prepare_debug_exit(vcpu);
 | 
				
			||||||
		return 0;
 | 
							rc = 0;
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvm_sigset_activate(vcpu);
 | 
						kvm_sigset_activate(vcpu);
 | 
				
			||||||
| 
						 | 
					@ -3385,7 +3388,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 | 
				
			||||||
	} else if (is_vcpu_stopped(vcpu)) {
 | 
						} else if (is_vcpu_stopped(vcpu)) {
 | 
				
			||||||
		pr_err_ratelimited("can't run stopped vcpu %d\n",
 | 
							pr_err_ratelimited("can't run stopped vcpu %d\n",
 | 
				
			||||||
				   vcpu->vcpu_id);
 | 
									   vcpu->vcpu_id);
 | 
				
			||||||
		return -EINVAL;
 | 
							rc = -EINVAL;
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sync_regs(vcpu, kvm_run);
 | 
						sync_regs(vcpu, kvm_run);
 | 
				
			||||||
| 
						 | 
					@ -3415,6 +3419,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 | 
				
			||||||
	kvm_sigset_deactivate(vcpu);
 | 
						kvm_sigset_deactivate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vcpu->stat.exit_userspace++;
 | 
						vcpu->stat.exit_userspace++;
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
						vcpu_put(vcpu);
 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7280,8 +7280,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int r;
 | 
						int r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_load(vcpu);
 | 
				
			||||||
	kvm_sigset_activate(vcpu);
 | 
						kvm_sigset_activate(vcpu);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	kvm_load_guest_fpu(vcpu);
 | 
						kvm_load_guest_fpu(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
 | 
						if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {
 | 
				
			||||||
| 
						 | 
					@ -7328,6 +7328,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 | 
				
			||||||
	post_kvm_run_save(vcpu);
 | 
						post_kvm_run_save(vcpu);
 | 
				
			||||||
	kvm_sigset_deactivate(vcpu);
 | 
						kvm_sigset_deactivate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_put(vcpu);
 | 
				
			||||||
	return r;
 | 
						return r;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -619,21 +619,27 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
	if (unlikely(!kvm_vcpu_initialized(vcpu)))
 | 
						if (unlikely(!kvm_vcpu_initialized(vcpu)))
 | 
				
			||||||
		return -ENOEXEC;
 | 
							return -ENOEXEC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vcpu_load(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = kvm_vcpu_first_run_init(vcpu);
 | 
						ret = kvm_vcpu_first_run_init(vcpu);
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		return ret;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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, vcpu->run);
 | 
				
			||||||
		if (ret)
 | 
							if (ret)
 | 
				
			||||||
			return ret;
 | 
								goto out;
 | 
				
			||||||
		if (kvm_arm_handle_step_debug(vcpu, vcpu->run))
 | 
							if (kvm_arm_handle_step_debug(vcpu, vcpu->run)) {
 | 
				
			||||||
			return 0;
 | 
								ret = 0;
 | 
				
			||||||
 | 
								goto out;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (run->immediate_exit)
 | 
						if (run->immediate_exit) {
 | 
				
			||||||
		return -EINTR;
 | 
							ret = -EINTR;
 | 
				
			||||||
 | 
							goto out;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvm_sigset_activate(vcpu);
 | 
						kvm_sigset_activate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -772,6 +778,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kvm_sigset_deactivate(vcpu);
 | 
						kvm_sigset_deactivate(vcpu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					out:
 | 
				
			||||||
 | 
						vcpu_put(vcpu);
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2562,7 +2562,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
 | 
				
			||||||
		r = -EINVAL;
 | 
							r = -EINVAL;
 | 
				
			||||||
		if (arg)
 | 
							if (arg)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
		vcpu_load(vcpu);
 | 
					 | 
				
			||||||
		oldpid = rcu_access_pointer(vcpu->pid);
 | 
							oldpid = rcu_access_pointer(vcpu->pid);
 | 
				
			||||||
		if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
 | 
							if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
 | 
				
			||||||
			/* The thread running this VCPU changed. */
 | 
								/* The thread running this VCPU changed. */
 | 
				
			||||||
| 
						 | 
					@ -2574,7 +2573,6 @@ static long kvm_vcpu_ioctl(struct file *filp,
 | 
				
			||||||
			put_pid(oldpid);
 | 
								put_pid(oldpid);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
 | 
							r = kvm_arch_vcpu_ioctl_run(vcpu, vcpu->run);
 | 
				
			||||||
		vcpu_put(vcpu);
 | 
					 | 
				
			||||||
		trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
 | 
							trace_kvm_userspace_exit(vcpu->run->exit_reason, r);
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue