qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Tristan Gingold <tgingold@free.fr>
To: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: Tristan Gingold <tgingold@free.fr>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] patch: e1000: fix unaligned access
Date: Fri, 28 Mar 2008 02:48:58 +0100	[thread overview]
Message-ID: <20080328014858.GA2609@saphi> (raw)
In-Reply-To: <1206665796.4586.4.camel@frecb07144>

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

On Fri, Mar 28, 2008 at 01:56:36AM +0100, Laurent Vivier wrote:
> > +#define be32_to_cpupu(p) le32_to_cpup(p)
> 
> should be "#define be32_to_cpupu(p) be32_to_cpup(p)" ?

Yes, thank you for the catch.  I didn't submit the right patch.  So here
is the correct one.

Tristan.

[-- Attachment #2: e1000-unalign.diff --]
[-- Type: text/plain, Size: 1319 bytes --]

--- /home/gingold/src/qemu/bswap.h	2007-09-16 23:07:48.000000000 +0200
+++ qemu/bswap.h	2008-03-18 06:46:23.000000000 +0100
@@ -132,6 +132,7 @@
 #define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
 #define le16_to_cpupu(p) le16_to_cpup(p)
 #define le32_to_cpupu(p) le32_to_cpup(p)
+#define be32_to_cpupu(p) be32_to_cpup(p)
 
 #define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
 #define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
@@ -168,6 +169,12 @@
     return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
 }
 
+static inline uint32_t be32_to_cpupu(const uint32_t *p)
+{
+    const uint8_t *p1 = (const uint8_t *)p;
+    return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24);
+}
+
 static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
 {
     uint8_t *p1 = (uint8_t *)p;
--- /home/gingold/src/qemu/hw/e1000.c	2008-03-13 20:18:26.000000000 +0100
+++ qemu/hw/e1000.c	2008-03-27 07:11:48.000000000 +0100
@@ -326,7 +326,7 @@
         if (tp->tcp) {
             sofar = frames * tp->mss;
             cpu_to_be32wu((uint32_t *)(tp->data+css+4),	// seq
-                be32_to_cpup((uint32_t *)(tp->data+css+4))+sofar);
+                be32_to_cpupu((uint32_t *)(tp->data+css+4))+sofar);
             if (tp->paylen - sofar > tp->mss)
                 tp->data[css + 13] &= ~9;		// PSH, FIN
         } else	// UDP

      reply	other threads:[~2008-03-28  1:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-27 15:59 [Qemu-devel] patch: e1000: fix unaligned access tgingold
2008-03-28  0:56 ` Laurent Vivier
2008-03-28  1:48   ` Tristan Gingold [this message]

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=20080328014858.GA2609@saphi \
    --to=tgingold@free.fr \
    --cc=Laurent.Vivier@bull.net \
    --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).