From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jf3al-0005zE-7G for qemu-devel@nongnu.org; Thu, 27 Mar 2008 21:41:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jf3aj-0005yM-5N for qemu-devel@nongnu.org; Thu, 27 Mar 2008 21:41:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jf3ai-0005yF-UO for qemu-devel@nongnu.org; Thu, 27 Mar 2008 21:41:12 -0400 Received: from smtp6-g19.free.fr ([212.27.42.36]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jf3ai-0001Ki-JR for qemu-devel@nongnu.org; Thu, 27 Mar 2008 21:41:12 -0400 Date: Fri, 28 Mar 2008 02:48:58 +0100 Subject: Re: [Qemu-devel] patch: e1000: fix unaligned access Message-ID: <20080328014858.GA2609@saphi> References: <1206633582.47ebc46ee1513@imp.free.fr> <1206665796.4586.4.camel@frecb07144> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline In-Reply-To: <1206665796.4586.4.camel@frecb07144> From: Tristan Gingold Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: Tristan Gingold , qemu-devel@nongnu.org --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="e1000-unalign.diff" --- /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 --x+6KMIRAuhnl3hBn--