kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too.
@ 2009-04-07  9:08 Gleb Natapov
  2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Gleb Natapov @ 2009-04-07  9:08 UTC (permalink / raw)
  To: avi; +Cc: kvm

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---

 arch/x86/kvm/irq.c |   39 +++++++++++++++++++++++----------------
 arch/x86/kvm/svm.c |   11 +++++++----
 arch/x86/kvm/vmx.c |   18 +++++++++---------
 arch/x86/kvm/x86.c |    4 ++--
 4 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
index cf17ed5..6974e7c 100644
--- a/arch/x86/kvm/irq.c
+++ b/arch/x86/kvm/irq.c
@@ -24,6 +24,7 @@
 
 #include "irq.h"
 #include "i8254.h"
+#include "x86.h"
 
 /*
  * check if there are pending timer events
@@ -48,14 +49,17 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
 {
 	struct kvm_pic *s;
 
-	if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
-		if (kvm_apic_accept_pic_intr(v)) {
-			s = pic_irqchip(v->kvm);	/* PIC */
-			return s->output;
-		} else
-			return 0;
+	if (irqchip_in_kernel(v->kvm)) {
+		if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
+			if (kvm_apic_accept_pic_intr(v)) {
+				s = pic_irqchip(v->kvm);	/* PIC */
+				return s->output;
+			} else
+				return 0;
+		}
+		return 1;
 	}
-	return 1;
+	return v->arch.irq_summary;
 }
 EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
 
@@ -64,18 +68,21 @@ EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
  */
 int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
 {
-	struct kvm_pic *s;
-	int vector;
+	if (irqchip_in_kernel(v->kvm)) {
+		struct kvm_pic *s;
+		int vector;
 
-	vector = kvm_get_apic_interrupt(v);	/* APIC */
-	if (vector == -1) {
-		if (kvm_apic_accept_pic_intr(v)) {
-			s = pic_irqchip(v->kvm);
-			s->output = 0;		/* PIC */
-			vector = kvm_pic_read_irq(v->kvm);
+		vector = kvm_get_apic_interrupt(v);	/* APIC */
+		if (vector == -1) {
+			if (kvm_apic_accept_pic_intr(v)) {
+				s = pic_irqchip(v->kvm);
+				s->output = 0;		/* PIC */
+				vector = kvm_pic_read_irq(v->kvm);
+			}
 		}
+		return vector;
 	}
-	return vector;
+	return kvm_pop_irq(v);
 }
 EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
 
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 053f3c5..1903c27 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2089,8 +2089,9 @@ static int interrupt_window_interception(struct vcpu_svm *svm,
 	 * If the user space waits to inject interrupts, exit as soon as
 	 * possible
 	 */
-	if (kvm_run->request_interrupt_window &&
-	    !svm->vcpu.arch.irq_summary) {
+	if (!irqchip_in_kernel(svm->vcpu.kvm) &&
+	    kvm_run->request_interrupt_window &&
+	    !kvm_cpu_has_interrupt(&svm->vcpu)) {
 		++svm->vcpu.stat.irq_window_exits;
 		kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
 		return 0;
@@ -2371,7 +2372,8 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
 		 (svm->vmcb->save.rflags & X86_EFLAGS_IF) &&
 		 (svm->vcpu.arch.hflags & HF_GIF_MASK));
 
-	if (svm->vcpu.arch.interrupt_window_open && svm->vcpu.arch.irq_summary)
+	if (svm->vcpu.arch.interrupt_window_open &&
+	    kvm_cpu_has_interrupt(&svm->vcpu))
 		/*
 		 * If interrupts enabled, and not blocked by sti or mov ss. Good.
 		 */
@@ -2381,7 +2383,8 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
 	 * Interrupts blocked.  Wait for unblock.
 	 */
 	if (!svm->vcpu.arch.interrupt_window_open &&
-	    (svm->vcpu.arch.irq_summary || kvm_run->request_interrupt_window))
+	    (kvm_cpu_has_interrupt(&svm->vcpu) ||
+	     kvm_run->request_interrupt_window))
 		svm_set_vintr(svm);
 	else
 		svm_clear_vintr(svm);
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c6997c0..b3292c1 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2535,21 +2535,20 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
 		vmx_inject_nmi(vcpu);
 		if (vcpu->arch.nmi_pending)
 			enable_nmi_window(vcpu);
-		else if (vcpu->arch.irq_summary
-			 || kvm_run->request_interrupt_window)
+		else if (kvm_cpu_has_interrupt(vcpu) ||
+			 kvm_run->request_interrupt_window)
 			enable_irq_window(vcpu);
 		return;
 	}
 
 	if (vcpu->arch.interrupt_window_open) {
-		if (vcpu->arch.irq_summary && !vcpu->arch.interrupt.pending)
-			kvm_queue_interrupt(vcpu, kvm_pop_irq(vcpu));
+		if (kvm_cpu_has_interrupt(vcpu) && !vcpu->arch.interrupt.pending)
+			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
 
 		if (vcpu->arch.interrupt.pending)
 			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
-	}
-	if (!vcpu->arch.interrupt_window_open &&
-	    (vcpu->arch.irq_summary || kvm_run->request_interrupt_window))
+	} else if(kvm_cpu_has_interrupt(vcpu) ||
+		  kvm_run->request_interrupt_window)
 		enable_irq_window(vcpu);
 }
 
@@ -2976,8 +2975,9 @@ static int handle_interrupt_window(struct kvm_vcpu *vcpu,
 	 * If the user space waits to inject interrupts, exit as soon as
 	 * possible
 	 */
-	if (kvm_run->request_interrupt_window &&
-	    !vcpu->arch.irq_summary) {
+	if (!irqchip_in_kernel(vcpu->kvm) &&
+	    kvm_run->request_interrupt_window &&
+	    !kvm_cpu_has_interrupt(vcpu)) {
 		kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
 		return 0;
 	}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 52c7a29..6e30cef 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3064,7 +3064,7 @@ EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
 static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu,
 					  struct kvm_run *kvm_run)
 {
-	return (!vcpu->arch.irq_summary &&
+	return (!irqchip_in_kernel(vcpu->kvm) && !kvm_cpu_has_interrupt(vcpu) &&
 		kvm_run->request_interrupt_window &&
 		vcpu->arch.interrupt_window_open &&
 		(kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF));
@@ -3081,7 +3081,7 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu,
 	else
 		kvm_run->ready_for_interrupt_injection =
 					(vcpu->arch.interrupt_window_open &&
-					 vcpu->arch.irq_summary == 0);
+					 !kvm_cpu_has_interrupt(vcpu));
 }
 
 static void vapic_enter(struct kvm_vcpu *vcpu)


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX.
  2009-04-07  9:08 [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Gleb Natapov
@ 2009-04-07  9:08 ` Gleb Natapov
  2009-04-11 11:29   ` Avi Kivity
  2009-04-07  9:08 ` [PATCH 3/3] Cleanup vmx_intr_assist() Gleb Natapov
  2009-04-07  9:56 ` [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Sheng Yang
  2 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-04-07  9:08 UTC (permalink / raw)
  To: avi; +Cc: kvm

Use the same callback to inject irq/nmi events no matter what irqchip is
in use. Only from VMX for now.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---

 arch/x86/include/asm/kvm_host.h |    2 +
 arch/x86/kvm/svm.c              |    2 +
 arch/x86/kvm/vmx.c              |   71 +++++++++------------------------------
 arch/x86/kvm/x86.c              |    2 +
 4 files changed, 19 insertions(+), 58 deletions(-)

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index e672ca5..4e39c40 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -520,7 +520,7 @@ struct kvm_x86_ops {
 	void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
 				bool has_error_code, u32 error_code);
 	bool (*exception_injected)(struct kvm_vcpu *vcpu);
-	void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
+	void (*inject_pending_irq)(struct kvm_vcpu *vcpu, struct kvm_run *run);
 	void (*inject_pending_vectors)(struct kvm_vcpu *vcpu,
 				       struct kvm_run *run);
 	int (*interrupt_allowed)(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1903c27..674a249 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2296,7 +2296,7 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu)
 		(svm->vcpu.arch.hflags & HF_GIF_MASK);
 }
 
-static void svm_intr_assist(struct kvm_vcpu *vcpu)
+static void svm_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
 	struct vcpu_svm *svm = to_svm(vcpu);
 	struct vmcb *vmcb = svm->vmcb;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b3292c1..06252f7 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2510,48 +2510,6 @@ static int vmx_interrupt_allowed(struct kvm_vcpu *vcpu)
 	return vcpu->arch.interrupt_window_open;
 }
 
-static void do_interrupt_requests(struct kvm_vcpu *vcpu,
-				       struct kvm_run *kvm_run)
-{
-	vmx_update_window_states(vcpu);
-
-	if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP)
-		vmcs_clear_bits(GUEST_INTERRUPTIBILITY_INFO,
-				GUEST_INTR_STATE_STI |
-				GUEST_INTR_STATE_MOV_SS);
-
-	if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) {
-		if (vcpu->arch.interrupt.pending) {
-			enable_nmi_window(vcpu);
-		} else if (vcpu->arch.nmi_window_open) {
-			vcpu->arch.nmi_pending = false;
-			vcpu->arch.nmi_injected = true;
-		} else {
-			enable_nmi_window(vcpu);
-			return;
-		}
-	}
-	if (vcpu->arch.nmi_injected) {
-		vmx_inject_nmi(vcpu);
-		if (vcpu->arch.nmi_pending)
-			enable_nmi_window(vcpu);
-		else if (kvm_cpu_has_interrupt(vcpu) ||
-			 kvm_run->request_interrupt_window)
-			enable_irq_window(vcpu);
-		return;
-	}
-
-	if (vcpu->arch.interrupt_window_open) {
-		if (kvm_cpu_has_interrupt(vcpu) && !vcpu->arch.interrupt.pending)
-			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
-
-		if (vcpu->arch.interrupt.pending)
-			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
-	} else if(kvm_cpu_has_interrupt(vcpu) ||
-		  kvm_run->request_interrupt_window)
-		enable_irq_window(vcpu);
-}
-
 static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
 {
 	int ret;
@@ -3351,8 +3309,11 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
 	}
 }
 
-static void vmx_intr_assist(struct kvm_vcpu *vcpu)
+static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
+	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
+		kvm_run->request_interrupt_window;
+
 	update_tpr_threshold(vcpu);
 
 	vmx_update_window_states(vcpu);
@@ -3373,25 +3334,25 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
 			return;
 		}
 	}
+
 	if (vcpu->arch.nmi_injected) {
 		vmx_inject_nmi(vcpu);
-		if (vcpu->arch.nmi_pending)
-			enable_nmi_window(vcpu);
-		else if (kvm_cpu_has_interrupt(vcpu))
-			enable_irq_window(vcpu);
-		return;
+		goto out;
 	}
+
 	if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
 		if (vcpu->arch.interrupt_window_open)
 			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
-		else
-			enable_irq_window(vcpu);
 	}
-	if (vcpu->arch.interrupt.pending) {
+
+	if (vcpu->arch.interrupt.pending)
 		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
-		if (kvm_cpu_has_interrupt(vcpu))
-			enable_irq_window(vcpu);
-	}
+
+out:
+	if (vcpu->arch.nmi_pending)
+		enable_nmi_window(vcpu);
+	else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
+		enable_irq_window(vcpu);
 }
 
 /*
@@ -3733,7 +3694,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
 	.queue_exception = vmx_queue_exception,
 	.exception_injected = vmx_exception_injected,
 	.inject_pending_irq = vmx_intr_assist,
-	.inject_pending_vectors = do_interrupt_requests,
+	.inject_pending_vectors = vmx_intr_assist,
 	.interrupt_allowed = vmx_interrupt_allowed,
 	.set_tss_addr = vmx_set_tss_addr,
 	.get_tdp_level = get_ept_level,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6e30cef..1c19215 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3168,7 +3168,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	if (vcpu->arch.exception.pending)
 		__queue_exception(vcpu);
 	else if (irqchip_in_kernel(vcpu->kvm))
-		kvm_x86_ops->inject_pending_irq(vcpu);
+		kvm_x86_ops->inject_pending_irq(vcpu, kvm_run);
 	else
 		kvm_x86_ops->inject_pending_vectors(vcpu, kvm_run);
 


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] Cleanup vmx_intr_assist()
  2009-04-07  9:08 [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Gleb Natapov
  2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
@ 2009-04-07  9:08 ` Gleb Natapov
  2009-04-11 11:30   ` Avi Kivity
  2009-04-07  9:56 ` [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Sheng Yang
  2 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-04-07  9:08 UTC (permalink / raw)
  To: avi; +Cc: kvm

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---

 arch/x86/kvm/vmx.c |   55 ++++++++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 06252f7..9eb518f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3309,6 +3309,34 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
 	}
 }
 
+static void vmx_intr_inject(struct kvm_vcpu *vcpu)
+{
+	/* try to reinject previous events if any */
+	if (vcpu->arch.nmi_injected) {
+		vmx_inject_nmi(vcpu);
+		return;
+	}
+
+	if (vcpu->arch.interrupt.pending) {
+		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
+		return;
+	}
+
+	/* try to inject new event if pending */
+	if (vcpu->arch.nmi_pending) {
+		if (vcpu->arch.nmi_window_open) {
+			vcpu->arch.nmi_pending = false;
+			vcpu->arch.nmi_injected = true;
+			vmx_inject_nmi(vcpu);
+		}
+	} else if (kvm_cpu_has_interrupt(vcpu)) {
+		if (vcpu->arch.interrupt_window_open) {
+			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
+			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
+		}
+	}
+}
+
 static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 {
 	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
@@ -3323,32 +3351,9 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 				GUEST_INTR_STATE_STI |
 				GUEST_INTR_STATE_MOV_SS);
 
-	if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) {
-		if (vcpu->arch.interrupt.pending) {
-			enable_nmi_window(vcpu);
-		} else if (vcpu->arch.nmi_window_open) {
-			vcpu->arch.nmi_pending = false;
-			vcpu->arch.nmi_injected = true;
-		} else {
-			enable_nmi_window(vcpu);
-			return;
-		}
-	}
-
-	if (vcpu->arch.nmi_injected) {
-		vmx_inject_nmi(vcpu);
-		goto out;
-	}
-
-	if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
-		if (vcpu->arch.interrupt_window_open)
-			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
-	}
-
-	if (vcpu->arch.interrupt.pending)
-		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
+	vmx_intr_inject(vcpu);
 
-out:
+	/* enable NMI/IRQ window open exits if needed */
 	if (vcpu->arch.nmi_pending)
 		enable_nmi_window(vcpu);
 	else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too.
  2009-04-07  9:08 [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Gleb Natapov
  2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
  2009-04-07  9:08 ` [PATCH 3/3] Cleanup vmx_intr_assist() Gleb Natapov
@ 2009-04-07  9:56 ` Sheng Yang
  2009-04-07 10:07   ` Gleb Natapov
  2 siblings, 1 reply; 10+ messages in thread
From: Sheng Yang @ 2009-04-07  9:56 UTC (permalink / raw)
  To: kvm; +Cc: Gleb Natapov, avi

On Tuesday 07 April 2009 17:08:12 Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>
>  arch/x86/kvm/irq.c |   39 +++++++++++++++++++++++----------------
>  arch/x86/kvm/svm.c |   11 +++++++----
>  arch/x86/kvm/vmx.c |   18 +++++++++---------
>  arch/x86/kvm/x86.c |    4 ++--
>  4 files changed, 41 insertions(+), 31 deletions(-)
>
> diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
> index cf17ed5..6974e7c 100644
> --- a/arch/x86/kvm/irq.c
> +++ b/arch/x86/kvm/irq.c
> @@ -24,6 +24,7 @@
>
>  #include "irq.h"
>  #include "i8254.h"
> +#include "x86.h"
>
>  /*
>   * check if there are pending timer events
> @@ -48,14 +49,17 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
>  {
>  	struct kvm_pic *s;
>
> -	if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> -		if (kvm_apic_accept_pic_intr(v)) {
> -			s = pic_irqchip(v->kvm);	/* PIC */
> -			return s->output;
> -		} else
> -			return 0;
> +	if (irqchip_in_kernel(v->kvm)) {
> +		if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> +			if (kvm_apic_accept_pic_intr(v)) {
> +				s = pic_irqchip(v->kvm);	/* PIC */
> +				return s->output;
> +			} else
> +				return 0;
> +		}
> +		return 1;
>  	}
> -	return 1;
> +	return v->arch.irq_summary;
>  }

Use if (!irqchip_in_kernel(v->kvm)) for userspace seems more simple(rather 
than a series of indention...).

>  EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
>
> @@ -64,18 +68,21 @@ EXPORT_SYMBOL_GPL(kvm_cpu_has_interrupt);
>   */
>  int kvm_cpu_get_interrupt(struct kvm_vcpu *v)
>  {
> -	struct kvm_pic *s;
> -	int vector;
> +	if (irqchip_in_kernel(v->kvm)) {
> +		struct kvm_pic *s;
> +		int vector;
>
> -	vector = kvm_get_apic_interrupt(v);	/* APIC */
> -	if (vector == -1) {
> -		if (kvm_apic_accept_pic_intr(v)) {
> -			s = pic_irqchip(v->kvm);
> -			s->output = 0;		/* PIC */
> -			vector = kvm_pic_read_irq(v->kvm);
> +		vector = kvm_get_apic_interrupt(v);	/* APIC */
> +		if (vector == -1) {
> +			if (kvm_apic_accept_pic_intr(v)) {
> +				s = pic_irqchip(v->kvm);
> +				s->output = 0;		/* PIC */
> +				vector = kvm_pic_read_irq(v->kvm);
> +			}
>  		}
> +		return vector;
>  	}
> -	return vector;
> +	return kvm_pop_irq(v);
>  }
>  EXPORT_SYMBOL_GPL(kvm_cpu_get_interrupt);
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 053f3c5..1903c27 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -2089,8 +2089,9 @@ static int interrupt_window_interception(struct
> vcpu_svm *svm, * If the user space waits to inject interrupts, exit as soon
> as * possible
>  	 */
> -	if (kvm_run->request_interrupt_window &&
> -	    !svm->vcpu.arch.irq_summary) {
> +	if (!irqchip_in_kernel(svm->vcpu.kvm) &&
> +	    kvm_run->request_interrupt_window &&
> +	    !kvm_cpu_has_interrupt(&svm->vcpu)) {
>  		++svm->vcpu.stat.irq_window_exits;
>  		kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
>  		return 0;
> @@ -2371,7 +2372,8 @@ static void do_interrupt_requests(struct kvm_vcpu
> *vcpu, (svm->vmcb->save.rflags & X86_EFLAGS_IF) &&
>  		 (svm->vcpu.arch.hflags & HF_GIF_MASK));
>
> -	if (svm->vcpu.arch.interrupt_window_open && svm->vcpu.arch.irq_summary)
> +	if (svm->vcpu.arch.interrupt_window_open &&
> +	    kvm_cpu_has_interrupt(&svm->vcpu))
>  		/*
>  		 * If interrupts enabled, and not blocked by sti or mov ss. Good.
>  		 */
> @@ -2381,7 +2383,8 @@ static void do_interrupt_requests(struct kvm_vcpu
> *vcpu, * Interrupts blocked.  Wait for unblock.
>  	 */
>  	if (!svm->vcpu.arch.interrupt_window_open &&
> -	    (svm->vcpu.arch.irq_summary || kvm_run->request_interrupt_window))
> +	    (kvm_cpu_has_interrupt(&svm->vcpu) ||
> +	     kvm_run->request_interrupt_window))
>  		svm_set_vintr(svm);
>  	else
>  		svm_clear_vintr(svm);
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c6997c0..b3292c1 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2535,21 +2535,20 @@ static void do_interrupt_requests(struct kvm_vcpu
> *vcpu, vmx_inject_nmi(vcpu);
>  		if (vcpu->arch.nmi_pending)
>  			enable_nmi_window(vcpu);
> -		else if (vcpu->arch.irq_summary
> -			 || kvm_run->request_interrupt_window)
> +		else if (kvm_cpu_has_interrupt(vcpu) ||
> +			 kvm_run->request_interrupt_window)
>  			enable_irq_window(vcpu);
>  		return;
>  	}
>
>  	if (vcpu->arch.interrupt_window_open) {
> -		if (vcpu->arch.irq_summary && !vcpu->arch.interrupt.pending)
> -			kvm_queue_interrupt(vcpu, kvm_pop_irq(vcpu));
> +		if (kvm_cpu_has_interrupt(vcpu) && !vcpu->arch.interrupt.pending)
> +			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
>
>  		if (vcpu->arch.interrupt.pending)
>  			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> -	}
> -	if (!vcpu->arch.interrupt_window_open &&
> -	    (vcpu->arch.irq_summary || kvm_run->request_interrupt_window))
> +	} else if(kvm_cpu_has_interrupt(vcpu) ||
> +		  kvm_run->request_interrupt_window)
>  		enable_irq_window(vcpu);
>  }
>
> @@ -2976,8 +2975,9 @@ static int handle_interrupt_window(struct kvm_vcpu
> *vcpu, * If the user space waits to inject interrupts, exit as soon as *
> possible
>  	 */
> -	if (kvm_run->request_interrupt_window &&
> -	    !vcpu->arch.irq_summary) {
> +	if (!irqchip_in_kernel(vcpu->kvm) &&
> +	    kvm_run->request_interrupt_window &&

I think kvm_run->request_interrupt_window can indicate it's userspace irqchip?

> +	    !kvm_cpu_has_interrupt(vcpu)) {
>  		kvm_run->exit_reason = KVM_EXIT_IRQ_WINDOW_OPEN;
>  		return 0;
>  	}
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 52c7a29..6e30cef 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3064,7 +3064,7 @@ EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);
>  static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu,
>  					  struct kvm_run *kvm_run)
>  {
> -	return (!vcpu->arch.irq_summary &&
> +	return (!irqchip_in_kernel(vcpu->kvm) && !kvm_cpu_has_interrupt(vcpu) &&
>  		kvm_run->request_interrupt_window &&

ditto.

-- 
regards
Yang, Sheng

>  		vcpu->arch.interrupt_window_open &&
>  		(kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_IF));
> @@ -3081,7 +3081,7 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu,
>  	else
>  		kvm_run->ready_for_interrupt_injection =
>  					(vcpu->arch.interrupt_window_open &&
> -					 vcpu->arch.irq_summary == 0);
> +					 !kvm_cpu_has_interrupt(vcpu));
>  }
>
>  static void vapic_enter(struct kvm_vcpu *vcpu)
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too.
  2009-04-07  9:56 ` [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Sheng Yang
@ 2009-04-07 10:07   ` Gleb Natapov
  2009-04-11 11:24     ` Avi Kivity
  0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-04-07 10:07 UTC (permalink / raw)
  To: Sheng Yang; +Cc: kvm, avi

> >   * check if there are pending timer events
> > @@ -48,14 +49,17 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
> >  {
> >  	struct kvm_pic *s;
> >
> > -	if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> > -		if (kvm_apic_accept_pic_intr(v)) {
> > -			s = pic_irqchip(v->kvm);	/* PIC */
> > -			return s->output;
> > -		} else
> > -			return 0;
> > +	if (irqchip_in_kernel(v->kvm)) {
> > +		if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
> > +			if (kvm_apic_accept_pic_intr(v)) {
> > +				s = pic_irqchip(v->kvm);	/* PIC */
> > +				return s->output;
> > +			} else
> > +				return 0;
> > +		}
> > +		return 1;
> >  	}
> > -	return 1;
> > +	return v->arch.irq_summary;
> >  }
> 
> Use if (!irqchip_in_kernel(v->kvm)) for userspace seems more simple(rather 
> than a series of indention...).
> 
As long as lines are smaller then 80 chars I don't care much :) If new
version of the patch will be needed I'll change this.

> >
> > @@ -2976,8 +2975,9 @@ static int handle_interrupt_window(struct kvm_vcpu
> > *vcpu, * If the user space waits to inject interrupts, exit as soon as *
> > possible
> >  	 */
> > -	if (kvm_run->request_interrupt_window &&
> > -	    !vcpu->arch.irq_summary) {
> > +	if (!irqchip_in_kernel(vcpu->kvm) &&
> > +	    kvm_run->request_interrupt_window &&
> 
> I think kvm_run->request_interrupt_window can indicate it's userspace irqchip?
> 
You are correct, but this value is directly controlled by userspase, so
I added irqchip_in_kernel() check to protect from buggy userspace.
 
--
			Gleb.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too.
  2009-04-07 10:07   ` Gleb Natapov
@ 2009-04-11 11:24     ` Avi Kivity
  0 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2009-04-11 11:24 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: Sheng Yang, kvm

Gleb Natapov wrote:
>>>   * check if there are pending timer events
>>> @@ -48,14 +49,17 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
>>>  {
>>>  	struct kvm_pic *s;
>>>
>>> -	if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
>>> -		if (kvm_apic_accept_pic_intr(v)) {
>>> -			s = pic_irqchip(v->kvm);	/* PIC */
>>> -			return s->output;
>>> -		} else
>>> -			return 0;
>>> +	if (irqchip_in_kernel(v->kvm)) {
>>> +		if (kvm_apic_has_interrupt(v) == -1) {	/* LAPIC */
>>> +			if (kvm_apic_accept_pic_intr(v)) {
>>> +				s = pic_irqchip(v->kvm);	/* PIC */
>>> +				return s->output;
>>> +			} else
>>> +				return 0;
>>> +		}
>>> +		return 1;
>>>  	}
>>> -	return 1;
>>> +	return v->arch.irq_summary;
>>>  }
>>>       
>> Use if (!irqchip_in_kernel(v->kvm)) for userspace seems more simple(rather 
>> than a series of indention...).
>>
>>     
> As long as lines are smaller then 80 chars I don't care much :) If new
> version of the patch will be needed I'll change this.
>   

Please change it, the less indentation levels the better.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX.
  2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
@ 2009-04-11 11:29   ` Avi Kivity
  2009-04-11 19:53     ` Gleb Natapov
  0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2009-04-11 11:29 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

Gleb Natapov wrote:
> Use the same callback to inject irq/nmi events no matter what irqchip is
> in use. Only from VMX for now.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>
>  arch/x86/include/asm/kvm_host.h |    2 +
>  arch/x86/kvm/svm.c              |    2 +
>  arch/x86/kvm/vmx.c              |   71 +++++++++------------------------------
>  arch/x86/kvm/x86.c              |    2 +
>  4 files changed, 19 insertions(+), 58 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index e672ca5..4e39c40 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -520,7 +520,7 @@ struct kvm_x86_ops {
>  	void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
>  				bool has_error_code, u32 error_code);
>  	bool (*exception_injected)(struct kvm_vcpu *vcpu);
> -	void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
> +	void (*inject_pending_irq)(struct kvm_vcpu *vcpu, struct kvm_run *run);
>   

kvm_run is available as vcpu->run, so this isn't needed.  But better to 
keep it for now and drop it in a later patch.

>  static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
>  {
>  	int ret;
> @@ -3351,8 +3309,11 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
>  	}
>  }
>  
> -static void vmx_intr_assist(struct kvm_vcpu *vcpu)
> +static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  {
> +	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
> +		kvm_run->request_interrupt_window;
> +
>  	update_tpr_threshold(vcpu);
>  
>  	vmx_update_window_states(vcpu);
> @@ -3373,25 +3334,25 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
>  			return;
>  		}
>  	}
>   

Why not convert the 'enable_nmi_window(); return;' above to a 'goto out' 
like you do elsewhere?


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] Cleanup vmx_intr_assist()
  2009-04-07  9:08 ` [PATCH 3/3] Cleanup vmx_intr_assist() Gleb Natapov
@ 2009-04-11 11:30   ` Avi Kivity
  2009-04-11 19:52     ` Gleb Natapov
  0 siblings, 1 reply; 10+ messages in thread
From: Avi Kivity @ 2009-04-11 11:30 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm

Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>
>  arch/x86/kvm/vmx.c |   55 ++++++++++++++++++++++++++++------------------------
>  1 files changed, 30 insertions(+), 25 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 06252f7..9eb518f 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3309,6 +3309,34 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
>  	}
>  }
>  
> +static void vmx_intr_inject(struct kvm_vcpu *vcpu)
> +{
> +	/* try to reinject previous events if any */
> +	if (vcpu->arch.nmi_injected) {
> +		vmx_inject_nmi(vcpu);
> +		return;
> +	}
> +
> +	if (vcpu->arch.interrupt.pending) {
> +		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> +		return;
> +	}
> +
> +	/* try to inject new event if pending */
> +	if (vcpu->arch.nmi_pending) {
> +		if (vcpu->arch.nmi_window_open) {
> +			vcpu->arch.nmi_pending = false;
> +			vcpu->arch.nmi_injected = true;
> +			vmx_inject_nmi(vcpu);
> +		}
> +	} else if (kvm_cpu_has_interrupt(vcpu)) {
> +		if (vcpu->arch.interrupt_window_open) {
> +			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
> +			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> +		}
> +	}
> +}
> +
>  static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  {
>  	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
> @@ -3323,32 +3351,9 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>  				GUEST_INTR_STATE_STI |
>  				GUEST_INTR_STATE_MOV_SS);
>  
> -	if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) {
> -		if (vcpu->arch.interrupt.pending) {
> -			enable_nmi_window(vcpu);
> -		} else if (vcpu->arch.nmi_window_open) {
> -			vcpu->arch.nmi_pending = false;
> -			vcpu->arch.nmi_injected = true;
> -		} else {
> -			enable_nmi_window(vcpu);
> -			return;
> -		}
> -	}
> -
> -	if (vcpu->arch.nmi_injected) {
> -		vmx_inject_nmi(vcpu);
> -		goto out;
> -	}
> -
> -	if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
> -		if (vcpu->arch.interrupt_window_open)
> -			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
> -	}
> -
> -	if (vcpu->arch.interrupt.pending)
> -		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
> +	vmx_intr_inject(vcpu);
>  
> -out:
> +	/* enable NMI/IRQ window open exits if needed */
>  	if (vcpu->arch.nmi_pending)
>  		enable_nmi_window(vcpu);
>  	else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
>   

Not sure I understand the motivation.  Just replace a 'goto out' with a 
return?

-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] Cleanup vmx_intr_assist()
  2009-04-11 11:30   ` Avi Kivity
@ 2009-04-11 19:52     ` Gleb Natapov
  0 siblings, 0 replies; 10+ messages in thread
From: Gleb Natapov @ 2009-04-11 19:52 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Sat, Apr 11, 2009 at 02:30:30PM +0300, Avi Kivity wrote:
> Gleb Natapov wrote:
>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
>> ---
>>
>>  arch/x86/kvm/vmx.c |   55 ++++++++++++++++++++++++++++------------------------
>>  1 files changed, 30 insertions(+), 25 deletions(-)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index 06252f7..9eb518f 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -3309,6 +3309,34 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
>>  	}
>>  }
>>  +static void vmx_intr_inject(struct kvm_vcpu *vcpu)
>> +{
>> +	/* try to reinject previous events if any */
>> +	if (vcpu->arch.nmi_injected) {
>> +		vmx_inject_nmi(vcpu);
>> +		return;
>> +	}
>> +
>> +	if (vcpu->arch.interrupt.pending) {
>> +		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
>> +		return;
>> +	}
>> +
>> +	/* try to inject new event if pending */
>> +	if (vcpu->arch.nmi_pending) {
>> +		if (vcpu->arch.nmi_window_open) {
>> +			vcpu->arch.nmi_pending = false;
>> +			vcpu->arch.nmi_injected = true;
>> +			vmx_inject_nmi(vcpu);
>> +		}
>> +	} else if (kvm_cpu_has_interrupt(vcpu)) {
>> +		if (vcpu->arch.interrupt_window_open) {
>> +			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
>> +			vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
>> +		}
>> +	}
>> +}
>> +
>>  static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>>  {
>>  	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
>> @@ -3323,32 +3351,9 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>>  				GUEST_INTR_STATE_STI |
>>  				GUEST_INTR_STATE_MOV_SS);
>>  -	if (vcpu->arch.nmi_pending && !vcpu->arch.nmi_injected) {
>> -		if (vcpu->arch.interrupt.pending) {
>> -			enable_nmi_window(vcpu);
>> -		} else if (vcpu->arch.nmi_window_open) {
>> -			vcpu->arch.nmi_pending = false;
>> -			vcpu->arch.nmi_injected = true;
>> -		} else {
>> -			enable_nmi_window(vcpu);
>> -			return;
>> -		}
>> -	}
>> -
>> -	if (vcpu->arch.nmi_injected) {
>> -		vmx_inject_nmi(vcpu);
>> -		goto out;
>> -	}
>> -
>> -	if (!vcpu->arch.interrupt.pending && kvm_cpu_has_interrupt(vcpu)) {
>> -		if (vcpu->arch.interrupt_window_open)
>> -			kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu));
>> -	}
>> -
>> -	if (vcpu->arch.interrupt.pending)
>> -		vmx_inject_irq(vcpu, vcpu->arch.interrupt.nr);
>> +	vmx_intr_inject(vcpu);
>>  -out:
>> +	/* enable NMI/IRQ window open exits if needed */
>>  	if (vcpu->arch.nmi_pending)
>>  		enable_nmi_window(vcpu);
>>  	else if (kvm_cpu_has_interrupt(vcpu) || req_int_win)
>>   
>
> Not sure I understand the motivation.  Just replace a 'goto out' with a  
> return?
>
Yes. The code is much cleaner this way. It is easy to see that no matter what happened
during injection irq/nmi windows is enabled if there are pending events. With gotos
and returns scattered over the function you'll need to check every single path that may
or may not lead to the window enable code.

--
			Gleb.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX.
  2009-04-11 11:29   ` Avi Kivity
@ 2009-04-11 19:53     ` Gleb Natapov
  0 siblings, 0 replies; 10+ messages in thread
From: Gleb Natapov @ 2009-04-11 19:53 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm

On Sat, Apr 11, 2009 at 02:29:28PM +0300, Avi Kivity wrote:
> Gleb Natapov wrote:
>> Use the same callback to inject irq/nmi events no matter what irqchip is
>> in use. Only from VMX for now.
>>
>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
>> ---
>>
>>  arch/x86/include/asm/kvm_host.h |    2 +
>>  arch/x86/kvm/svm.c              |    2 +
>>  arch/x86/kvm/vmx.c              |   71 +++++++++------------------------------
>>  arch/x86/kvm/x86.c              |    2 +
>>  4 files changed, 19 insertions(+), 58 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index e672ca5..4e39c40 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -520,7 +520,7 @@ struct kvm_x86_ops {
>>  	void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
>>  				bool has_error_code, u32 error_code);
>>  	bool (*exception_injected)(struct kvm_vcpu *vcpu);
>> -	void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
>> +	void (*inject_pending_irq)(struct kvm_vcpu *vcpu, struct kvm_run *run);
>>   
>
> kvm_run is available as vcpu->run, so this isn't needed.  But better to  
> keep it for now and drop it in a later patch.
>
>>  static int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr)
>>  {
>>  	int ret;
>> @@ -3351,8 +3309,11 @@ static void vmx_complete_interrupts(struct vcpu_vmx *vmx)
>>  	}
>>  }
>>  -static void vmx_intr_assist(struct kvm_vcpu *vcpu)
>> +static void vmx_intr_assist(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
>>  {
>> +	bool req_int_win = !irqchip_in_kernel(vcpu->kvm) &&
>> +		kvm_run->request_interrupt_window;
>> +
>>  	update_tpr_threshold(vcpu);
>>   	vmx_update_window_states(vcpu);
>> @@ -3373,25 +3334,25 @@ static void vmx_intr_assist(struct kvm_vcpu *vcpu)
>>  			return;
>>  		}
>>  	}
>>   
>
> Why not convert the 'enable_nmi_window(); return;' above to a 'goto out'  
> like you do elsewhere?
>
>
Mainly because of the next patch in the series that reworks this code
anyway.

--
			Gleb.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-04-11 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-07  9:08 [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Gleb Natapov
2009-04-07  9:08 ` [PATCH 2/3] Consolidate userspace and kernel interrupt injection for VMX Gleb Natapov
2009-04-11 11:29   ` Avi Kivity
2009-04-11 19:53     ` Gleb Natapov
2009-04-07  9:08 ` [PATCH 3/3] Cleanup vmx_intr_assist() Gleb Natapov
2009-04-11 11:30   ` Avi Kivity
2009-04-11 19:52     ` Gleb Natapov
2009-04-07  9:56 ` [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too Sheng Yang
2009-04-07 10:07   ` Gleb Natapov
2009-04-11 11:24     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).