From patchwork Tue Mar 20 12:31:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 147788 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93BBCB6ED0 for ; Tue, 20 Mar 2012 23:32:04 +1100 (EST) Received: from localhost ([::1]:36203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9yEL-0004eM-EX for incoming@patchwork.ozlabs.org; Tue, 20 Mar 2012 08:32:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9yEC-0004e8-Vi for qemu-devel@nongnu.org; Tue, 20 Mar 2012 08:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9yDm-0006dw-2H for qemu-devel@nongnu.org; Tue, 20 Mar 2012 08:31:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9yDl-0006cz-Q6 for qemu-devel@nongnu.org; Tue, 20 Mar 2012 08:31:25 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2KCVNde024262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Mar 2012 08:31:23 -0400 Received: from redhat.com (dhcp-4-60.tlv.redhat.com [10.35.4.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id q2KCVJf8007480; Tue, 20 Mar 2012 08:31:20 -0400 Date: Tue, 20 Mar 2012 14:31:38 +0200 From: "Michael S. Tsirkin" To: Avi Kivity , Marcelo Tosatti , Anthony Liguori , Richard Henderson , Isaku Yamahata , Jan Kiszka , qemu-devel@nongnu.org Message-ID: <20120320123137.GA29666@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] kvm: allow arbitrarily sized mmio ioeventfd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We use a 2 byte ioeventfd for virtio memory, add support for this. Signed-off-by: Michael S. Tsirkin Reviewed-by: Amos Kong --- hw/ivshmem.c | 8 ++++---- kvm-all.c | 15 ++++++++------- kvm-stub.c | 2 +- kvm.h | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/hw/ivshmem.c b/hw/ivshmem.c index 5ebf840..f02530c 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -354,8 +354,8 @@ static void close_guest_eventfds(IVShmemState *s, int posn) guest_curr_max = s->peers[posn].nb_eventfds; for (i = 0; i < guest_curr_max; i++) { - kvm_set_ioeventfd_mmio_long(s->peers[posn].eventfds[i], - s->mmio_addr + DOORBELL, (posn << 16) | i, 0); + kvm_set_ioeventfd_mmio(s->peers[posn].eventfds[i], + s->mmio_addr + DOORBELL, (posn << 16) | i, 0, 4); close(s->peers[posn].eventfds[i]); } @@ -500,8 +500,8 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) } if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { - if (kvm_set_ioeventfd_mmio_long(incoming_fd, s->mmio_addr + DOORBELL, - (incoming_posn << 16) | guest_max_eventfd, 1) < 0) { + if (kvm_set_ioeventfd_mmio(incoming_fd, s->mmio_addr + DOORBELL, + (incoming_posn << 16) | guest_max_eventfd, 1, 4) < 0) { fprintf(stderr, "ivshmem: ioeventfd not available\n"); } } diff --git a/kvm-all.c b/kvm-all.c index 42e5e23..bcf0dbe 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -744,10 +744,10 @@ static void kvm_mem_ioeventfd_add(MemoryRegionSection *section, { int r; - assert(match_data && section->size == 4); + assert(match_data && section->size <= 8); - r = kvm_set_ioeventfd_mmio_long(fd, section->offset_within_address_space, - data, true); + r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space, + data, true, section->size); if (r < 0) { abort(); } @@ -758,8 +758,8 @@ static void kvm_mem_ioeventfd_del(MemoryRegionSection *section, { int r; - r = kvm_set_ioeventfd_mmio_long(fd, section->offset_within_address_space, - data, false); + r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space, + data, false, section->size); if (r < 0) { abort(); } @@ -1639,14 +1639,15 @@ int kvm_set_signal_mask(CPUArchState *env, const sigset_t *sigset) return r; } -int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool assign) +int kvm_set_ioeventfd_mmio(int fd, uint32_t addr, uint32_t val, bool assign, + uint32_t size) { int ret; struct kvm_ioeventfd iofd; iofd.datamatch = val; iofd.addr = addr; - iofd.len = 4; + iofd.len = size; iofd.flags = KVM_IOEVENTFD_FLAG_DATAMATCH; iofd.fd = fd; diff --git a/kvm-stub.c b/kvm-stub.c index 69a1228..0d426db 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -120,7 +120,7 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) return -ENOSYS; } -int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign) +int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, uint32_t len) { return -ENOSYS; } diff --git a/kvm.h b/kvm.h index 330f17b..9bdbdb0 100644 --- a/kvm.h +++ b/kvm.h @@ -210,7 +210,8 @@ int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr, #endif #endif -int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign); +int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, + uint32_t size); int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); #endif