From patchwork Fri Oct 29 17:12:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 290792 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9THCrnV025581 for ; Fri, 29 Oct 2010 17:12:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932771Ab0J2RMu (ORCPT ); Fri, 29 Oct 2010 13:12:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20118 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932342Ab0J2RMu (ORCPT ); Fri, 29 Oct 2010 13:12:50 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9THCoIw015129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 29 Oct 2010 13:12:50 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9THCnnW032211; Fri, 29 Oct 2010 13:12:49 -0400 From: Alex Williamson Subject: [PATCH] kvm: Add suport for KVM_EOI_EVENTFD To: kvm@vger.kernel.org, avi@redhat.com Cc: alex.williamson@redhat.com, mst@redhat.com, chrisw@redhat.com, ddutile@redhat.com Date: Fri, 29 Oct 2010 11:12:49 -0600 Message-ID: <20101029171113.8956.19058.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Oct 2010 17:12:54 +0000 (UTC) diff --git a/kvm-all.c b/kvm-all.c index 0e60748..75dbe76 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1349,5 +1349,24 @@ int kvm_set_irqfd(int gsi, int fd, bool assigned) } #endif +#if defined(KVM_EOI_EVENTFD) +int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags) +{ + struct kvm_eoi eoi = { + .fd = fd, + .gsi = gsi, + .flags = flags, + }; + int r; + + if (!kvm_enabled() || !kvm_irqchip_in_kernel()) + return -ENOSYS; + + r = kvm_vm_ioctl(kvm_state, KVM_EOI_EVENTFD, &eoi); + if (r < 0) + return r; + return 0; +} +#endif #undef PAGE_SIZE #include "qemu-kvm.c" diff --git a/kvm.h b/kvm.h index 02280a6..777904a 100644 --- a/kvm.h +++ b/kvm.h @@ -203,6 +203,16 @@ int kvm_set_irqfd(int gsi, int fd, bool assigned) } #endif +#if defined(KVM_EOI_EVENTFD) && defined(CONFIG_KVM) +int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags); +#else +static inline +int kvm_eoi_eventfd(int gsi, int fd, uint32_t flags) +{ + return -ENOSYS; +} +#endif + int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); int kvm_has_gsi_routing(void); diff --git a/kvm/include/linux/kvm.h b/kvm/include/linux/kvm.h index e46729e..5490f62 100644 --- a/kvm/include/linux/kvm.h +++ b/kvm/include/linux/kvm.h @@ -530,6 +530,7 @@ struct kvm_enable_cap { #ifdef __KVM_HAVE_XCRS #define KVM_CAP_XCRS 56 #endif +#define KVM_CAP_EOI_EVENTFD 60 #ifdef KVM_CAP_IRQ_ROUTING @@ -609,6 +610,16 @@ struct kvm_clock_data { __u32 pad[9]; }; +#define KVM_EOI_EVENTFD_FLAG_DEASSIGN (1 << 0) +#define KVM_EOI_EVENTFD_FLAG_DEASSERT (1 << 1) + +struct kvm_eoi { + __u32 fd; + __u32 gsi; + __u32 flags; + __u8 pad[20]; +}; + /* * ioctls for VM fds */ @@ -663,6 +674,8 @@ struct kvm_clock_data { /* Available with KVM_CAP_PIT_STATE2 */ #define KVM_GET_PIT2 _IOR(KVMIO, 0x9f, struct kvm_pit_state2) #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) +/* Available with KVM_CAP_EOI_EVENTFD */ +#define KVM_EOI_EVENTFD _IOW(KVMIO, 0xa2, struct kvm_eoi) /* * ioctls for vcpu fds