From 7542d3e706732f1d26713a26d8d7cd61f675b1d9 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 16 Jun 2016 18:17:25 +0100 Subject: [PATCH] hw/net/virtio-net.c: Don't use *_to_cpup() Don't use *_to_cpup() to do byte-swapped loads; instead use ld*_p() which correctly handle misaligned accesses. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Acked-by: Jason Wang Acked-by: Dmitry Fleytman > Message-id: 1466097446-981-5-git-send-email-peter.maydell@linaro.org --- hw/net/virtio-net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5798f87..7e6a60a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1051,7 +1051,7 @@ static int receive_filter(VirtIONet *n, const uint8_t *buf, int size) ptr += n->host_hdr_len; if (!memcmp(&ptr[12], vlan, sizeof(vlan))) { - int vid = be16_to_cpup((uint16_t *)(ptr + 14)) & 0xfff; + int vid = lduw_be_p(ptr + 14) & 0xfff; if (!(n->vlans[vid >> 5] & (1U << (vid & 0x1f)))) return 0; } -- 2.7.4