From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Jason Wang <jasowang@redhat.com>,
Dmitry Fleytman <dmitry@daynix.com>,
Scott Feldman <sfeldma@gmail.com>, Jiri Pirko <jiri@resnulli.us>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PATCH 2/5] hw/net/rtl8139.c: Don't use *_to_cpup()
Date: Thu, 16 Jun 2016 18:17:23 +0100 [thread overview]
Message-ID: <1466097446-981-3-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1466097446-981-1-git-send-email-peter.maydell@linaro.org>
Don't use *_to_cpup() to do byte-swapped loads; instead use
ld*_p() which correctly handle misaligned accesses.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/net/rtl8139.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 562c1fd..e2b140d 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -1013,8 +1013,8 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t
uint32_t rx_space = rxdw0 & CP_RX_BUFFER_SIZE_MASK;
/* write VLAN info to descriptor variables. */
- if (s->CpCmd & CPlusRxVLAN && be16_to_cpup((uint16_t *)
- &buf[ETH_ALEN * 2]) == ETH_P_VLAN) {
+ if (s->CpCmd & CPlusRxVLAN &&
+ lduw_be_p(&buf[ETH_ALEN * 2]) == ETH_P_VLAN) {
dot1q_buf = &buf[ETH_ALEN * 2];
size -= VLAN_HLEN;
/* if too small buffer, use the tailroom added duing expansion */
@@ -1024,11 +1024,10 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, const uint8_t *buf, size_t
rxdw1 &= ~CP_RX_VLAN_TAG_MASK;
/* BE + ~le_to_cpu()~ + cpu_to_le() = BE */
- rxdw1 |= CP_RX_TAVA | le16_to_cpup((uint16_t *)
- &dot1q_buf[ETHER_TYPE_LEN]);
+ rxdw1 |= CP_RX_TAVA | lduw_le_p(&dot1q_buf[ETHER_TYPE_LEN]);
DPRINTF("C+ Rx mode : extracted vlan tag with tci: ""%u\n",
- be16_to_cpup((uint16_t *)&dot1q_buf[ETHER_TYPE_LEN]));
+ lduw_be_p(&dot1q_buf[ETHER_TYPE_LEN]));
} else {
/* reset VLAN tag flag */
rxdw1 &= ~CP_RX_TAVA;
--
1.9.1
next prev parent reply other threads:[~2016-06-16 17:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 17:17 [Qemu-devel] [PATCH 0/5] hw/net: Don't use cpu_to_*w() and *_to_cpup() Peter Maydell
2016-06-16 17:17 ` [Qemu-devel] [PATCH 1/5] hw/net/eepro100.c: " Peter Maydell
2016-06-16 17:17 ` Peter Maydell [this message]
2016-06-16 17:17 ` [Qemu-devel] [PATCH 3/5] hw/net/rocker: Don't use *_to_cpup() Peter Maydell
2016-06-16 17:17 ` [Qemu-devel] [PATCH 4/5] hw/net/virtio-net.c: " Peter Maydell
2016-06-16 17:17 ` [Qemu-devel] [PATCH 5/5] hw/net/e1000: " Peter Maydell
2016-06-17 17:11 ` [Qemu-devel] [PATCH 0/5] hw/net: Don't use cpu_to_*w() and *_to_cpup() Richard Henderson
2016-06-20 2:45 ` Jason Wang
2016-06-20 7:19 ` Dmitry Fleytman
2016-06-27 16:04 ` Peter Maydell
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=1466097446-981-3-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=dmitry@daynix.com \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=mst@redhat.com \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sfeldma@gmail.com \
/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).