* [PATCH v4 0/2] KVM: ioeventfd cookies
@ 2013-07-03 14:30 Cornelia Huck
2013-07-03 14:30 ` [PATCH v4 1/2] KVM: kvm-io: support cookies Cornelia Huck
2013-07-03 14:30 ` [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd Cornelia Huck
0 siblings, 2 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-07-03 14:30 UTC (permalink / raw)
To: Gleb Natapov, Paolo Bonzini
Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky, KVM,
linux-s390
Hi,
fourth version of this patch set.
Changes:
- make the cookie-less read/write function return 0 again on success and
drop the changes at the callsites
Cornelia Huck (2):
KVM: kvm-io: support cookies
KVM: s390: use cookies for ioeventfd
arch/s390/kvm/diag.c | 15 +++++--
include/linux/kvm_host.h | 4 ++
virt/kvm/kvm_main.c | 106 ++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 107 insertions(+), 18 deletions(-)
--
1.8.2.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v4 1/2] KVM: kvm-io: support cookies
2013-07-03 14:30 [PATCH v4 0/2] KVM: ioeventfd cookies Cornelia Huck
@ 2013-07-03 14:30 ` Cornelia Huck
2013-07-03 15:05 ` Gleb Natapov
2013-07-03 14:30 ` [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd Cornelia Huck
1 sibling, 1 reply; 11+ messages in thread
From: Cornelia Huck @ 2013-07-03 14:30 UTC (permalink / raw)
To: Gleb Natapov, Paolo Bonzini
Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky, KVM,
linux-s390
Add new functions kvm_io_bus_{read,write}_cookie() that allows users of
the kvm io infrastructure to use a cookie value to speed up lookup of a
device on an io bus.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
include/linux/kvm_host.h | 4 ++
virt/kvm/kvm_main.c | 106 ++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 95 insertions(+), 15 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index e3aae6d..60e261c9 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -159,8 +159,12 @@ enum kvm_bus {
int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, const void *val);
+int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
+ int len, const void *val, long cookie);
int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, int len,
void *val);
+int kvm_io_bus_read_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
+ int len, void *val, long cookie);
int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, struct kvm_io_device *dev);
int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 1580dd4..c7f5355 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2863,11 +2863,48 @@ static int kvm_io_bus_get_first_dev(struct kvm_io_bus *bus,
return off;
}
+static int __kvm_io_bus_write(struct kvm_io_bus *bus,
+ struct kvm_io_range *range, const void *val)
+{
+ int idx;
+
+ idx = kvm_io_bus_get_first_dev(bus, range->addr, range->len);
+ if (idx < 0)
+ return -EOPNOTSUPP;
+
+ while (idx < bus->dev_count &&
+ kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
+ if (!kvm_iodevice_write(bus->range[idx].dev, range->addr,
+ range->len, val))
+ return idx;
+ idx++;
+ }
+
+ return -EOPNOTSUPP;
+}
+
/* kvm_io_bus_write - called under kvm->slots_lock */
int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, const void *val)
{
- int idx;
+ struct kvm_io_bus *bus;
+ struct kvm_io_range range;
+ int r;
+
+ range = (struct kvm_io_range) {
+ .addr = addr,
+ .len = len,
+ };
+
+ bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
+ r = __kvm_io_bus_write(bus, &range, val);
+ return r < 0 ? r : 0;
+}
+
+/* kvm_io_bus_write_cookie - called under kvm->slots_lock */
+int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
+ int len, const void *val, long cookie)
+{
struct kvm_io_bus *bus;
struct kvm_io_range range;
@@ -2877,14 +2914,35 @@ int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
};
bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
- idx = kvm_io_bus_get_first_dev(bus, addr, len);
+
+ /* First try the device referenced by cookie. */
+ if ((cookie >= 0) && (cookie < bus->dev_count) &&
+ (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
+ if (!kvm_iodevice_write(bus->range[cookie].dev, addr, len,
+ val))
+ return cookie;
+
+ /*
+ * cookie contained garbage; fall back to search and return the
+ * correct cookie value.
+ */
+ return __kvm_io_bus_write(bus, &range, val);
+}
+
+static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
+ void *val)
+{
+ int idx;
+
+ idx = kvm_io_bus_get_first_dev(bus, range->addr, range->len);
if (idx < 0)
return -EOPNOTSUPP;
while (idx < bus->dev_count &&
kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
- if (!kvm_iodevice_write(bus->range[idx].dev, addr, len, val))
- return 0;
+ if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
+ range->len, val))
+ return idx;
idx++;
}
@@ -2895,9 +2953,9 @@ int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
int len, void *val)
{
- int idx;
struct kvm_io_bus *bus;
struct kvm_io_range range;
+ int r;
range = (struct kvm_io_range) {
.addr = addr,
@@ -2905,18 +2963,36 @@ int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
};
bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
- idx = kvm_io_bus_get_first_dev(bus, addr, len);
- if (idx < 0)
- return -EOPNOTSUPP;
+ r = __kvm_io_bus_read(bus, &range, val);
+ return r < 0 ? r : 0;
+}
- while (idx < bus->dev_count &&
- kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
- if (!kvm_iodevice_read(bus->range[idx].dev, addr, len, val))
- return 0;
- idx++;
- }
+/* kvm_io_bus_read_cookie - called under kvm->slots_lock */
+int kvm_io_bus_read_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
+ int len, void *val, long cookie)
+{
+ struct kvm_io_bus *bus;
+ struct kvm_io_range range;
- return -EOPNOTSUPP;
+ range = (struct kvm_io_range) {
+ .addr = addr,
+ .len = len,
+ };
+
+ bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
+
+ /* First try the device referenced by cookie. */
+ if ((cookie >= 0) && (cookie < bus->dev_count) &&
+ (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
+ if (!kvm_iodevice_read(bus->range[cookie].dev, addr, len,
+ val))
+ return cookie;
+
+ /*
+ * cookie contained garbage; fall back to search and return the
+ * correct cookie value.
+ */
+ return __kvm_io_bus_read(bus, &range, val);
}
/* Caller must hold slots_lock. */
--
1.8.2.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-03 14:30 [PATCH v4 0/2] KVM: ioeventfd cookies Cornelia Huck
2013-07-03 14:30 ` [PATCH v4 1/2] KVM: kvm-io: support cookies Cornelia Huck
@ 2013-07-03 14:30 ` Cornelia Huck
2013-07-03 15:30 ` Paolo Bonzini
1 sibling, 1 reply; 11+ messages in thread
From: Cornelia Huck @ 2013-07-03 14:30 UTC (permalink / raw)
To: Gleb Natapov, Paolo Bonzini
Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky, KVM,
linux-s390
Make use of cookies for the virtio ccw notification hypercall to speed up
lookup of devices on the io bus.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
arch/s390/kvm/diag.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 3074475..e88c76e 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -119,11 +119,20 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
* The layout is as follows:
* - gpr 2 contains the subchannel id (passed as addr)
* - gpr 3 contains the virtqueue index (passed as datamatch)
+ * - gpr 4 contains the index on the bus (optionally)
*/
- ret = kvm_io_bus_write(vcpu->kvm, KVM_VIRTIO_CCW_NOTIFY_BUS,
- vcpu->run->s.regs.gprs[2],
- 8, &vcpu->run->s.regs.gprs[3]);
+ ret = kvm_io_bus_write_cookie(vcpu->kvm, KVM_VIRTIO_CCW_NOTIFY_BUS,
+ vcpu->run->s.regs.gprs[2],
+ 8, &vcpu->run->s.regs.gprs[3],
+ vcpu->run->s.regs.gprs[4]);
srcu_read_unlock(&vcpu->kvm->srcu, idx);
+
+ /*
+ * Return cookie in gpr 2, but don't overwrite the register if the
+ * diagnose will be handled by userspace.
+ */
+ if (ret != -EOPNOTSUPP)
+ vcpu->run->s.regs.gprs[2] = ret;
/* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
return ret < 0 ? ret : 0;
}
--
1.8.2.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 1/2] KVM: kvm-io: support cookies
2013-07-03 14:30 ` [PATCH v4 1/2] KVM: kvm-io: support cookies Cornelia Huck
@ 2013-07-03 15:05 ` Gleb Natapov
0 siblings, 0 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-07-03 15:05 UTC (permalink / raw)
To: Cornelia Huck
Cc: Paolo Bonzini, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
On Wed, Jul 03, 2013 at 04:30:53PM +0200, Cornelia Huck wrote:
> Add new functions kvm_io_bus_{read,write}_cookie() that allows users of
> the kvm io infrastructure to use a cookie value to speed up lookup of a
> device on an io bus.
>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Looks good to me now.
> ---
> include/linux/kvm_host.h | 4 ++
> virt/kvm/kvm_main.c | 106 ++++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 95 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index e3aae6d..60e261c9 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -159,8 +159,12 @@ enum kvm_bus {
>
> int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> int len, const void *val);
> +int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> + int len, const void *val, long cookie);
> int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, int len,
> void *val);
> +int kvm_io_bus_read_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> + int len, void *val, long cookie);
> int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> int len, struct kvm_io_device *dev);
> int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 1580dd4..c7f5355 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2863,11 +2863,48 @@ static int kvm_io_bus_get_first_dev(struct kvm_io_bus *bus,
> return off;
> }
>
> +static int __kvm_io_bus_write(struct kvm_io_bus *bus,
> + struct kvm_io_range *range, const void *val)
> +{
> + int idx;
> +
> + idx = kvm_io_bus_get_first_dev(bus, range->addr, range->len);
> + if (idx < 0)
> + return -EOPNOTSUPP;
> +
> + while (idx < bus->dev_count &&
> + kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
> + if (!kvm_iodevice_write(bus->range[idx].dev, range->addr,
> + range->len, val))
> + return idx;
> + idx++;
> + }
> +
> + return -EOPNOTSUPP;
> +}
> +
> /* kvm_io_bus_write - called under kvm->slots_lock */
> int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> int len, const void *val)
> {
> - int idx;
> + struct kvm_io_bus *bus;
> + struct kvm_io_range range;
> + int r;
> +
> + range = (struct kvm_io_range) {
> + .addr = addr,
> + .len = len,
> + };
> +
> + bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
> + r = __kvm_io_bus_write(bus, &range, val);
> + return r < 0 ? r : 0;
> +}
> +
> +/* kvm_io_bus_write_cookie - called under kvm->slots_lock */
> +int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> + int len, const void *val, long cookie)
> +{
> struct kvm_io_bus *bus;
> struct kvm_io_range range;
>
> @@ -2877,14 +2914,35 @@ int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> };
>
> bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
> - idx = kvm_io_bus_get_first_dev(bus, addr, len);
> +
> + /* First try the device referenced by cookie. */
> + if ((cookie >= 0) && (cookie < bus->dev_count) &&
> + (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
> + if (!kvm_iodevice_write(bus->range[cookie].dev, addr, len,
> + val))
> + return cookie;
> +
> + /*
> + * cookie contained garbage; fall back to search and return the
> + * correct cookie value.
> + */
> + return __kvm_io_bus_write(bus, &range, val);
> +}
> +
> +static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
> + void *val)
> +{
> + int idx;
> +
> + idx = kvm_io_bus_get_first_dev(bus, range->addr, range->len);
> if (idx < 0)
> return -EOPNOTSUPP;
>
> while (idx < bus->dev_count &&
> kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
> - if (!kvm_iodevice_write(bus->range[idx].dev, addr, len, val))
> - return 0;
> + if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
> + range->len, val))
> + return idx;
> idx++;
> }
>
> @@ -2895,9 +2953,9 @@ int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> int len, void *val)
> {
> - int idx;
> struct kvm_io_bus *bus;
> struct kvm_io_range range;
> + int r;
>
> range = (struct kvm_io_range) {
> .addr = addr,
> @@ -2905,18 +2963,36 @@ int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> };
>
> bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
> - idx = kvm_io_bus_get_first_dev(bus, addr, len);
> - if (idx < 0)
> - return -EOPNOTSUPP;
> + r = __kvm_io_bus_read(bus, &range, val);
> + return r < 0 ? r : 0;
> +}
>
> - while (idx < bus->dev_count &&
> - kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
> - if (!kvm_iodevice_read(bus->range[idx].dev, addr, len, val))
> - return 0;
> - idx++;
> - }
> +/* kvm_io_bus_read_cookie - called under kvm->slots_lock */
> +int kvm_io_bus_read_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> + int len, void *val, long cookie)
> +{
> + struct kvm_io_bus *bus;
> + struct kvm_io_range range;
>
> - return -EOPNOTSUPP;
> + range = (struct kvm_io_range) {
> + .addr = addr,
> + .len = len,
> + };
> +
> + bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
> +
> + /* First try the device referenced by cookie. */
> + if ((cookie >= 0) && (cookie < bus->dev_count) &&
> + (kvm_io_bus_sort_cmp(&range, &bus->range[cookie]) == 0))
> + if (!kvm_iodevice_read(bus->range[cookie].dev, addr, len,
> + val))
> + return cookie;
> +
> + /*
> + * cookie contained garbage; fall back to search and return the
> + * correct cookie value.
> + */
> + return __kvm_io_bus_read(bus, &range, val);
> }
>
> /* Caller must hold slots_lock. */
> --
> 1.8.2.2
--
Gleb.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-03 14:30 ` [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd Cornelia Huck
@ 2013-07-03 15:30 ` Paolo Bonzini
2013-07-03 16:33 ` Cornelia Huck
0 siblings, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2013-07-03 15:30 UTC (permalink / raw)
To: Cornelia Huck
Cc: Gleb Natapov, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
Il 03/07/2013 16:30, Cornelia Huck ha scritto:
> + /*
> + * Return cookie in gpr 2, but don't overwrite the register if the
> + * diagnose will be handled by userspace.
> + */
> + if (ret != -EOPNOTSUPP)
> + vcpu->run->s.regs.gprs[2] = ret;
I think this should now be "if (ret >= 0)".
> /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
The comment is now obsolete.
> return ret < 0 ? ret : 0;
Otherwise looks good, thanks!
Paolo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-03 15:30 ` Paolo Bonzini
@ 2013-07-03 16:33 ` Cornelia Huck
2013-07-04 6:54 ` Paolo Bonzini
0 siblings, 1 reply; 11+ messages in thread
From: Cornelia Huck @ 2013-07-03 16:33 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Gleb Natapov, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
On Wed, 03 Jul 2013 17:30:40 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 03/07/2013 16:30, Cornelia Huck ha scritto:
> > + /*
> > + * Return cookie in gpr 2, but don't overwrite the register if the
> > + * diagnose will be handled by userspace.
> > + */
> > + if (ret != -EOPNOTSUPP)
> > + vcpu->run->s.regs.gprs[2] = ret;
>
> I think this should now be "if (ret >= 0)".
Hm, we don't want to kill gpr 2's old contents if userspace will do
something, which means -EOPNOTSUPP.
>
> > /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
>
> The comment is now obsolete.
s/kvm_io_bus_write/kvm_io_bus_write_cookie/ ? Otherwise, this is still
true.
>
> > return ret < 0 ? ret : 0;
>
> Otherwise looks good, thanks!
>
> Paolo
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-03 16:33 ` Cornelia Huck
@ 2013-07-04 6:54 ` Paolo Bonzini
2013-07-14 9:25 ` Gleb Natapov
0 siblings, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2013-07-04 6:54 UTC (permalink / raw)
To: Cornelia Huck
Cc: Gleb Natapov, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
Il 03/07/2013 18:33, Cornelia Huck ha scritto:
> On Wed, 03 Jul 2013 17:30:40 +0200
> Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> Il 03/07/2013 16:30, Cornelia Huck ha scritto:
>>> + /*
>>> + * Return cookie in gpr 2, but don't overwrite the register if the
>>> + * diagnose will be handled by userspace.
>>> + */
>>> + if (ret != -EOPNOTSUPP)
>>> + vcpu->run->s.regs.gprs[2] = ret;
>>
>> I think this should now be "if (ret >= 0)".
>
> Hm, we don't want to kill gpr 2's old contents if userspace will do
> something, which means -EOPNOTSUPP.
In the end kvm_io_bus_write_cookie only returns -EOPNOTSUPP if there is
an error, so it works. But if this were to change, the code would
break. That's why I suggested testing "ret >= 0" rather than "ret !=
-EOPNOTSUPP". But in the end it is the same.
>>
>>> /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
>>
>> The comment is now obsolete.
>
> s/kvm_io_bus_write/kvm_io_bus_write_cookie/ ? Otherwise, this is still
> true.
True but somewhat misplaced, it is basically saying the same thing as
the "Return cookie in gpr 2" comment just above.
Anyhow, these are very small details. I changed kvm_io_bus_write to
kvm_io_bus_write_cookie in the comment and applied the patches to kvm-queue.
Paolo
>>
>>> return ret < 0 ? ret : 0;
>>
>> Otherwise looks good, thanks!
>>
>> Paolo
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-04 6:54 ` Paolo Bonzini
@ 2013-07-14 9:25 ` Gleb Natapov
2013-07-14 10:19 ` Gleb Natapov
0 siblings, 1 reply; 11+ messages in thread
From: Gleb Natapov @ 2013-07-14 9:25 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Cornelia Huck, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
On Thu, Jul 04, 2013 at 08:54:32AM +0200, Paolo Bonzini wrote:
> Il 03/07/2013 18:33, Cornelia Huck ha scritto:
> > On Wed, 03 Jul 2013 17:30:40 +0200
> > Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> >> Il 03/07/2013 16:30, Cornelia Huck ha scritto:
> >>> + /*
> >>> + * Return cookie in gpr 2, but don't overwrite the register if the
> >>> + * diagnose will be handled by userspace.
> >>> + */
> >>> + if (ret != -EOPNOTSUPP)
> >>> + vcpu->run->s.regs.gprs[2] = ret;
> >>
> >> I think this should now be "if (ret >= 0)".
> >
> > Hm, we don't want to kill gpr 2's old contents if userspace will do
> > something, which means -EOPNOTSUPP.
>
> In the end kvm_io_bus_write_cookie only returns -EOPNOTSUPP if there is
> an error, so it works. But if this were to change, the code would
> break. That's why I suggested testing "ret >= 0" rather than "ret !=
> -EOPNOTSUPP". But in the end it is the same.
>
> >>
> >>> /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
> >>
> >> The comment is now obsolete.
> >
> > s/kvm_io_bus_write/kvm_io_bus_write_cookie/ ? Otherwise, this is still
> > true.
>
> True but somewhat misplaced, it is basically saying the same thing as
> the "Return cookie in gpr 2" comment just above.
>
> Anyhow, these are very small details. I changed kvm_io_bus_write to
> kvm_io_bus_write_cookie in the comment and applied the patches to kvm-queue.
>
1/2 broke x86. QEMU prints "Invalid read from memory region kvm-pic" and
guest hangs. Looks like IO is forwarded to userspace instead of in kernel device
for some reason. Un-applying for now.
--
Gleb.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-14 9:25 ` Gleb Natapov
@ 2013-07-14 10:19 ` Gleb Natapov
2013-07-15 7:56 ` Cornelia Huck
2013-07-15 12:03 ` Paolo Bonzini
0 siblings, 2 replies; 11+ messages in thread
From: Gleb Natapov @ 2013-07-14 10:19 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Cornelia Huck, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
On Sun, Jul 14, 2013 at 12:25:16PM +0300, Gleb Natapov wrote:
> On Thu, Jul 04, 2013 at 08:54:32AM +0200, Paolo Bonzini wrote:
> > Il 03/07/2013 18:33, Cornelia Huck ha scritto:
> > > On Wed, 03 Jul 2013 17:30:40 +0200
> > > Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >
> > >> Il 03/07/2013 16:30, Cornelia Huck ha scritto:
> > >>> + /*
> > >>> + * Return cookie in gpr 2, but don't overwrite the register if the
> > >>> + * diagnose will be handled by userspace.
> > >>> + */
> > >>> + if (ret != -EOPNOTSUPP)
> > >>> + vcpu->run->s.regs.gprs[2] = ret;
> > >>
> > >> I think this should now be "if (ret >= 0)".
> > >
> > > Hm, we don't want to kill gpr 2's old contents if userspace will do
> > > something, which means -EOPNOTSUPP.
> >
> > In the end kvm_io_bus_write_cookie only returns -EOPNOTSUPP if there is
> > an error, so it works. But if this were to change, the code would
> > break. That's why I suggested testing "ret >= 0" rather than "ret !=
> > -EOPNOTSUPP". But in the end it is the same.
> >
> > >>
> > >>> /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
> > >>
> > >> The comment is now obsolete.
> > >
> > > s/kvm_io_bus_write/kvm_io_bus_write_cookie/ ? Otherwise, this is still
> > > true.
> >
> > True but somewhat misplaced, it is basically saying the same thing as
> > the "Return cookie in gpr 2" comment just above.
> >
> > Anyhow, these are very small details. I changed kvm_io_bus_write to
> > kvm_io_bus_write_cookie in the comment and applied the patches to kvm-queue.
> >
> 1/2 broke x86. QEMU prints "Invalid read from memory region kvm-pic" and
> guest hangs. Looks like IO is forwarded to userspace instead of in kernel device
> for some reason. Un-applying for now.
>
OK, stupid typo. Will amend the commit instead of dropping.
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 6cde6fa..a86735d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2942,7 +2942,7 @@ static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
return -EOPNOTSUPP;
while (idx < bus->dev_count &&
- kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
+ kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
range->len, val))
return idx;
--
Gleb.
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-14 10:19 ` Gleb Natapov
@ 2013-07-15 7:56 ` Cornelia Huck
2013-07-15 12:03 ` Paolo Bonzini
1 sibling, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-07-15 7:56 UTC (permalink / raw)
To: Gleb Natapov
Cc: Paolo Bonzini, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
On Sun, 14 Jul 2013 13:19:59 +0300
Gleb Natapov <gleb@redhat.com> wrote:
> On Sun, Jul 14, 2013 at 12:25:16PM +0300, Gleb Natapov wrote:
> > 1/2 broke x86. QEMU prints "Invalid read from memory region kvm-pic" and
> > guest hangs. Looks like IO is forwarded to userspace instead of in kernel device
> > for some reason. Un-applying for now.
> >
> OK, stupid typo. Will amend the commit instead of dropping.
>
Thanks for fixing.
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 6cde6fa..a86735d 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2942,7 +2942,7 @@ static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
> return -EOPNOTSUPP;
>
> while (idx < bus->dev_count &&
> - kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
> + kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
> if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
> range->len, val))
> return idx;
> --
> Gleb.
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd
2013-07-14 10:19 ` Gleb Natapov
2013-07-15 7:56 ` Cornelia Huck
@ 2013-07-15 12:03 ` Paolo Bonzini
1 sibling, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2013-07-15 12:03 UTC (permalink / raw)
To: Gleb Natapov
Cc: Cornelia Huck, Christian Borntraeger, Heiko Carstens,
Martin Schwidefsky, KVM, linux-s390
Il 14/07/2013 12:19, Gleb Natapov ha scritto:
> On Sun, Jul 14, 2013 at 12:25:16PM +0300, Gleb Natapov wrote:
>> On Thu, Jul 04, 2013 at 08:54:32AM +0200, Paolo Bonzini wrote:
>>> Il 03/07/2013 18:33, Cornelia Huck ha scritto:
>>>> On Wed, 03 Jul 2013 17:30:40 +0200
>>>> Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>>
>>>>> Il 03/07/2013 16:30, Cornelia Huck ha scritto:
>>>>>> + /*
>>>>>> + * Return cookie in gpr 2, but don't overwrite the register if the
>>>>>> + * diagnose will be handled by userspace.
>>>>>> + */
>>>>>> + if (ret != -EOPNOTSUPP)
>>>>>> + vcpu->run->s.regs.gprs[2] = ret;
>>>>>
>>>>> I think this should now be "if (ret >= 0)".
>>>>
>>>> Hm, we don't want to kill gpr 2's old contents if userspace will do
>>>> something, which means -EOPNOTSUPP.
>>>
>>> In the end kvm_io_bus_write_cookie only returns -EOPNOTSUPP if there is
>>> an error, so it works. But if this were to change, the code would
>>> break. That's why I suggested testing "ret >= 0" rather than "ret !=
>>> -EOPNOTSUPP". But in the end it is the same.
>>>
>>>>>
>>>>>> /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
>>>>>
>>>>> The comment is now obsolete.
>>>>
>>>> s/kvm_io_bus_write/kvm_io_bus_write_cookie/ ? Otherwise, this is still
>>>> true.
>>>
>>> True but somewhat misplaced, it is basically saying the same thing as
>>> the "Return cookie in gpr 2" comment just above.
>>>
>>> Anyhow, these are very small details. I changed kvm_io_bus_write to
>>> kvm_io_bus_write_cookie in the comment and applied the patches to kvm-queue.
>>>
>> 1/2 broke x86. QEMU prints "Invalid read from memory region kvm-pic" and
>> guest hangs. Looks like IO is forwarded to userspace instead of in kernel device
>> for some reason. Un-applying for now.
>>
> OK, stupid typo. Will amend the commit instead of dropping.
>
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 6cde6fa..a86735d 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2942,7 +2942,7 @@ static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range,
> return -EOPNOTSUPP;
>
> while (idx < bus->dev_count &&
> - kvm_io_bus_sort_cmp(&range, &bus->range[idx]) == 0) {
> + kvm_io_bus_sort_cmp(range, &bus->range[idx]) == 0) {
> if (!kvm_iodevice_read(bus->range[idx].dev, range->addr,
> range->len, val))
> return idx;
> --
> Gleb.
>
We can introduce an
int __kvm_io_bus_sort_cmp(const struct kvm_io_range *p1, const struct kvm_io_range *p2)
function so that this kind of typo doesn't happen again in the future.
I'll post a patch later.
Paolo
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-07-15 12:03 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 14:30 [PATCH v4 0/2] KVM: ioeventfd cookies Cornelia Huck
2013-07-03 14:30 ` [PATCH v4 1/2] KVM: kvm-io: support cookies Cornelia Huck
2013-07-03 15:05 ` Gleb Natapov
2013-07-03 14:30 ` [PATCH v4 2/2] KVM: s390: use cookies for ioeventfd Cornelia Huck
2013-07-03 15:30 ` Paolo Bonzini
2013-07-03 16:33 ` Cornelia Huck
2013-07-04 6:54 ` Paolo Bonzini
2013-07-14 9:25 ` Gleb Natapov
2013-07-14 10:19 ` Gleb Natapov
2013-07-15 7:56 ` Cornelia Huck
2013-07-15 12:03 ` Paolo Bonzini
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).