From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb1d-0006GS-Pp for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:24:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDb1c-0000rX-SB for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:24:17 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:57856) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDb1c-0000rQ-L6 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:24:16 -0400 From: Peter Maydell Date: Thu, 16 Jun 2016 18:17:23 +0100 Message-Id: <1466097446-981-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1466097446-981-1-git-send-email-peter.maydell@linaro.org> References: <1466097446-981-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH 2/5] hw/net/rtl8139.c: Don't use *_to_cpup() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org, Jason Wang , Dmitry Fleytman , Scott Feldman , Jiri Pirko , "Michael S. Tsirkin" Don't use *_to_cpup() to do byte-swapped loads; instead use ld*_p() which correctly handle misaligned accesses. Signed-off-by: Peter Maydell --- 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