Skip to contentSkip to conversation

Reduce interface between kvm general and kvm arch.

PATCH In review Gleb Natapov 2 participants 4 messages Jul 9, 2009 – Jul 12, 2009

Subsystems (7)
x86 KVM PowerPC s390 +3 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reduce interface between kvm general and kvm arch.

Remove kvm_cpu_has_interrupt() and kvm_arch_interrupt_allowed() from interface between general code and arch code. kvm_arch_vcpu_runnable() checks for interrupts instead.

---
 arch/ia64/kvm/kvm-ia64.c        |   16 ++--------------
 arch/powerpc/kvm/powerpc.c      |   13 +------------
 arch/s390/kvm/interrupt.c       |    8 +-------
 arch/x86/include/asm/kvm_host.h |    2 ++
 arch/x86/kvm/x86.c              |    6 ++++--
 include/linux/kvm_host.h        |    2 --
 virt/kvm/kvm_main.c             |    4 +---
 7 files changed, 11 insertions(+), 40 deletions(-)
arch/ia64/kvm/kvm-ia64.c +2 -14
index 8054d7b..421c3a4 100644
@@ -1935,19 +1935,6 @@ int kvm_highest_pending_irq(struct kvm_vcpu *vcpu)
     return find_highest_bits((int *)&vpd->irr[0]);
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
-{
-	if (kvm_highest_pending_irq(vcpu) != -1)
-		return 1;
-	return 0;
-}
-
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-	/* do real check here */
-	return 1;
-}
-
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
 {
 	return vcpu->arch.timer_fired;
@@ -1960,7 +1947,8 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
 
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
-	return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE;
+	return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE) ||
+		(kvm_highest_pending_irq(vcpu) != -1);
 }
 
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
arch/powerpc/kvm/powerpc.c +1 -12
index 0341391..2a4551f 100644
@@ -39,20 +39,9 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
 	return gfn;
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
-{
-	return !!(v->arch.pending_exceptions);
-}
-
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-	/* do real check here */
-	return 1;
-}
-
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
 {
-	return !(v->arch.msr & MSR_WE);
+	return !(v->arch.msr & MSR_WE) || !!(v->arch.pending_exceptions);
 }
 
 
arch/s390/kvm/interrupt.c +1 -7
index f04f530..5f2e144 100644
@@ -283,7 +283,7 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
-int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
+static int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
 {
 	struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
 	struct kvm_s390_float_interrupt *fi = vcpu->arch.local_int.float_int;
@@ -320,12 +320,6 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu)
 	return rc;
 }
 
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu)
-{
-	/* do real check here */
-	return 1;
-}
-
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
 {
 	return 0;
arch/x86/include/asm/kvm_host.h +2 -0
index 30b625d..bbc9727 100644
@@ -797,5 +797,7 @@ asmlinkage void kvm_handle_fault_on_reboot(void);
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
 int kvm_age_hva(struct kvm *kvm, unsigned long hva);
 int cpuid_maxphyaddr(struct kvm_vcpu *vcpu);
+int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu);
+int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 
 #endif /* _ASM_X86_KVM_HOST_H */
arch/x86/kvm/x86.c +4 -2
index de73e7c..00844eb 100644
@@ -4829,8 +4829,10 @@ void kvm_arch_flush_shadow(struct kvm *kvm)
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 {
 	return vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE
-	       || vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED
-	       || vcpu->arch.nmi_pending;
+		|| vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED
+		|| vcpu->arch.nmi_pending ||
+		(kvm_arch_interrupt_allowed(vcpu) &&
+		 kvm_cpu_has_interrupt(vcpu));
 }
 
 void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
include/linux/kvm_host.h +0 -2
index 8e04a34..3778081 100644
@@ -326,7 +326,6 @@ int kvm_arch_hardware_setup(void);
 void kvm_arch_hardware_unsetup(void);
 void kvm_arch_check_processor_compat(void *rtn);
 int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
-int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 
 void kvm_free_physmem(struct kvm *kvm);
 
@@ -336,7 +335,6 @@ void kvm_free_all_assigned_devices(struct kvm *kvm);
 void kvm_arch_sync_events(struct kvm *kvm);
 
 int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
-int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
 int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
 void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
 
virt/kvm/kvm_main.c +1 -3
index 05b6bc7..cf20dc1 100644
@@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 	for (;;) {
 		prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE);
 
-		if ((kvm_arch_interrupt_allowed(vcpu) &&
-					kvm_cpu_has_interrupt(vcpu)) ||
-				kvm_arch_vcpu_runnable(vcpu)) {
+		if (kvm_arch_vcpu_runnable(vcpu)) {
 			set_bit(KVM_REQ_UNHALT, &vcpu->requests);
 			break;
 		}
Signature · 1 line
1.6.2.1
#1 lore raw
Quoted 7 lines · Gleb Natapov
virt/kvm/kvm_main.c +0 -0
index 05b6bc7..cf20dc1 100644

virt/kvm/kvm_main.c void kvm_vcpu_block(struct kvm_vcpu *vcpu) · line 1672

Quoted 10 lines
virt/kvm/kvm_main.c +1 -3
@@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
  	for (;;) {
  		prepare_to_wait(&vcpu->wq,&wait, TASK_INTERRUPTIBLE);
 
-		if ((kvm_arch_interrupt_allowed(vcpu)&&
-					kvm_cpu_has_interrupt(vcpu)) ||
-				kvm_arch_vcpu_runnable(vcpu)) {
+		if (kvm_arch_vcpu_runnable(vcpu)) {
  			set_bit(KVM_REQ_UNHALT,&vcpu->requests);
  			break;
  		}

s390 has:

int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)

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

So this needs to be updated. Please coordinate with the s390 folks.

Signature · 1 line
error compiling committee.c: too many arguments to function
#2 lore raw
Quoted 22 lines · Avi Kivity
Quoted 7 lines · Gleb Natapov
virt/kvm/kvm_main.c +0 -0
index 05b6bc7..cf20dc1 100644

virt/kvm/kvm_main.c void kvm_vcpu_block(struct kvm_vcpu *vcpu) · line 1672

Quoted 10 lines
virt/kvm/kvm_main.c +1 -3
@@ -1666,9 +1666,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
  	for (;;) {
  		prepare_to_wait(&vcpu->wq,&wait, TASK_INTERRUPTIBLE);
 
-		if ((kvm_arch_interrupt_allowed(vcpu)&&
-					kvm_cpu_has_interrupt(vcpu)) ||
-				kvm_arch_vcpu_runnable(vcpu)) {
+		if (kvm_arch_vcpu_runnable(vcpu)) {
  			set_bit(KVM_REQ_UNHALT,&vcpu->requests);
  			break;
  		}

s390 has:

Quoted 9 lines

int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)

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

So this needs to be updated. Please coordinate with the s390 folks.

s390 never calls kvm_vcpu_block(). They implement their own blocking.

--
Gleb.

#3 lore raw
Quoted 11 lines · Gleb Natapov
Quoted 11 lines

s390 has:

int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)

{
     /* kvm common code refers to this, but never calls it */
     BUG();
     return 0;
}
Quoted 6 lines
Quoted 3 lines

So this needs to be updated. Please coordinate with the s390 folks.

s390 never calls kvm_vcpu_block(). They implement their own blocking.

Right; applied.

Signature · 1 line
error compiling committee.c: too many arguments to function