From patchwork Tue Dec 13 01:42:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zanghongyong@huawei.com X-Patchwork-Id: 130972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B0E711007D3 for ; Tue, 13 Dec 2011 13:40:00 +1100 (EST) Received: from localhost ([::1]:35854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaIHd-0000GR-6F for incoming@patchwork.ozlabs.org; Mon, 12 Dec 2011 21:39:57 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaIHC-0007YY-3K for qemu-devel@nongnu.org; Mon, 12 Dec 2011 21:39:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaIHA-0000na-GX for qemu-devel@nongnu.org; Mon, 12 Dec 2011 21:39:29 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:49920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaIHA-0000l4-2q for qemu-devel@nongnu.org; Mon, 12 Dec 2011 21:39:28 -0500 Received: from huawei.com (szxga05-in [172.24.2.49]) by szxga05-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LW400DFMFB96H@szxga05-in.huawei.com> for qemu-devel@nongnu.org; Tue, 13 Dec 2011 10:37:57 +0800 (CST) Received: from szxrg01-dlp.huawei.com ([172.24.2.119]) by szxga05-in.huawei.com (iPlanet Messaging Server 5.2 HotFix 2.14 (built Aug 8 2006)) with ESMTP id <0LW400570FB713@szxga05-in.huawei.com> for qemu-devel@nongnu.org; Tue, 13 Dec 2011 10:37:57 +0800 (CST) Received: from szxeml207-edg.china.huawei.com ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.1.9-GA) with ESMTP id AFU23726; Tue, 13 Dec 2011 10:37:54 +0800 Received: from SZXEML404-HUB.china.huawei.com (10.82.67.59) by szxeml207-edg.china.huawei.com (172.24.2.59) with Microsoft SMTP Server (TLS) id 14.1.323.3; Tue, 13 Dec 2011 10:37:52 +0800 Received: from localhost.localdomain (10.166.29.45) by szxeml404-hub.china.huawei.com (10.82.67.59) with Microsoft SMTP Server id 14.1.323.3; Tue, 13 Dec 2011 10:37:43 +0800 Date: Tue, 13 Dec 2011 09:42:46 +0800 From: zanghongyong@huawei.com In-reply-to: <1323740568-17692-1-git-send-email-zanghongyong@huawei.com> X-Originating-IP: [10.166.29.45] To: qemu-devel@nongnu.org, kvm@vger.kernel.org Message-id: <1323740568-17692-2-git-send-email-zanghongyong@huawei.com> MIME-version: 1.0 X-Mailer: git-send-email 1.7.0.4 Content-type: text/plain Content-transfer-encoding: 7BIT X-CFilter-Loop: Reflected References: <1323740568-17692-1-git-send-email-zanghongyong@huawei.com> X-detected-operating-system: by eggs.gnu.org: Solaris 9 X-Received-From: 119.145.14.64 Cc: wusongwei@huawei.com, hanweidong@huawei.com, louzhengwei@huawei.com, xiaowei.yang@huawei.com, zanghongyong@huawei.com, avi@redhat.com, cam@cs.ualberta.ca Subject: [Qemu-devel] [PATCH v3 1/3] memory: add a memory API about ioeventfd for PIO long 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 From: Hongyong Zang The new memory API, named kvm_set_ioeventfd_pio_long, is about ioeventfd for PIO long. Signed-off-by: Hongyong Zang --- kvm-all.c | 23 +++++++++++++++++++++++ kvm-stub.c | 5 +++++ kvm.h | 1 + memory.c | 20 ++++++++++++++++---- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 4c466d6..4614c5d 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1365,6 +1365,29 @@ int kvm_set_ioeventfd_mmio_long(int fd, uint32_t addr, uint32_t val, bool assign return 0; } +int kvm_set_ioeventfd_pio_long(int fd, uint32_t addr, uint32_t val, bool assign) +{ + struct kvm_ioeventfd kick = { + .datamatch = val, + .addr = addr, + .len = 4, + .flags = KVM_IOEVENTFD_FLAG_DATAMATCH | KVM_IOEVENTFD_FLAG_PIO, + .fd = fd, + }; + int r; + if (!kvm_enabled()) { + return -ENOSYS; + } + if (!assign) { + kick.flags |= KVM_IOEVENTFD_FLAG_DEASSIGN; + } + r = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick); + if (r < 0) { + return r; + } + return 0; +} + int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) { struct kvm_ioeventfd kick = { diff --git a/kvm-stub.c b/kvm-stub.c index 06064b9..64cdd7c 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -115,6 +115,11 @@ int kvm_set_ioeventfd_pio_word(int fd, uint16_t addr, uint16_t val, bool assign) return -ENOSYS; } +int kvm_set_ioeventfd_pio_long(int fd, uint32_t adr, uint32_t val, bool assign) +{ + return -ENOSYS; +} + int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign) { return -ENOSYS; diff --git a/kvm.h b/kvm.h index 243b063..64b1737 100644 --- a/kvm.h +++ b/kvm.h @@ -195,5 +195,6 @@ int kvm_physical_memory_addr_from_ram(KVMState *s, ram_addr_t ram_addr, #endif int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign); +int kvm_set_ioeventfd_pio_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 diff --git a/memory.c b/memory.c index adfdf14..544c955 100644 --- a/memory.c +++ b/memory.c @@ -480,10 +480,16 @@ static void as_io_ioeventfd_add(AddressSpace *as, MemoryRegionIoeventfd *fd) { int r; - assert(fd->match_data && int128_get64(fd->addr.size) == 2); - - r = kvm_set_ioeventfd_pio_word(fd->fd, int128_get64(fd->addr.start), + assert(fd->match_data && (int128_get64(fd->addr.size) == 2 || + int128_get64(fd->addr.size) == 4)); + if(int128_get64(fd->addr.size) == 2) { + r = kvm_set_ioeventfd_pio_word(fd->fd, int128_get64(fd->addr.start), + fd->data, true); + } + else { + r = kvm_set_ioeventfd_pio_long(fd->fd, int128_get64(fd->addr.start), fd->data, true); + } if (r < 0) { abort(); } @@ -493,8 +499,14 @@ static void as_io_ioeventfd_del(AddressSpace *as, MemoryRegionIoeventfd *fd) { int r; - r = kvm_set_ioeventfd_pio_word(fd->fd, int128_get64(fd->addr.start), + if(int128_get64(fd->addr.size) == 2) { + r = kvm_set_ioeventfd_pio_word(fd->fd, int128_get64(fd->addr.start), fd->data, false); + } + else { + r = kvm_set_ioeventfd_pio_long(fd->fd, int128_get64(fd->addr.start), + fd->data, false); + } if (r < 0) { abort(); }