Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6d33834 authored by Christoffer Dall's avatar Christoffer Dall Committed by Avi Kivity
Browse files

KVM: Factor out kvm_vcpu_kick to arch-generic code



The kvm_vcpu_kick function performs roughly the same funcitonality on
most all architectures, so we shouldn't have separate copies.

PowerPC keeps a pointer to interchanging waitqueues on the vcpu_arch
structure and to accomodate this special need a
__KVM_HAVE_ARCH_VCPU_GET_WQ define and accompanying function
kvm_arch_vcpu_wq have been defined. For all other architectures this
is a generic inline that just returns &vcpu->wq;

Acked-by: default avatarScott Wood <scottwood@freescale.com>
Signed-off-by: default avatarChristoffer Dall <c.dall@virtualopensystems.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 66ef8931
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -365,6 +365,7 @@ struct thash_cb {
};

struct kvm_vcpu_stat {
	u32 halt_wakeup;
};

struct kvm_vcpu_arch {
+5 −15
Original line number Diff line number Diff line
@@ -1872,21 +1872,6 @@ void kvm_arch_hardware_unsetup(void)
{
}

void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
{
	int me;
	int cpu = vcpu->cpu;

	if (waitqueue_active(&vcpu->wq))
		wake_up_interruptible(&vcpu->wq);

	me = get_cpu();
	if (cpu != me && (unsigned) cpu < nr_cpu_ids && cpu_online(cpu))
		if (!test_and_set_bit(KVM_REQ_KICK, &vcpu->requests))
			smp_send_reschedule(cpu);
	put_cpu();
}

int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq)
{
	return __apic_accept_irq(vcpu, irq->vector);
@@ -1956,6 +1941,11 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
		(kvm_highest_pending_irq(vcpu) != -1);
}

int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
{
	return (!test_and_set_bit(KVM_REQ_KICK, &vcpu->requests));
}

int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
				    struct kvm_mp_state *mp_state)
{
+6 −0
Original line number Diff line number Diff line
@@ -498,4 +498,10 @@ struct kvm_vcpu_arch {
#define KVM_MMIO_REG_QPR	0x0040
#define KVM_MMIO_REG_FQPR	0x0060

#define __KVM_HAVE_ARCH_VCPU_GET_WQ 1
static inline wait_queue_head *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
{
	return vcpu->arch.wqp;
}

#endif /* __POWERPC_KVM_HOST_H__ */
+6 −15
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
	       v->requests;
}

int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
{
	return 1;
}

int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
{
	int nr = kvmppc_get_gpr(vcpu, 11);
@@ -588,21 +593,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
	return r;
}

void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
{
	int me;
	int cpu = vcpu->cpu;

	me = get_cpu();
	if (waitqueue_active(vcpu->arch.wqp)) {
		wake_up_interruptible(vcpu->arch.wqp);
		vcpu->stat.halt_wakeup++;
	} else if (cpu != me && cpu != -1) {
		smp_send_reschedule(vcpu->cpu);
	}
	put_cpu();
}

int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
{
	if (irq->irq == KVM_INTERRUPT_UNSET) {
@@ -611,6 +601,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
	}

	kvmppc_core_queue_external(vcpu, irq);

	kvm_vcpu_kick(vcpu);

	return 0;
+8 −0
Original line number Diff line number Diff line
@@ -423,6 +423,14 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
	return 0;
}

int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
{
	/* kvm common code refers to this, but never calls it */
	BUG();
	return 0;
}


static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu)
{
	kvm_s390_vcpu_initial_reset(vcpu);
Loading