stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_balloon: fix up endian-ness for free cmd id
@ 2020-07-27 16:03 Michael S. Tsirkin
  2020-07-27 16:56 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-07-27 16:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: stable, David Hildenbrand, Jason Wang, Liang Li, Wei Wang,
	virtualization, Alexander Duyck

free cmd id is read using virtio endian, spec says all fields
in balloon are LE. Fix it up.

Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/virtio/virtio_balloon.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 774deb65a9bb..798ec304fe3e 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
 static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
 {
 	if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
-			       &vb->config_read_bitmap))
+			       &vb->config_read_bitmap)) {
 		virtio_cread(vb->vdev, struct virtio_balloon_config,
 			     free_page_hint_cmd_id,
 			     &vb->cmd_id_received_cache);
+		/* Legacy balloon config space is LE, unlike all other devices. */
+		if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
+			vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
+	}
 
 	return vb->cmd_id_received_cache;
 }
-- 
MST


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

* Re: [PATCH] virtio_balloon: fix up endian-ness for free cmd id
  2020-07-27 16:03 [PATCH] virtio_balloon: fix up endian-ness for free cmd id Michael S. Tsirkin
@ 2020-07-27 16:56 ` David Hildenbrand
  2020-07-28  6:37 ` Wei Wang
  2020-07-29  9:33 ` Jason Wang
  2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2020-07-27 16:56 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: stable, Jason Wang, Liang Li, Wei Wang, virtualization, Alexander Duyck

On 27.07.20 18:03, Michael S. Tsirkin wrote:
> free cmd id is read using virtio endian, spec says all fields
> in balloon are LE. Fix it up.
> 
> Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/virtio/virtio_balloon.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 774deb65a9bb..798ec304fe3e 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
>  static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
>  {
>  	if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
> -			       &vb->config_read_bitmap))
> +			       &vb->config_read_bitmap)) {
>  		virtio_cread(vb->vdev, struct virtio_balloon_config,
>  			     free_page_hint_cmd_id,
>  			     &vb->cmd_id_received_cache);
> +		/* Legacy balloon config space is LE, unlike all other devices. */
> +		if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
> +			vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
> +	}
>  
>  	return vb->cmd_id_received_cache;
>  }
> 

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH] virtio_balloon: fix up endian-ness for free cmd id
  2020-07-27 16:03 [PATCH] virtio_balloon: fix up endian-ness for free cmd id Michael S. Tsirkin
  2020-07-27 16:56 ` David Hildenbrand
@ 2020-07-28  6:37 ` Wei Wang
  2020-07-29  9:33 ` Jason Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Wei Wang @ 2020-07-28  6:37 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: stable, David Hildenbrand, Jason Wang, Liang Li, virtualization,
	Alexander Duyck

On 07/28/2020 12:03 AM, Michael S. Tsirkin wrote:
> free cmd id is read using virtio endian, spec says all fields
> in balloon are LE. Fix it up.
>
> Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   drivers/virtio/virtio_balloon.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 774deb65a9bb..798ec304fe3e 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
>   static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
>   {
>   	if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
> -			       &vb->config_read_bitmap))
> +			       &vb->config_read_bitmap)) {
>   		virtio_cread(vb->vdev, struct virtio_balloon_config,
>   			     free_page_hint_cmd_id,
>   			     &vb->cmd_id_received_cache);
> +		/* Legacy balloon config space is LE, unlike all other devices. */
> +		if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
> +			vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
Seems it exceeds 80 character length.

Reviewed-by: Wei Wang <wei.w.wang@intel.com>

Best,
Wei

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

* Re: [PATCH] virtio_balloon: fix up endian-ness for free cmd id
  2020-07-27 16:03 [PATCH] virtio_balloon: fix up endian-ness for free cmd id Michael S. Tsirkin
  2020-07-27 16:56 ` David Hildenbrand
  2020-07-28  6:37 ` Wei Wang
@ 2020-07-29  9:33 ` Jason Wang
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2020-07-29  9:33 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel
  Cc: stable, David Hildenbrand, Liang Li, Wei Wang, virtualization,
	Alexander Duyck


On 2020/7/28 上午12:03, Michael S. Tsirkin wrote:
> free cmd id is read using virtio endian, spec says all fields
> in balloon are LE. Fix it up.
>
> Fixes: 86a559787e6f ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT")
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>   drivers/virtio/virtio_balloon.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 774deb65a9bb..798ec304fe3e 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -578,10 +578,14 @@ static int init_vqs(struct virtio_balloon *vb)
>   static u32 virtio_balloon_cmd_id_received(struct virtio_balloon *vb)
>   {
>   	if (test_and_clear_bit(VIRTIO_BALLOON_CONFIG_READ_CMD_ID,
> -			       &vb->config_read_bitmap))
> +			       &vb->config_read_bitmap)) {
>   		virtio_cread(vb->vdev, struct virtio_balloon_config,
>   			     free_page_hint_cmd_id,
>   			     &vb->cmd_id_received_cache);
> +		/* Legacy balloon config space is LE, unlike all other devices. */
> +		if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1))
> +			vb->cmd_id_received_cache = le32_to_cpu((__force __le32)vb->cmd_id_received_cache);
> +	}
>   
>   	return vb->cmd_id_received_cache;
>   }


Acked-by: Jason Wang <jasowang@redhat.com>



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

end of thread, other threads:[~2020-07-29  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 16:03 [PATCH] virtio_balloon: fix up endian-ness for free cmd id Michael S. Tsirkin
2020-07-27 16:56 ` David Hildenbrand
2020-07-28  6:37 ` Wei Wang
2020-07-29  9:33 ` Jason Wang

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).