1 From d1a0011e9857e105e38d9a0ea6fd7b8e7e6d8dc9 Mon Sep 17 00:00:00 2001
2 From: Jan Kiszka <jan.kiszka@siemens.com>
3 Date: Tue, 3 Jan 2017 08:50:01 +0100
4 Subject: [PATCH 22/32] ivshmem-net: Switch to relative descriptor addresses
6 Make sure that we do not depend on identity-mapped shared memory
9 This also fixes an off-by-one in the range check of ivshm_net_desc_data.
11 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 drivers/net/ivshmem-net.c | 8 ++++----
14 1 file changed, 4 insertions(+), 4 deletions(-)
16 diff --git a/drivers/net/ivshmem-net.c b/drivers/net/ivshmem-net.c
17 index 9f307ec4d677..0e770ca293a4 100644
18 --- a/drivers/net/ivshmem-net.c
19 +++ b/drivers/net/ivshmem-net.c
20 @@ -123,14 +123,14 @@ static void *ivshm_net_desc_data(struct ivshm_net *in,
21 struct vring_desc *desc,
24 - u64 addr = READ_ONCE(desc->addr);
25 + u64 offs = READ_ONCE(desc->addr);
26 u32 dlen = READ_ONCE(desc->len);
29 - if (addr < in->shmaddr || desc->addr > in->shmaddr + in->shmlen)
30 + if (offs >= in->shmlen)
33 - data = in->shm + (addr - in->shmaddr);
34 + data = in->shm + offs;
36 if (data < q->data || data >= q->end)
38 @@ -317,7 +317,7 @@ static int ivshm_net_tx_frame(struct net_device *ndev, struct sk_buff *skb)
39 buf = tx->data + head;
40 skb_copy_and_csum_dev(skb, buf);
42 - desc->addr = in->shmaddr + (buf - in->shm);
43 + desc->addr = buf - in->shm;
46 avail = tx->last_avail_idx++ & (vr->num - 1);