From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 1/3] Make kvm_cpu_(has|get)_interrupt() work for userspace irqchip too. Date: Tue, 7 Apr 2009 13:07:08 +0300 Message-ID: <20090407100708.GA25543@redhat.com> References: <20090407090811.2074.19043.stgit@trex.usersys.redhat.com> <200904071756.13864.sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, avi@redhat.com To: Sheng Yang Return-path: Received: from mx2.redhat.com ([66.187.237.31]:55531 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbZDGKHM (ORCPT ); Tue, 7 Apr 2009 06:07:12 -0400 Content-Disposition: inline In-Reply-To: <200904071756.13864.sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: > > * 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.