From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [RFC][PATCH 0/2] Fix guest shared interrupt with in-kernel irqchip Date: Thu, 02 Oct 2008 16:27:18 +0300 Message-ID: <48E4CC36.70607@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "'kvm@vger.kernel.org'" To: "Yang, Sheng" Return-path: Received: from mx2.redhat.com ([66.187.237.31]:41049 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650AbYJBN10 (ORCPT ); Thu, 2 Oct 2008 09:27:26 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Yang, Sheng wrote: > To deal with guest shared interrupt bug in in-kernel irqchip, we should: > > 1. Identify each level trig interrupt source. > 2. Implement logical OR on the same IRQ line for each interrupt source. > > Here I chose a simple method: the caller of kvm_set_irq() has responsiblity > to identify interrupt sources, and IOAPIC/PIC ensure logical OR on IRQ line. > The downside is that every caller has to do this edge detection. How about allocating a vector of u32s (one per irq), and each source will allocate a bit within this vector. The 'or' operation becomes (word != 0). For example: irq_src = kvm_irq_allocate_source(kvm); /* allocate bit within irq vector */ ... kvm_set_irq(kvm, irq, 1, irq_src); kvm_set_irq(...) { // locking? if (level) set_bit(irq_src, &kvm->irq_state[irq]); else clear_bit(irq_src, &kvm->irq_state[irq]); kvm_pic_set_irq(kvm, irq, !!kvm->irq_state[irq]); kvm_ioapic_set_irq(kvm, irq, !!kvm->irq_state[irq]); } kvm_irq_allocate_source(kvm) { irq_src = find_first_clear_bit(kvm->irq_sources); set_bit(irq_src, &kvm->irq_sources); return irq_src; } This also keeps the pic and ioapic out of the picture, which is good. It also allows us to implement negative polarity easily in the future. -- error compiling committee.c: too many arguments to function