virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Subject: [PATCH 2/6] virtio_config: fix virtio_cread_bytes
Date: Mon, 15 Dec 2014 23:23:12 +0200	[thread overview]
Message-ID: <1418678575-31755-3-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1418678575-31755-1-git-send-email-mst@redhat.com>

virtio_cread_bytes is implemented incorrectly in case length happens to
be 2,4 or 8 bytes: transports and devices will assume it's an integer
value that has to be converted to LE format.

Let's just do multiple 1-byte reads: this also makes life easier
for transports who only need to implement 1,2,4 and 8 byte reads.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/linux/virtio_config.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 7979f85..a61cd37 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -305,7 +305,10 @@ static inline void virtio_cread_bytes(struct virtio_device *vdev,
 				      unsigned int offset,
 				      void *buf, size_t len)
 {
-	vdev->config->get(vdev, offset, buf, len);
+	int i;
+
+	for (i = 0; i < len; i++)
+		vdev->config->get(vdev, offset + i, buf + i, 1);
 }
 
 static inline void virtio_cwrite8(struct virtio_device *vdev,
-- 
MST

  parent reply	other threads:[~2014-12-15 21:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 21:23 [PATCH 0/6] virtio 1.0 fixups, tweaks Michael S. Tsirkin
2014-12-15 21:23 ` [PATCH 1/6] virtio: set VIRTIO_CONFIG_S_FEATURES_OK on restore Michael S. Tsirkin
2014-12-15 21:23 ` Michael S. Tsirkin [this message]
2014-12-15 21:23 ` [PATCH 3/6] virtio_pci_common.h: drop VIRTIO_PCI_NO_LEGACY Michael S. Tsirkin
2014-12-15 21:23 ` [PATCH 4/6] virtio_pci: move probe to common file Michael S. Tsirkin
2014-12-15 21:23 ` [PATCH 5/6] virtio_pci: add VIRTIO_PCI_NO_LEGACY Michael S. Tsirkin
2014-12-15 21:23 ` [PATCH 6/6] virtio: core support for config generation Michael S. Tsirkin
2014-12-19  1:26 ` [PATCH 0/6] virtio 1.0 fixups, tweaks Rusty Russell
     [not found] ` <1418678575-31755-7-git-send-email-mst@redhat.com>
2014-12-19  3:01   ` [PATCH 6/6] virtio: core support for config generation Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418678575-31755-3-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).