* [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness
@ 2014-12-02 11:44 Michael S. Tsirkin
2014-12-02 11:44 ` [PATCH RFC 2/2] virtio_balloon: drop legacy_only Michael S. Tsirkin
[not found] ` <1417520617-2135-1-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 2 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-02 11:44 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-api, virtualization
balloon device is not part of virtio 1.0 spec. Still, it's easy enough
to make it handle endian-ness exactly as other virtio 1.0 devices: what
we gain from this, is that there's no need to special-case it in virtio
core.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/uapi/linux/virtio_balloon.h | 5 +++--
drivers/virtio/virtio_balloon.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h
index 5e26f61..5bee71c 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -27,6 +27,7 @@
* SUCH DAMAGE. */
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
+#include <linux/virtio_types.h>
/* The feature bitmap for virtio balloon */
#define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
@@ -52,8 +53,8 @@ struct virtio_balloon_config
#define VIRTIO_BALLOON_S_NR 6
struct virtio_balloon_stat {
- __u16 tag;
- __u64 val;
+ __virtio16 tag;
+ __virtio64 val;
} __attribute__((packed));
#endif /* _LINUX_VIRTIO_BALLOON_H */
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 4497def..721e32f 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -201,8 +201,8 @@ static inline void update_stat(struct virtio_balloon *vb, int idx,
u16 tag, u64 val)
{
BUG_ON(idx >= VIRTIO_BALLOON_S_NR);
- vb->stats[idx].tag = tag;
- vb->stats[idx].val = val;
+ vb->stats[idx].tag = cpu_to_virtio16(vb->vdev, tag);
+ vb->stats[idx].val = cpu_to_virtio64(vb->vdev, val);
}
#define pages_to_bytes(x) ((u64)(x) << PAGE_SHIFT)
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH RFC 2/2] virtio_balloon: drop legacy_only
2014-12-02 11:44 [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness Michael S. Tsirkin
@ 2014-12-02 11:44 ` Michael S. Tsirkin
[not found] ` <1417520617-2135-1-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
1 sibling, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-02 11:44 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-api, David Hildenbrand, virtualization
balloon is the only driver using legacy_only ATM.
It turns out, it's easier to just make balloon support virtio 1.0
endian-ness and drop the flag from core.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/linux/virtio.h | 2 --
drivers/virtio/virtio.c | 4 ----
drivers/virtio/virtio_balloon.c | 1 -
3 files changed, 7 deletions(-)
diff --git a/include/linux/virtio.h b/include/linux/virtio.h
index 2bbf626..f70411e 100644
--- a/include/linux/virtio.h
+++ b/include/linux/virtio.h
@@ -132,7 +132,6 @@ int virtio_device_restore(struct virtio_device *dev);
* @feature_table_size: number of entries in the feature table array.
* @feature_table_legacy: same as feature_table but when working in legacy mode.
* @feature_table_size_legacy: number of entries in feature table legacy array.
- * @legacy_only: driver does not support virtio 1.0.
* @probe: the function to call when a device is found. Returns 0 or -errno.
* @remove: the function to call when a device is removed.
* @config_changed: optional function to call when the device configuration
@@ -145,7 +144,6 @@ struct virtio_driver {
unsigned int feature_table_size;
const unsigned int *feature_table_legacy;
unsigned int feature_table_size_legacy;
- bool legacy_only;
int (*probe)(struct virtio_device *dev);
void (*scan)(struct virtio_device *dev);
void (*remove)(struct virtio_device *dev);
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index fa6b75d..2e836d8 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -197,10 +197,6 @@ static int virtio_dev_probe(struct device *_d)
driver_features_legacy = driver_features;
}
- /* Detect legacy-only drivers and disable VIRTIO_F_VERSION_1. */
- if (drv->legacy_only)
- device_features &= ~(1ULL << VIRTIO_F_VERSION_1);
-
if (device_features & (1ULL << VIRTIO_F_VERSION_1))
dev->features = driver_features & device_features;
else
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 721e32f..fed3709 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -518,7 +518,6 @@ static unsigned int features[] = {
};
static struct virtio_driver virtio_balloon_driver = {
- .legacy_only = true,
.feature_table = features,
.feature_table_size = ARRAY_SIZE(features),
.driver.name = KBUILD_MODNAME,
--
MST
^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1417520617-2135-1-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness
[not found] ` <1417520617-2135-1-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-12-02 18:39 ` Cornelia Huck
2014-12-03 14:02 ` Michael S. Tsirkin
0 siblings, 1 reply; 5+ messages in thread
From: Cornelia Huck @ 2014-12-02 18:39 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA,
virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
On Tue, 2 Dec 2014 13:44:06 +0200
"Michael S. Tsirkin" <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> balloon device is not part of virtio 1.0 spec. Still, it's easy enough
> to make it handle endian-ness exactly as other virtio 1.0 devices: what
> we gain from this, is that there's no need to special-case it in virtio
> core.
Well, the balloon is weird in a number of ways, including its always
little-endian config space.
But I'm not quite sure the spec covers this?
>
> Signed-off-by: Michael S. Tsirkin <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> include/uapi/linux/virtio_balloon.h | 5 +++--
> drivers/virtio/virtio_balloon.c | 4 ++--
> 2 files changed, 5 insertions(+), 4 deletions(-)
>
> struct virtio_balloon_stat {
> - __u16 tag;
> - __u64 val;
> + __virtio16 tag;
> + __virtio64 val;
> } __attribute__((packed));
Would the respective fields in the spec need updating? While it is
actually talking about legacy requirements, the fields are not
specified as __virtio{16,64}.
Also, is changing the stat fields enough? I've not looked into balloon
operation, but does the payload need some endianess conversion as well?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness
2014-12-02 18:39 ` [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness Cornelia Huck
@ 2014-12-03 14:02 ` Michael S. Tsirkin
2014-12-03 14:27 ` Cornelia Huck
0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2014-12-03 14:02 UTC (permalink / raw)
To: Cornelia Huck; +Cc: linux-api, linux-kernel, virtualization
On Tue, Dec 02, 2014 at 07:39:30PM +0100, Cornelia Huck wrote:
> On Tue, 2 Dec 2014 13:44:06 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
>
> > balloon device is not part of virtio 1.0 spec. Still, it's easy enough
> > to make it handle endian-ness exactly as other virtio 1.0 devices: what
> > we gain from this, is that there's no need to special-case it in virtio
> > core.
>
> Well, the balloon is weird in a number of ways, including its always
> little-endian config space.
Hmm yes, I forgot about that.
> But I'm not quite sure the spec covers this?
The spec does not cover balloon. It merely includes a reference section
about legacy balloon device. What to do when that device sets VERSION_1
is really up to us.
Patchset v8 simply makes balloon tell core it's legacy_only.
This is I guess fine as far as it goes.
I was still looking for the best way that involves minimal noise
in core. This looked like the best way: change 4 lines,
and drop all special casing in core, but given the config space
endian-ness mess, I'm not sure anymore.
I guess we'll just stick to what v8 does for now.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > include/uapi/linux/virtio_balloon.h | 5 +++--
> > drivers/virtio/virtio_balloon.c | 4 ++--
> > 2 files changed, 5 insertions(+), 4 deletions(-)
> >
>
> > struct virtio_balloon_stat {
> > - __u16 tag;
> > - __u64 val;
> > + __virtio16 tag;
> > + __virtio64 val;
> > } __attribute__((packed));
>
> Would the respective fields in the spec need updating? While it is
> actually talking about legacy requirements, the fields are not
> specified as __virtio{16,64}.
>
> Also, is changing the stat fields enough? I've not looked into balloon
> operation, but does the payload need some endianess conversion as well?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness
2014-12-03 14:02 ` Michael S. Tsirkin
@ 2014-12-03 14:27 ` Cornelia Huck
0 siblings, 0 replies; 5+ messages in thread
From: Cornelia Huck @ 2014-12-03 14:27 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: linux-api, linux-kernel, virtualization
On Wed, 3 Dec 2014 16:02:28 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Tue, Dec 02, 2014 at 07:39:30PM +0100, Cornelia Huck wrote:
> > On Tue, 2 Dec 2014 13:44:06 +0200
> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> >
> > > balloon device is not part of virtio 1.0 spec. Still, it's easy enough
> > > to make it handle endian-ness exactly as other virtio 1.0 devices: what
> > > we gain from this, is that there's no need to special-case it in virtio
> > > core.
> >
> > Well, the balloon is weird in a number of ways, including its always
> > little-endian config space.
>
> Hmm yes, I forgot about that.
>
> > But I'm not quite sure the spec covers this?
>
> The spec does not cover balloon. It merely includes a reference section
> about legacy balloon device. What to do when that device sets VERSION_1
> is really up to us.
>
> Patchset v8 simply makes balloon tell core it's legacy_only.
> This is I guess fine as far as it goes.
> I was still looking for the best way that involves minimal noise
> in core. This looked like the best way: change 4 lines,
> and drop all special casing in core, but given the config space
> endian-ness mess, I'm not sure anymore.
> I guess we'll just stick to what v8 does for now.
I don't think the legacy_only approach is so bad, let's keep it for now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-03 14:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-02 11:44 [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness Michael S. Tsirkin
2014-12-02 11:44 ` [PATCH RFC 2/2] virtio_balloon: drop legacy_only Michael S. Tsirkin
[not found] ` <1417520617-2135-1-git-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-12-02 18:39 ` [PATCH RFC 1/2] virtio_balloon: convert to virtio 1.0 endian-ness Cornelia Huck
2014-12-03 14:02 ` Michael S. Tsirkin
2014-12-03 14:27 ` Cornelia Huck
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).