* [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features
[not found] <1417713984-23771-1-git-send-email-mst@redhat.com>
@ 2014-12-04 17:26 ` Michael S. Tsirkin
2014-12-04 17:56 ` Cornelia Huck
2014-12-04 17:26 ` [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1 Michael S. Tsirkin
1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-12-04 17:26 UTC (permalink / raw)
To: linux-kernel
Cc: Rusty Russell, Cornelia Huck, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
Legacy balloon device doesn't pretend to support revision 1 or 64 bit
features.
But just in case someone implements a broken one that does, let's not
even try to drive legacy only devices using revision 1, and let's not
give them a chance to say they support VIRTIO_F_VERSION_1 by not reading
high feature bits.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/s390/kvm/virtio_ccw.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 4a3e6e5..088bdf1 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -733,6 +733,9 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
rc = le32_to_cpu(features->features);
+ if (vcdev->revision == 0)
+ goto out_free;
+
/* Read second half of the feature bits from the host. */
features->index = 1;
ccw->cmd_code = CCW_CMD_READ_FEAT;
@@ -1182,9 +1185,13 @@ static int virtio_ccw_online(struct ccw_device *cdev)
vcdev->vdev.id.vendor = cdev->id.cu_type;
vcdev->vdev.id.device = cdev->id.cu_model;
- ret = virtio_ccw_set_transport_rev(vcdev);
- if (ret)
- goto out_free;
+ if (virtio_device_is_legacy_only(vcdev->vdev.id)) {
+ ret = virtio_ccw_set_transport_rev(vcdev);
+ if (ret)
+ goto out_free;
+ } else {
+ vcdev->revision = 0;
+ }
ret = register_virtio_device(&vcdev->vdev);
if (ret) {
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
[not found] <1417713984-23771-1-git-send-email-mst@redhat.com>
2014-12-04 17:26 ` [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features Michael S. Tsirkin
@ 2014-12-04 17:26 ` Michael S. Tsirkin
2014-12-04 17:59 ` Cornelia Huck
1 sibling, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-12-04 17:26 UTC (permalink / raw)
To: linux-kernel
Cc: Rusty Russell, Cornelia Huck, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
What does it mean if rev 1 device does not set
VIRTIO_F_VERSION_1? E.g. is it native endian?
Let's not even try to drive such devices:
skip attempts to finalize features or set status.
virtio core will detect this and bail out.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/s390/kvm/virtio_ccw.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index 088bdf1..0ceeb25 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -65,6 +65,7 @@ struct virtio_ccw_device {
bool is_thinint;
bool going_away;
bool device_lost;
+ bool features_invalid;
void *airq_info;
};
@@ -746,6 +747,12 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
if (ret == 0)
rc |= (u64)le32_to_cpu(features->features) << 32;
+ /* Devices MUST set VIRTIO_F_VERSION_1 */
+ if (!(rc & BIT_ULL(VIRTIO_F_VERSION_1))) {
+ vcdev->features_invalid = true;
+ rc |= BIT_ULL(VIRTIO_F_VERSION_1);
+ }
+
out_free:
kfree(features);
kfree(ccw);
@@ -758,6 +765,10 @@ static void virtio_ccw_finalize_features(struct virtio_device *vdev)
struct virtio_feature_desc *features;
struct ccw1 *ccw;
+ /* Invalid features? Let's not try to drive this device. */
+ if (vcdev->features_invalid)
+ return;
+
ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
if (!ccw)
return;
@@ -869,6 +880,10 @@ static void virtio_ccw_set_status(struct virtio_device *vdev, u8 status)
struct ccw1 *ccw;
int ret;
+ /* Invalid features? Let's not try to drive this device. */
+ if (vcdev->features_invalid)
+ return;
+
ccw = kzalloc(sizeof(*ccw), GFP_DMA | GFP_KERNEL);
if (!ccw)
return;
--
MST
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features
2014-12-04 17:26 ` [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features Michael S. Tsirkin
@ 2014-12-04 17:56 ` Cornelia Huck
2014-12-04 18:09 ` Michael S. Tsirkin
0 siblings, 1 reply; 7+ messages in thread
From: Cornelia Huck @ 2014-12-04 17:56 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-kernel, Rusty Russell, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
On Thu, 4 Dec 2014 19:26:45 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> Legacy balloon device doesn't pretend to support revision 1 or 64 bit
> features.
>
> But just in case someone implements a broken one that does, let's not
> even try to drive legacy only devices using revision 1, and let's not
> give them a chance to say they support VIRTIO_F_VERSION_1 by not reading
> high feature bits.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/s390/kvm/virtio_ccw.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
> index 4a3e6e5..088bdf1 100644
> --- a/drivers/s390/kvm/virtio_ccw.c
> +++ b/drivers/s390/kvm/virtio_ccw.c
> @@ -733,6 +733,9 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
>
> rc = le32_to_cpu(features->features);
>
> + if (vcdev->revision == 0)
> + goto out_free;
> +
> /* Read second half of the feature bits from the host. */
> features->index = 1;
> ccw->cmd_code = CCW_CMD_READ_FEAT;
> @@ -1182,9 +1185,13 @@ static int virtio_ccw_online(struct ccw_device *cdev)
> vcdev->vdev.id.vendor = cdev->id.cu_type;
> vcdev->vdev.id.device = cdev->id.cu_model;
>
> - ret = virtio_ccw_set_transport_rev(vcdev);
> - if (ret)
> - goto out_free;
> + if (virtio_device_is_legacy_only(vcdev->vdev.id)) {
Inverted logic?
> + ret = virtio_ccw_set_transport_rev(vcdev);
> + if (ret)
> + goto out_free;
> + } else {
> + vcdev->revision = 0;
> + }
>
> ret = register_virtio_device(&vcdev->vdev);
> if (ret) {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
2014-12-04 17:26 ` [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1 Michael S. Tsirkin
@ 2014-12-04 17:59 ` Cornelia Huck
2014-12-04 18:09 ` Michael S. Tsirkin
2014-12-04 18:15 ` Michael S. Tsirkin
0 siblings, 2 replies; 7+ messages in thread
From: Cornelia Huck @ 2014-12-04 17:59 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-kernel, Rusty Russell, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
On Thu, 4 Dec 2014 19:26:50 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> What does it mean if rev 1 device does not set
> VIRTIO_F_VERSION_1? E.g. is it native endian?
>
> Let's not even try to drive such devices:
> skip attempts to finalize features or set status.
Why not set status_failed?
> virtio core will detect this and bail out.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/s390/kvm/virtio_ccw.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
I'm not sure yet whether I like this approach. I'll think about it over
the weekend.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features
2014-12-04 17:56 ` Cornelia Huck
@ 2014-12-04 18:09 ` Michael S. Tsirkin
0 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-12-04 18:09 UTC (permalink / raw)
To: Cornelia Huck
Cc: linux-kernel, Rusty Russell, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
On Thu, Dec 04, 2014 at 06:56:06PM +0100, Cornelia Huck wrote:
> On Thu, 4 Dec 2014 19:26:45 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > Legacy balloon device doesn't pretend to support revision 1 or 64 bit
> > features.
> >
> > But just in case someone implements a broken one that does, let's not
> > even try to drive legacy only devices using revision 1, and let's not
> > give them a chance to say they support VIRTIO_F_VERSION_1 by not reading
> > high feature bits.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > drivers/s390/kvm/virtio_ccw.c | 13 ++++++++++---
> > 1 file changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
> > index 4a3e6e5..088bdf1 100644
> > --- a/drivers/s390/kvm/virtio_ccw.c
> > +++ b/drivers/s390/kvm/virtio_ccw.c
> > @@ -733,6 +733,9 @@ static u64 virtio_ccw_get_features(struct virtio_device *vdev)
> >
> > rc = le32_to_cpu(features->features);
> >
> > + if (vcdev->revision == 0)
> > + goto out_free;
> > +
> > /* Read second half of the feature bits from the host. */
> > features->index = 1;
> > ccw->cmd_code = CCW_CMD_READ_FEAT;
> > @@ -1182,9 +1185,13 @@ static int virtio_ccw_online(struct ccw_device *cdev)
> > vcdev->vdev.id.vendor = cdev->id.cu_type;
> > vcdev->vdev.id.device = cdev->id.cu_model;
> >
> > - ret = virtio_ccw_set_transport_rev(vcdev);
> > - if (ret)
> > - goto out_free;
> > + if (virtio_device_is_legacy_only(vcdev->vdev.id)) {
>
> Inverted logic?
Ugh, clearly.
> > + ret = virtio_ccw_set_transport_rev(vcdev);
> > + if (ret)
> > + goto out_free;
> > + } else {
> > + vcdev->revision = 0;
> > + }
> >
> > ret = register_virtio_device(&vcdev->vdev);
> > if (ret) {
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
2014-12-04 17:59 ` Cornelia Huck
@ 2014-12-04 18:09 ` Michael S. Tsirkin
2014-12-04 18:15 ` Michael S. Tsirkin
1 sibling, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-12-04 18:09 UTC (permalink / raw)
To: Cornelia Huck
Cc: linux-kernel, Rusty Russell, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
On Thu, Dec 04, 2014 at 06:59:14PM +0100, Cornelia Huck wrote:
> On Thu, 4 Dec 2014 19:26:50 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > What does it mean if rev 1 device does not set
> > VIRTIO_F_VERSION_1? E.g. is it native endian?
> >
> > Let's not even try to drive such devices:
> > skip attempts to finalize features or set status.
>
> Why not set status_failed?
What's status_failed?
> > virtio core will detect this and bail out.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > drivers/s390/kvm/virtio_ccw.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
>
> I'm not sure yet whether I like this approach. I'll think about it over
> the weekend.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1
2014-12-04 17:59 ` Cornelia Huck
2014-12-04 18:09 ` Michael S. Tsirkin
@ 2014-12-04 18:15 ` Michael S. Tsirkin
1 sibling, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-12-04 18:15 UTC (permalink / raw)
To: Cornelia Huck
Cc: linux-kernel, Rusty Russell, David Hildenbrand, virtualization,
Christian Borntraeger, linux390, Martin Schwidefsky,
Heiko Carstens, linux-s390
On Thu, Dec 04, 2014 at 06:59:14PM +0100, Cornelia Huck wrote:
> On Thu, 4 Dec 2014 19:26:50 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > What does it mean if rev 1 device does not set
> > VIRTIO_F_VERSION_1? E.g. is it native endian?
> >
> > Let's not even try to drive such devices:
> > skip attempts to finalize features or set status.
>
> Why not set status_failed?
It might be cleanest to just teach core that finalize_features
can fail.
I'll look into this.
> > virtio core will detect this and bail out.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > drivers/s390/kvm/virtio_ccw.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
>
> I'm not sure yet whether I like this approach. I'll think about it over
> the weekend.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-04 18:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1417713984-23771-1-git-send-email-mst@redhat.com>
2014-12-04 17:26 ` [PATCH RFC 2/3] virtio_ccw: legacy: don't negotiate rev 1/features Michael S. Tsirkin
2014-12-04 17:56 ` Cornelia Huck
2014-12-04 18:09 ` Michael S. Tsirkin
2014-12-04 17:26 ` [PATCH RFC 3/3] virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1 Michael S. Tsirkin
2014-12-04 17:59 ` Cornelia Huck
2014-12-04 18:09 ` Michael S. Tsirkin
2014-12-04 18:15 ` Michael S. Tsirkin
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).