From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 01/10] KVM: Add a route layer to convert MSI message to GSI Date: Tue, 30 Dec 2008 12:39:47 +0200 Message-ID: <4959FA73.1090303@redhat.com> References: <1230616562-18113-1-git-send-email-sheng@linux.intel.com> <1230616562-18113-2-git-send-email-sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Sheng Yang Return-path: Received: from mx2.redhat.com ([66.187.237.31]:43730 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbYL3Kjw (ORCPT ); Tue, 30 Dec 2008 05:39:52 -0500 In-Reply-To: <1230616562-18113-2-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: Sheng Yang wrote: > Avi's purpose, to use single kvm_set_irq() to deal with all interrupt, including > MSI. So here is it. > > struct gsi_msg is a mapping from a special gsi(with KVM_GSI_MSG_MASK) to > MSI/MSI-X message address/data. > > Now we support up to 256 gsi_msg mapping, and gsi_msg is allocated by kernel and > provide two ioctls to userspace, which is more flexiable. > > > +#define KVM_REQUEST_GSI_MSG _IOWR(KVMIO, 0x71, struct kvm_assigned_gsi_msg) > +#define KVM_FREE_GSI_MSG _IOR(KVMIO, 0x72, struct kvm_assigned_gsi_msg) > We will also need a pair for PIC and a pair for IOAPIC routing. How about a single ioctl to set the entire routing table? It would take an array of structures: struct { __u32 gsi; __u32 type; __u32 flags; __u32 reserved; union { struct { __u32 irq; } pic; struct { __u32 ioapic; // can have >1 ioapic __u32 inti; } ioapic; struct { ... } msi; __u32 reserved[8]; }; }; This way we can solve the HPET irq0/inti2 mess, and also have a simpler way of setting MSI. All the mess in one ioctl. > + > +/* Call with kvm->gsi_msg_lock hold */ > +struct kvm_gsi_msg *kvm_find_gsi_msg(struct kvm *kvm, u32 gsi) > +{ > + struct kvm_gsi_msg *gsi_msg; > + struct hlist_node *n; > + > + if (!(gsi & KVM_GSI_MSG_MASK)) > + return NULL; > + hlist_for_each_entry(gsi_msg, n, &kvm->gsi_msg_list, link) > + if (gsi_msg->gsi == gsi) > + goto out; > + gsi_msg = NULL; > +out: > + return gsi_msg; > +} > Linear search is a bit sad but fine for now. Later we can add an array indexed by gsi. -- error compiling committee.c: too many arguments to function