From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH 2/4] Endian fix an assertion in usb-msd
Date: Tue, 13 Mar 2012 15:22:42 +1100 [thread overview]
Message-ID: <1331612562.3105.96.camel@pasglop> (raw)
In-Reply-To: <4F59FBA6.9070805@redhat.com>
On Fri, 2012-03-09 at 13:46 +0100, Gerd Hoffmann wrote:
> On 03/08/12 01:41, David Gibson wrote:
> > From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> > - assert(s->csw.sig == 0x53425355);
> > + assert(s->csw.sig == cpu_to_le32(0x53425355));
>
> Correct but incomplete. residue is sent in host endian instead of
> little endian too. It is zero most of the time though, so it easily
> goes unnoticed.
>
> Can you try the attached patch instead?
I dislike the patch as it does an in-place swap of the structure. I tend
to prefer a given structure to have a known endian, never change in
place. For example it would make it harder to ever implement endian
annotations like the kernel does (to have sparse find the bugs for us).
As such I would rather fix the access locations instead. This basically
means adding this small patch on top of my previous one (I haven't
spotted any other error) :
diff --git a/hw/usb-msd.c b/hw/usb-msd.c
index c18e76d..d5d7f74 100644
--- a/hw/usb-msd.c
+++ b/hw/usb-msd.c
@@ -193,7 +193,7 @@ static void usb_msd_send_status(MSDState *s, USBPacket *p)
int len;
DPRINTF("Command status %d tag 0x%x, len %zd\n",
- s->csw.status, s->csw.tag, p->iov.size);
+ s->csw.status, le32_to_cpu(s->csw.tag), p->iov.size);
assert(s->csw.sig == cpu_to_le32(0x53425355));
len = MIN(sizeof(s->csw), p->iov.size);
@@ -233,7 +233,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r
s->csw.sig = cpu_to_le32(0x53425355);
s->csw.tag = cpu_to_le32(req->tag);
- s->csw.residue = s->residue;
+ s->csw.residue = cpu_to_le32(s->residue);
s->csw.status = status != 0;
if (s->packet) {
next prev parent reply other threads:[~2012-03-13 4:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[0/4] RESEND: Outstanding bugfixes and cleanups>
2012-03-08 0:41 ` [Qemu-devel] (no subject) David Gibson
2012-03-08 0:41 ` [Qemu-devel] [PATCH 1/4] kvm: Comparison with ioctl number macros needs to be unsigned David Gibson
2012-03-12 22:13 ` Alexander Graf
2012-03-08 0:41 ` [Qemu-devel] [PATCH 2/4] Endian fix an assertion in usb-msd David Gibson
2012-03-09 12:46 ` Gerd Hoffmann
2012-03-13 4:22 ` Benjamin Herrenschmidt [this message]
2012-03-13 9:57 ` Gerd Hoffmann
2012-03-13 10:43 ` Benjamin Herrenschmidt
2012-03-13 10:44 ` David Gibson
2012-03-08 0:41 ` [Qemu-devel] [PATCH 3/4] kvm: Fix dirty tracking with large kernel page size David Gibson
2012-03-08 0:41 ` [Qemu-devel] [PATCH 4/4] pci: Factor out bounds checking on config space accesses David Gibson
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=1331612562.3105.96.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=anthony@codemonkey.ws \
--cc=david@gibson.dropbear.id.au \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.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).