[PATCH 1/5] ioeventfd: Remove natural sized length limitation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch removes the 8 byte length limit on ioeventfds.

The consequences are that any write in the provided region
which is contained entierly by the region and matches datamatch
(if specified) will trigger an event.

Cc: Avi Kivity <avi@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
Cc: Michael S. Tsirkin <mst@xxxxxxxxxx>
Cc: Pekka Enberg <penberg@xxxxxxxxxx>
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 Documentation/virtual/kvm/api.txt |    4 ++--
 include/linux/kvm.h               |    4 ++--
 virt/kvm/eventfd.c                |   15 ++-------------
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index b251136..7994840 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -1334,8 +1334,8 @@ provided event instead of triggering an exit.
 
 struct kvm_ioeventfd {
 	__u64 datamatch;
-	__u64 addr;        /* legal pio/mmio address */
-	__u32 len;         /* 1, 2, 4, or 8 bytes    */
+	__u64 addr;
+	__u32 len;
 	__s32 fd;
 	__u32 flags;
 	__u8  pad[36];
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 9c9ca7c..81cd295 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -398,8 +398,8 @@ enum {
 
 struct kvm_ioeventfd {
 	__u64 datamatch;
-	__u64 addr;        /* legal pio/mmio address */
-	__u32 len;         /* 1, 2, 4, or 8 bytes    */
+	__u64 addr;
+	__u32 len;
 	__s32 fd;
 	__u32 flags;
 	__u8  pad[36];
diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index 73358d2..5fb09b4 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -449,8 +449,8 @@ ioeventfd_in_range(struct _ioeventfd *p, gpa_t addr, int len, const void *val)
 {
 	u64 _val;
 
-	if (!(addr == p->addr && len == p->length))
-		/* address-range must be precise for a hit */
+	if (!((addr >= p->addr) && ((addr + len) <= (p->addr + p->length))))
+		/* the entire address-range must be within the ioeventfd */
 		return false;
 
 	if (p->wildcard)
@@ -536,17 +536,6 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
 	struct eventfd_ctx       *eventfd;
 	int                       ret;
 
-	/* must be natural-word sized */
-	switch (args->len) {
-	case 1:
-	case 2:
-	case 4:
-	case 8:
-		break;
-	default:
-		return -EINVAL;
-	}
-
 	/* check for range overflow */
 	if (args->addr + args->len < args->addr)
 		return -EINVAL;
-- 
1.7.6

--
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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux