Skip to content

Commit

Permalink
e1000: fix unaligned access
Browse files Browse the repository at this point in the history
(Tristan Gingold)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4121 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
aurel32 committed Mar 28, 2008
1 parent f94f718 commit 88738c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ CPU_CONVERT(le, 64, uint64_t)
#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)
Expand Down Expand Up @@ -168,6 +169,12 @@ static inline uint32_t le32_to_cpupu(const uint32_t *p)
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;
Expand Down
2 changes: 1 addition & 1 deletion hw/e1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ xmit_seg(E1000State *s)
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
Expand Down

0 comments on commit 88738c0

Please sign in to comment.