From: zanghongyong@huawei.com
To: qemu-devel@nongnu.org, kvm@vger.kernel.org
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
Date: Tue, 13 Dec 2011 09:42:46 +0800 [thread overview]
Message-ID: <1323740568-17692-2-git-send-email-zanghongyong@huawei.com> (raw)
In-Reply-To: <1323740568-17692-1-git-send-email-zanghongyong@huawei.com>
From: Hongyong Zang <zanghongyong@huawei.com>
The new memory API, named kvm_set_ioeventfd_pio_long, is about ioeventfd for PIO long.
Signed-off-by: Hongyong Zang <zanghongyong@huawei.com>
---
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();
}
--
1.7.1
next prev parent reply other threads:[~2011-12-13 2:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-13 1:42 [Qemu-devel] [PATCH v3 0/3] ivshmem: add a new PIO BAR4(Doorbell) besides MMIO BAR0 to reduce notification time zanghongyong
2011-12-13 1:42 ` zanghongyong [this message]
2011-12-13 1:42 ` [Qemu-devel] [PATCH v3 2/3] ivshmem: add a new PIO BAR4(Doorbell) " zanghongyong
2011-12-13 1:42 ` [Qemu-devel] [PATCH v3 3/3] ivshmem: update the spec zanghongyong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1323740568-17692-2-git-send-email-zanghongyong@huawei.com \
--to=zanghongyong@huawei.com \
--cc=avi@redhat.com \
--cc=cam@cs.ualberta.ca \
--cc=hanweidong@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=louzhengwei@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=wusongwei@huawei.com \
--cc=xiaowei.yang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).