From: Hongyong Zang <zanghongyong@xxxxxxxxxx> The new memory API, named kvm_set_ioeventfd_pio_long, is about ioeventfd for PIO long. Signed-off-by: Hongyong Zang <zanghongyong@xxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html