All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_mmio: generation support
@ 2015-03-05 22:09 Michael S. Tsirkin
  2015-03-09  8:40   ` Michael S. Tsirkin
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2015-03-05 22:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rusty Russell, virtualization, Pawel Moll

virtio_mmio currently lacks generation support which
makes multi-byte field access racy.
Fix by getting the value at offset 0xfc for version 2
devices. Nothing we can do for version 1, so return
generation id 0.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Pawel, you mentioned you have a working virtio 1.0
hypervisor, can you pls confirm this works correctly?

 drivers/virtio/virtio_mmio.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 0375456..69b2e4d 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
 	}
 }
 
+static u32 vm_generation(struct virtio_device *vdev)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	if (vm_dev->version == 1)
+		return 0;
+	else
+		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
+}
+
 static u8 vm_get_status(struct virtio_device *vdev)
 {
 	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
@@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
 static const struct virtio_config_ops virtio_mmio_config_ops = {
 	.get		= vm_get,
 	.set		= vm_set,
+	.generation	= vm_generation,
+	.get_status	= vm_get_status,
 	.get_status	= vm_get_status,
 	.set_status	= vm_set_status,
 	.reset		= vm_reset,
-- 
MST

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
  2015-03-05 22:09 [PATCH] virtio_mmio: generation support Michael S. Tsirkin
@ 2015-03-09  8:40   ` Michael S. Tsirkin
  2015-03-12  2:07 ` Rusty Russell
  2015-03-12  2:07 ` Rusty Russell
  2 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2015-03-09  8:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rusty Russell, virtualization, Pawel Moll

On Thu, Mar 05, 2015 at 11:09:42PM +0100, Michael S. Tsirkin wrote:
> virtio_mmio currently lacks generation support which
> makes multi-byte field access racy.
> Fix by getting the value at offset 0xfc for version 2
> devices. Nothing we can do for version 1, so return
> generation id 0.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Pawel, you mentioned you have a working virtio 1.0
> hypervisor, can you pls confirm this works correctly?

Same here - can you ack pls?

>  drivers/virtio/virtio_mmio.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 0375456..69b2e4d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  	}
>  }
>  
> +static u32 vm_generation(struct virtio_device *vdev)
> +{
> +	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> +
> +	if (vm_dev->version == 1)
> +		return 0;
> +	else
> +		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
> +}
> +
>  static u8 vm_get_status(struct virtio_device *vdev)
>  {
>  	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> @@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
>  static const struct virtio_config_ops virtio_mmio_config_ops = {
>  	.get		= vm_get,
>  	.set		= vm_set,
> +	.generation	= vm_generation,
> +	.get_status	= vm_get_status,
>  	.get_status	= vm_get_status,
>  	.set_status	= vm_set_status,
>  	.reset		= vm_reset,
> -- 
> MST

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
@ 2015-03-09  8:40   ` Michael S. Tsirkin
  0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2015-03-09  8:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: Pawel Moll, virtualization

On Thu, Mar 05, 2015 at 11:09:42PM +0100, Michael S. Tsirkin wrote:
> virtio_mmio currently lacks generation support which
> makes multi-byte field access racy.
> Fix by getting the value at offset 0xfc for version 2
> devices. Nothing we can do for version 1, so return
> generation id 0.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Pawel, you mentioned you have a working virtio 1.0
> hypervisor, can you pls confirm this works correctly?

Same here - can you ack pls?

>  drivers/virtio/virtio_mmio.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 0375456..69b2e4d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  	}
>  }
>  
> +static u32 vm_generation(struct virtio_device *vdev)
> +{
> +	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> +
> +	if (vm_dev->version == 1)
> +		return 0;
> +	else
> +		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
> +}
> +
>  static u8 vm_get_status(struct virtio_device *vdev)
>  {
>  	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> @@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
>  static const struct virtio_config_ops virtio_mmio_config_ops = {
>  	.get		= vm_get,
>  	.set		= vm_set,
> +	.generation	= vm_generation,
> +	.get_status	= vm_get_status,
>  	.get_status	= vm_get_status,
>  	.set_status	= vm_set_status,
>  	.reset		= vm_reset,
> -- 
> MST

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
  2015-03-05 22:09 [PATCH] virtio_mmio: generation support Michael S. Tsirkin
  2015-03-09  8:40   ` Michael S. Tsirkin
  2015-03-12  2:07 ` Rusty Russell
@ 2015-03-12  2:07 ` Rusty Russell
  2015-03-23 11:50     ` Pawel Moll
  2 siblings, 1 reply; 8+ messages in thread
From: Rusty Russell @ 2015-03-12  2:07 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: virtualization, Pawel Moll

"Michael S. Tsirkin" <mst@redhat.com> writes:
> virtio_mmio currently lacks generation support which
> makes multi-byte field access racy.
> Fix by getting the value at offset 0xfc for version 2
> devices. Nothing we can do for version 1, so return
> generation id 0.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Pawel, you mentioned you have a working virtio 1.0
> hypervisor, can you pls confirm this works correctly?

I've applied this one, but fixed it to compile:

>  drivers/virtio/virtio_mmio.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 0375456..69b2e4d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  	}
>  }
>  
> +static u32 vm_generation(struct virtio_device *vdev)
> +{
> +	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> +
> +	if (vm_dev->version == 1)
> +		return 0;
> +	else
> +		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
> +}
> +
>  static u8 vm_get_status(struct virtio_device *vdev)
>  {
>  	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> @@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
>  static const struct virtio_config_ops virtio_mmio_config_ops = {
>  	.get		= vm_get,
>  	.set		= vm_set,
> +	.generation	= vm_generation,
> +	.get_status	= vm_get_status,
>  	.get_status	= vm_get_status,

See the double-assingment of get_status?

Thanks,
Rusty.
PS.  Sorry, that *does* actually compile.  I wish it didn't though...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
  2015-03-05 22:09 [PATCH] virtio_mmio: generation support Michael S. Tsirkin
  2015-03-09  8:40   ` Michael S. Tsirkin
@ 2015-03-12  2:07 ` Rusty Russell
  2015-03-12  2:07 ` Rusty Russell
  2 siblings, 0 replies; 8+ messages in thread
From: Rusty Russell @ 2015-03-12  2:07 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Pawel Moll, virtualization

"Michael S. Tsirkin" <mst@redhat.com> writes:
> virtio_mmio currently lacks generation support which
> makes multi-byte field access racy.
> Fix by getting the value at offset 0xfc for version 2
> devices. Nothing we can do for version 1, so return
> generation id 0.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Pawel, you mentioned you have a working virtio 1.0
> hypervisor, can you pls confirm this works correctly?

I've applied this one, but fixed it to compile:

>  drivers/virtio/virtio_mmio.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 0375456..69b2e4d 100644
> --- a/drivers/virtio/virtio_mmio.c
> +++ b/drivers/virtio/virtio_mmio.c
> @@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
>  	}
>  }
>  
> +static u32 vm_generation(struct virtio_device *vdev)
> +{
> +	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> +
> +	if (vm_dev->version == 1)
> +		return 0;
> +	else
> +		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
> +}
> +
>  static u8 vm_get_status(struct virtio_device *vdev)
>  {
>  	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
> @@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
>  static const struct virtio_config_ops virtio_mmio_config_ops = {
>  	.get		= vm_get,
>  	.set		= vm_set,
> +	.generation	= vm_generation,
> +	.get_status	= vm_get_status,
>  	.get_status	= vm_get_status,

See the double-assingment of get_status?

Thanks,
Rusty.
PS.  Sorry, that *does* actually compile.  I wish it didn't though...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
  2015-03-12  2:07 ` Rusty Russell
@ 2015-03-23 11:50     ` Pawel Moll
  0 siblings, 0 replies; 8+ messages in thread
From: Pawel Moll @ 2015-03-23 11:50 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Michael S. Tsirkin, linux-kernel, virtualization

On Thu, 2015-03-12 at 02:07 +0000, Rusty Russell wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> > virtio_mmio currently lacks generation support which
> > makes multi-byte field access racy.
> > Fix by getting the value at offset 0xfc for version 2
> > devices. Nothing we can do for version 1, so return
> > generation id 0.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > Pawel, you mentioned you have a working virtio 1.0
> > hypervisor, can you pls confirm this works correctly?

Again, belated

Acked-by: Pawel Moll <pawel.moll@arm.com>

although not yet tested-by...

Paweł


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] virtio_mmio: generation support
@ 2015-03-23 11:50     ` Pawel Moll
  0 siblings, 0 replies; 8+ messages in thread
From: Pawel Moll @ 2015-03-23 11:50 UTC (permalink / raw)
  To: Rusty Russell; +Cc: virtualization, linux-kernel, Michael S. Tsirkin

On Thu, 2015-03-12 at 02:07 +0000, Rusty Russell wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> > virtio_mmio currently lacks generation support which
> > makes multi-byte field access racy.
> > Fix by getting the value at offset 0xfc for version 2
> > devices. Nothing we can do for version 1, so return
> > generation id 0.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >
> > Pawel, you mentioned you have a working virtio 1.0
> > hypervisor, can you pls confirm this works correctly?

Again, belated

Acked-by: Pawel Moll <pawel.moll@arm.com>

although not yet tested-by...

Paweł

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] virtio_mmio: generation support
@ 2015-03-05 22:09 Michael S. Tsirkin
  0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2015-03-05 22:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: Pawel Moll, virtualization

virtio_mmio currently lacks generation support which
makes multi-byte field access racy.
Fix by getting the value at offset 0xfc for version 2
devices. Nothing we can do for version 1, so return
generation id 0.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Pawel, you mentioned you have a working virtio 1.0
hypervisor, can you pls confirm this works correctly?

 drivers/virtio/virtio_mmio.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
index 0375456..69b2e4d 100644
--- a/drivers/virtio/virtio_mmio.c
+++ b/drivers/virtio/virtio_mmio.c
@@ -237,6 +237,16 @@ static void vm_set(struct virtio_device *vdev, unsigned offset,
 	}
 }
 
+static u32 vm_generation(struct virtio_device *vdev)
+{
+	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
+
+	if (vm_dev->version == 1)
+		return 0;
+	else
+		return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
+}
+
 static u8 vm_get_status(struct virtio_device *vdev)
 {
 	struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
@@ -503,6 +513,8 @@ static const char *vm_bus_name(struct virtio_device *vdev)
 static const struct virtio_config_ops virtio_mmio_config_ops = {
 	.get		= vm_get,
 	.set		= vm_set,
+	.generation	= vm_generation,
+	.get_status	= vm_get_status,
 	.get_status	= vm_get_status,
 	.set_status	= vm_set_status,
 	.reset		= vm_reset,
-- 
MST

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-23 11:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 22:09 [PATCH] virtio_mmio: generation support Michael S. Tsirkin
2015-03-09  8:40 ` Michael S. Tsirkin
2015-03-09  8:40   ` Michael S. Tsirkin
2015-03-12  2:07 ` Rusty Russell
2015-03-12  2:07 ` Rusty Russell
2015-03-23 11:50   ` Pawel Moll
2015-03-23 11:50     ` Pawel Moll
2015-03-05 22:09 Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.