From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [RFC][PATCH] KVM: Introduce direct MSI message injection for in-kernel irqchips Date: Fri, 21 Oct 2011 11:42:13 +0200 Message-ID: <1319190133.31522.28.camel@lappy> References: <4EA13917.7070401@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , kvm , "Michael S. Tsirkin" To: Jan Kiszka Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:40094 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754018Ab1JUJmV (ORCPT ); Fri, 21 Oct 2011 05:42:21 -0400 Received: by wyg36 with SMTP id 36so3767349wyg.19 for ; Fri, 21 Oct 2011 02:42:20 -0700 (PDT) In-Reply-To: <4EA13917.7070401@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 2011-10-21 at 11:19 +0200, Jan Kiszka wrote: > Currently, MSI messages can only be injected to in-kernel irqchips by > defining a corresponding IRQ route for each message. This is not only > unhandy if the MSI messages are generated "on the fly" by user space, > IRQ routes are a limited resource that user space as to manage > carefully. > > By providing a direct injection with, we can both avoid using up limited > resources and simplify the necessary steps for user land. The API > already provides a channel (flags) to revoke an injected but not yet > delivered message which will become important for in-kernel MSI-X vector > masking support. > > Signed-off-by: Jan Kiszka > --- > Documentation/virtual/kvm/api.txt | 23 +++++++++++++++++++++++ > include/linux/kvm.h | 15 +++++++++++++++ > virt/kvm/kvm_main.c | 18 ++++++++++++++++++ > 3 files changed, 56 insertions(+), 0 deletions(-) > > diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt > index 7945b0b..f4c3de3 100644 > --- a/Documentation/virtual/kvm/api.txt > +++ b/Documentation/virtual/kvm/api.txt > @@ -1383,6 +1383,29 @@ The following flags are defined: > If datamatch flag is set, the event will be signaled only if the written value > to the registered address is equal to datamatch in struct kvm_ioeventfd. > > +4.59 KVM_SET_MSI > + > +Capability: KVM_CAP_SET_MSI > +Architectures: x86 ia64 > +Type: vm ioctl > +Parameters: struct kvm_msi (in) > +Returns: 0 on success, -1 on error > + > +Directly inject a MSI message. Only valid with in-kernel irqchip that handles > +MSI messages. > + > +struct kvm_msi { > + __u32 address_lo; > + __u32 address_hi; > + __u32 data; > + __u32 flags; > + __u8 pad[16]; > +}; > + > +The following flags are defined: > + > +#define KVM_MSI_FLAG_RAISE (1 << 0) > + > 4.62 KVM_CREATE_SPAPR_TCE > > Capability: KVM_CAP_SPAPR_TCE > diff --git a/include/linux/kvm.h b/include/linux/kvm.h > index 6884054..83875ed 100644 > --- a/include/linux/kvm.h > +++ b/include/linux/kvm.h > @@ -557,6 +557,9 @@ struct kvm_ppc_pvinfo { > #define KVM_CAP_PPC_HIOR 67 > #define KVM_CAP_PPC_PAPR 68 > #define KVM_CAP_S390_GMAP 71 > +#ifdef __KVM_HAVE_MSI > +#define KVM_CAP_SET_MSI 72 > +#endif > > #ifdef KVM_CAP_IRQ_ROUTING > > @@ -636,6 +639,16 @@ struct kvm_clock_data { > __u32 pad[9]; > }; > > +#define KVM_MSI_FLAG_RAISE (1 << 0) > + > +struct kvm_msi { > + __u32 address_lo; > + __u32 address_hi; > + __u32 data; > + __u32 flags; > + __u8 pad[16]; > +}; > + How about defining it as: struct kvm_msi { struct msi_msg msi; __u32 flags; __u8 pad[16]; }; It would allow keeping everything in a msi_msg all the way from userspace up to kvm_set_msi() -- Sasha.