From patchwork Tue Jul 27 00:10:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cam Macdonell X-Patchwork-Id: 59960 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0E892B70B7 for ; Tue, 27 Jul 2010 10:13:00 +1000 (EST) Received: from localhost ([127.0.0.1]:45631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdXmy-0003Qm-GM for incoming@patchwork.ozlabs.org; Mon, 26 Jul 2010 20:12:56 -0400 Received: from [140.186.70.92] (port=42931 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdXlT-0003PN-Ew for qemu-devel@nongnu.org; Mon, 26 Jul 2010 20:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdXlS-0006mN-B2 for qemu-devel@nongnu.org; Mon, 26 Jul 2010 20:11:23 -0400 Received: from fleet.cs.ualberta.ca ([129.128.22.22]:33340) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdXlS-0006kv-7G for qemu-devel@nongnu.org; Mon, 26 Jul 2010 20:11:22 -0400 Received: from localhost.localdomain (st-brides.cs.ualberta.ca [129.128.23.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.cs.ualberta.ca (Postfix) with ESMTP id 25F882801A; Mon, 26 Jul 2010 18:11:09 -0600 (MDT) From: Cam Macdonell To: qemu-devel@nongnu.org Date: Mon, 26 Jul 2010 18:10:59 -0600 Message-Id: <1280189461-1929-4-git-send-email-cam@cs.ualberta.ca> X-Mailer: git-send-email 1.6.3.2.198.g6096d In-Reply-To: <1280189461-1929-3-git-send-email-cam@cs.ualberta.ca> References: <1280189461-1929-1-git-send-email-cam@cs.ualberta.ca> <1280189461-1929-2-git-send-email-cam@cs.ualberta.ca> <1280189461-1929-3-git-send-email-cam@cs.ualberta.ca> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Cam Macdonell , kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH v8 3/5] Add function to assign ioeventfd to MMIO. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Cam Macdonell --- kvm-all.c | 32 ++++++++++++++++++++++++++++++++ kvm.h | 1 + 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 7635f2f..d9a5dd0 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1241,6 +1241,38 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset) return r; } +int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool assign) +{ +#ifdef KVM_IOEVENTFD + int ret; + struct kvm_ioeventfd iofd; + + iofd.datamatch = val; + iofd.addr = addr; + iofd.len = 4; + iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH; + iofd.fd = fd; + + if (!kvm_enabled()) { + return -ENOSYS; + } + + if (!assign) { + iofd.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN; + } + + ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &iofd); + + if (ret < 0) { + return -errno; + } + + return 0; +#else + return -ENOSYS; +#endif +} + int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) { #ifdef KVM_IOEVENTFD diff --git a/kvm.h b/kvm.h index 93f8187..50b6c01 100644 --- a/kvm.h +++ b/kvm.h @@ -175,6 +175,7 @@ static inline void cpu_synchronize_post_init(CPUState *env) } #endif +int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign); int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); #endif