a2554c7166a300adf7a7f33d6607bcef49a5b8ab
[openwrt/staging/ldir.git] /
1 From dd462c6eb2ba6af01ae38644183216c4d5603d90 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] ivshmem-net: Switch to relative descriptor addresses
5
6 Make sure that we do not depend on identity-mapped shared memory
7 regions.
8
9 This also fixes an off-by-one in the range check of ivshm_net_desc_data.
10
11 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 (cherry picked from commit fe9c9dd6373892591a7d6b165c3c43045eb349c1)
13 ---
14 drivers/net/ivshmem-net.c | 8 ++++----
15 1 file changed, 4 insertions(+), 4 deletions(-)
16
17 --- a/drivers/net/ivshmem-net.c
18 +++ b/drivers/net/ivshmem-net.c
19 @@ -123,14 +123,14 @@ static void *ivshm_net_desc_data(struct
20 struct vring_desc *desc,
21 u32 *len)
22 {
23 - u64 addr = READ_ONCE(desc->addr);
24 + u64 offs = READ_ONCE(desc->addr);
25 u32 dlen = READ_ONCE(desc->len);
26 void *data;
27
28 - if (addr < in->shmaddr || desc->addr > in->shmaddr + in->shmlen)
29 + if (offs >= in->shmlen)
30 return NULL;
31
32 - data = in->shm + (addr - in->shmaddr);
33 + data = in->shm + offs;
34
35 if (data < q->data || data >= q->end)
36 return NULL;
37 @@ -317,7 +317,7 @@ static int ivshm_net_tx_frame(struct net
38 buf = tx->data + head;
39 skb_copy_and_csum_dev(skb, buf);
40
41 - desc->addr = in->shmaddr + (buf - in->shm);
42 + desc->addr = buf - in->shm;
43 desc->len = skb->len;
44
45 avail = tx->last_avail_idx++ & (vr->num - 1);