Skip to contentSkip to conversation

PATCH Michael S. Tsirkin 1 participant 1 message Jun 25, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

[email protected]
Subject: [PATCH] kvm: pass value to in_range callback Reply-To:

For write transactions, pass the value written to in_range checks so that we can make each iosignalfd a separate device on kvm bus.

---

Avi, can you please merge this patch in kvm.git so that Gregory can use it for iosignalfd? Once bus has RCU we'll be able to remove in_range completely, but let's do it step by step.

 arch/ia64/kvm/kvm-ia64.c  |    9 ++++--
 arch/x86/kvm/i8254.c      |    2 +-
 arch/x86/kvm/lapic.c      |    2 +-
 arch/x86/kvm/x86.c        |   60 +++++++++++++++++++++++++-------------------
 include/linux/kvm_host.h  |    3 +-
 virt/kvm/coalesced_mmio.c |    3 +-
 virt/kvm/ioapic.c         |    3 +-
 virt/kvm/iodev.h          |    9 +++---
 virt/kvm/kvm_main.c       |    5 ++-
 9 files changed, 56 insertions(+), 40 deletions(-)
arch/ia64/kvm/kvm-ia64.c +6 -3
index c1c5cb6..68058c2 100644
@@ -211,11 +211,13 @@ int kvm_dev_ioctl_check_extension(long ext)
 }
 
 static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
-					gpa_t addr, int len, int is_write)
+					gpa_t addr, int len, int is_write,
+					void *write_val)
 {
 	struct kvm_io_device *dev;
 
-	dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr, len, is_write);
+	dev = kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr, len, is_write,
+	                          write_val);
 
 	return dev;
 }
@@ -247,7 +249,8 @@ static int handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	kvm_run->exit_reason = KVM_EXIT_MMIO;
 	return 0;
 mmio:
-	mmio_dev = vcpu_find_mmio_dev(vcpu, p->addr, p->size, !p->dir);
+	mmio_dev = vcpu_find_mmio_dev(vcpu, p->addr, p->size,
+				      !p->dir, &p->data);
 	if (mmio_dev) {
 		if (!p->dir)
 			kvm_iodevice_write(mmio_dev, p->addr, p->size,
arch/x86/kvm/i8254.c +1 -1
index 331705f..6f84cb2 100644
@@ -495,7 +495,7 @@ static void pit_ioport_read(struct kvm_io_device *this,
 }
 
 static int pit_in_range(struct kvm_io_device *this, gpa_t addr,
-			int len, int is_write)
+			int len, int is_write, void *write_val)
 {
 	return ((addr >= KVM_PIT_BASE_ADDRESS) &&
 		(addr < KVM_PIT_BASE_ADDRESS + KVM_PIT_MEM_LENGTH));
arch/x86/kvm/lapic.c +1 -1
index 2e02865..3d08b1d 100644
@@ -747,7 +747,7 @@ static void apic_mmio_write(struct kvm_io_device *this,
 }
 
 static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr,
-			   int len, int size)
+			   int len, int is_write, void *write_val)
 {
 	struct kvm_lapic *apic = to_lapic(this);
 	int ret = 0;
arch/x86/kvm/x86.c +34 -26

126 lines not on this page · raw message

include/linux/kvm_host.h +2 -1
index 2451f48..7b2bd9b 100644
@@ -60,7 +60,8 @@ struct kvm_io_bus {
 void kvm_io_bus_init(struct kvm_io_bus *bus);
 void kvm_io_bus_destroy(struct kvm_io_bus *bus);
 struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus,
-					  gpa_t addr, int len, int is_write);
+					  gpa_t addr, int len, int is_write,
+					  void *write_val);
 void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
 			     struct kvm_io_device *dev);
 
virt/kvm/coalesced_mmio.c +2 -1
index 397f419..9561bc2 100644
@@ -20,7 +20,8 @@ static inline struct kvm_coalesced_mmio_dev *to_mmio(struct kvm_io_device *dev)
 }
 
 static int coalesced_mmio_in_range(struct kvm_io_device *this,
-				   gpa_t addr, int len, int is_write)
+				   gpa_t addr, int len, int is_write,
+				   void *write_val)
 {
 	struct kvm_coalesced_mmio_dev *dev = to_mmio(this);
 	struct kvm_coalesced_mmio_zone *zone;
virt/kvm/ioapic.c +2 -1
index d8b2eca..fa3f4fb 100644
@@ -228,7 +228,8 @@ static inline struct kvm_ioapic *to_ioapic(struct kvm_io_device *dev)
 }
 
 static int ioapic_in_range(struct kvm_io_device *this, gpa_t addr,
-			   int len, int is_write)
+			   int len, int is_write,
+			   void *write_val)
 {
 	struct kvm_ioapic *ioapic = to_ioapic(this);
 
virt/kvm/iodev.h +5 -4
index 2c67f5a..d8cf9e2 100644
@@ -30,7 +30,7 @@ struct kvm_io_device_ops {
 		      int len,
 		      const void *val);
 	int (*in_range)(struct kvm_io_device *this, gpa_t addr, int len,
-			int is_write);
+			int is_write, void *write_val);
 	void (*destructor)(struct kvm_io_device *this);
 };
 
@@ -61,10 +61,11 @@ static inline void kvm_iodevice_write(struct kvm_io_device *dev,
 	dev->ops->write(dev, addr, len, val);
 }
 
-static inline int kvm_iodevice_in_range(struct kvm_io_device *dev,
-					gpa_t addr, int len, int is_write)
+static inline int kvm_iodevice_inrange(struct kvm_io_device *dev,
+				       gpa_t addr, int len, int is_write,
+				       void *write_val)
 {
-	return dev->ops->in_range(dev, addr, len, is_write);
+	return dev->ops->in_range(dev, addr, len, is_write, write_val);
 }
 
 static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
virt/kvm/kvm_main.c +3 -2
index 58d6bc6..f5dfe02 100644
@@ -2485,14 +2485,15 @@ void kvm_io_bus_destroy(struct kvm_io_bus *bus)
 }
 
 struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus,
-					  gpa_t addr, int len, int is_write)
+					  gpa_t addr, int len, int is_write,
+					  void *write_val)
 {
 	int i;
 
 	for (i = 0; i < bus->dev_count; i++) {
 		struct kvm_io_device *pos = bus->devs[i];
 
-		if (kvm_iodevice_in_range(pos, addr, len, is_write))
+		if (kvm_iodevice_in_range(pos, addr, len, is_write, write_val))
 			return pos;
 	}
 
Signature · 1 line
1.6.2.2