|
|
@ -1,14 +1,12 @@
|
|
|
|
From 3a1006355114da4b8fc4b935a64928b7f6ae374f Mon Sep 17 00:00:00 2001
|
|
|
|
From c7c1661d1b265ea620939bb5da4958eb0fb1385b Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
|
|
|
|
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
|
|
|
|
<marmarek@invisiblethingslab.com>
|
|
|
|
<marmarek@invisiblethingslab.com>
|
|
|
|
Date: Wed, 16 Dec 2015 05:09:55 +0100
|
|
|
|
Date: Wed, 16 Dec 2015 05:09:55 +0100
|
|
|
|
Subject: [PATCH 09/13] xen-netfront: copy response out of shared buffer before
|
|
|
|
Subject: [PATCH] xen-netfront: copy response out of shared buffer before
|
|
|
|
accessing it
|
|
|
|
accessing it
|
|
|
|
MIME-Version: 1.0
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Organization: Invisible Things Lab
|
|
|
|
|
|
|
|
Cc: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Make local copy of the response, otherwise backend might modify it while
|
|
|
|
Make local copy of the response, otherwise backend might modify it while
|
|
|
|
frontend is already processing it - leading to time of check / time of
|
|
|
|
frontend is already processing it - leading to time of check / time of
|
|
|
@ -16,14 +14,14 @@ use issue.
|
|
|
|
|
|
|
|
|
|
|
|
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
|
|
|
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
|
|
|
---
|
|
|
|
---
|
|
|
|
drivers/net/xen-netfront.c | 51 +++++++++++++++++++++++-----------------------
|
|
|
|
drivers/net/xen-netfront.c | 51 +++++++++++++++++++-------------------
|
|
|
|
1 file changed, 25 insertions(+), 26 deletions(-)
|
|
|
|
1 file changed, 25 insertions(+), 26 deletions(-)
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
|
|
|
|
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
|
|
|
|
index d6abf19..2af5100 100644
|
|
|
|
index 9dd2ca62d84a..1b6c319d74f1 100644
|
|
|
|
--- a/drivers/net/xen-netfront.c
|
|
|
|
--- a/drivers/net/xen-netfront.c
|
|
|
|
+++ b/drivers/net/xen-netfront.c
|
|
|
|
+++ b/drivers/net/xen-netfront.c
|
|
|
|
@@ -372,13 +372,13 @@ static void xennet_tx_buf_gc(struct netfront_queue *queue)
|
|
|
|
@@ -388,13 +388,13 @@ static void xennet_tx_buf_gc(struct netfront_queue *queue)
|
|
|
|
rmb(); /* Ensure we see responses up to 'rp'. */
|
|
|
|
rmb(); /* Ensure we see responses up to 'rp'. */
|
|
|
|
|
|
|
|
|
|
|
|
for (cons = queue->tx.rsp_cons; cons != prod; cons++) {
|
|
|
|
for (cons = queue->tx.rsp_cons; cons != prod; cons++) {
|
|
|
@ -41,7 +39,7 @@ index d6abf19..2af5100 100644
|
|
|
|
skb = queue->tx_skbs[id].skb;
|
|
|
|
skb = queue->tx_skbs[id].skb;
|
|
|
|
if (unlikely(gnttab_query_foreign_access(
|
|
|
|
if (unlikely(gnttab_query_foreign_access(
|
|
|
|
queue->grant_tx_ref[id]) != 0)) {
|
|
|
|
queue->grant_tx_ref[id]) != 0)) {
|
|
|
|
@@ -721,7 +721,7 @@ static int xennet_get_extras(struct netfront_queue *queue,
|
|
|
|
@@ -742,7 +742,7 @@ static int xennet_get_extras(struct netfront_queue *queue,
|
|
|
|
RING_IDX rp)
|
|
|
|
RING_IDX rp)
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -50,7 +48,7 @@ index d6abf19..2af5100 100644
|
|
|
|
struct device *dev = &queue->info->netdev->dev;
|
|
|
|
struct device *dev = &queue->info->netdev->dev;
|
|
|
|
RING_IDX cons = queue->rx.rsp_cons;
|
|
|
|
RING_IDX cons = queue->rx.rsp_cons;
|
|
|
|
int err = 0;
|
|
|
|
int err = 0;
|
|
|
|
@@ -737,24 +737,23 @@ static int xennet_get_extras(struct netfront_queue *queue,
|
|
|
|
@@ -758,24 +758,23 @@ static int xennet_get_extras(struct netfront_queue *queue,
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -82,7 +80,7 @@ index d6abf19..2af5100 100644
|
|
|
|
|
|
|
|
|
|
|
|
queue->rx.rsp_cons = cons;
|
|
|
|
queue->rx.rsp_cons = cons;
|
|
|
|
return err;
|
|
|
|
return err;
|
|
|
|
@@ -764,28 +763,28 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
@@ -785,28 +784,28 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
struct netfront_rx_info *rinfo, RING_IDX rp,
|
|
|
|
struct netfront_rx_info *rinfo, RING_IDX rp,
|
|
|
|
struct sk_buff_head *list)
|
|
|
|
struct sk_buff_head *list)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -93,8 +91,8 @@ index d6abf19..2af5100 100644
|
|
|
|
RING_IDX cons = queue->rx.rsp_cons;
|
|
|
|
RING_IDX cons = queue->rx.rsp_cons;
|
|
|
|
struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
|
|
|
|
struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
|
|
|
|
grant_ref_t ref = xennet_get_rx_ref(queue, cons);
|
|
|
|
grant_ref_t ref = xennet_get_rx_ref(queue, cons);
|
|
|
|
- int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
|
|
|
|
- int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);
|
|
|
|
+ int max = MAX_SKB_FRAGS + (rx.status <= RX_COPY_THRESHOLD);
|
|
|
|
+ int max = XEN_NETIF_NR_SLOTS_MIN + (rx.status <= RX_COPY_THRESHOLD);
|
|
|
|
int slots = 1;
|
|
|
|
int slots = 1;
|
|
|
|
int err = 0;
|
|
|
|
int err = 0;
|
|
|
|
unsigned long ret;
|
|
|
|
unsigned long ret;
|
|
|
@ -117,7 +115,7 @@ index d6abf19..2af5100 100644
|
|
|
|
xennet_move_rx_slot(queue, skb, ref);
|
|
|
|
xennet_move_rx_slot(queue, skb, ref);
|
|
|
|
err = -EINVAL;
|
|
|
|
err = -EINVAL;
|
|
|
|
goto next;
|
|
|
|
goto next;
|
|
|
|
@@ -799,7 +798,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
@@ -820,7 +819,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
if (ref == GRANT_INVALID_REF) {
|
|
|
|
if (ref == GRANT_INVALID_REF) {
|
|
|
|
if (net_ratelimit())
|
|
|
|
if (net_ratelimit())
|
|
|
|
dev_warn(dev, "Bad rx response id %d.\n",
|
|
|
|
dev_warn(dev, "Bad rx response id %d.\n",
|
|
|
@ -126,7 +124,7 @@ index d6abf19..2af5100 100644
|
|
|
|
err = -EINVAL;
|
|
|
|
err = -EINVAL;
|
|
|
|
goto next;
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -812,7 +811,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
@@ -833,7 +832,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
__skb_queue_tail(list, skb);
|
|
|
|
__skb_queue_tail(list, skb);
|
|
|
|
|
|
|
|
|
|
|
|
next:
|
|
|
|
next:
|
|
|
@ -135,7 +133,7 @@ index d6abf19..2af5100 100644
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
if (cons + slots == rp) {
|
|
|
|
if (cons + slots == rp) {
|
|
|
|
@@ -822,7 +821,7 @@ next:
|
|
|
|
@@ -843,7 +842,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -144,7 +142,7 @@ index d6abf19..2af5100 100644
|
|
|
|
skb = xennet_get_rx_skb(queue, cons + slots);
|
|
|
|
skb = xennet_get_rx_skb(queue, cons + slots);
|
|
|
|
ref = xennet_get_rx_ref(queue, cons + slots);
|
|
|
|
ref = xennet_get_rx_ref(queue, cons + slots);
|
|
|
|
slots++;
|
|
|
|
slots++;
|
|
|
|
@@ -878,9 +877,9 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
|
|
|
|
@@ -898,9 +897,9 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
|
|
|
|
struct sk_buff *nskb;
|
|
|
|
struct sk_buff *nskb;
|
|
|
|
|
|
|
|
|
|
|
|
while ((nskb = __skb_dequeue(list))) {
|
|
|
|
while ((nskb = __skb_dequeue(list))) {
|
|
|
@ -154,18 +152,18 @@ index d6abf19..2af5100 100644
|
|
|
|
skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];
|
|
|
|
skb_frag_t *nfrag = &skb_shinfo(nskb)->frags[0];
|
|
|
|
+ RING_COPY_RESPONSE(&queue->rx, ++cons, &rx);
|
|
|
|
+ RING_COPY_RESPONSE(&queue->rx, ++cons, &rx);
|
|
|
|
|
|
|
|
|
|
|
|
if (shinfo->nr_frags == MAX_SKB_FRAGS) {
|
|
|
|
if (skb_shinfo(skb)->nr_frags == MAX_SKB_FRAGS) {
|
|
|
|
unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
|
|
|
|
unsigned int pull_to = NETFRONT_SKB_CB(skb)->pull_to;
|
|
|
|
@@ -891,7 +890,7 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
|
|
|
|
@@ -912,7 +911,7 @@ static RING_IDX xennet_fill_frags(struct netfront_queue *queue,
|
|
|
|
BUG_ON(shinfo->nr_frags >= MAX_SKB_FRAGS);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
skb_add_rx_frag(skb, shinfo->nr_frags, skb_frag_page(nfrag),
|
|
|
|
skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
|
|
|
|
|
|
|
|
skb_frag_page(nfrag),
|
|
|
|
- rx->offset, rx->status, PAGE_SIZE);
|
|
|
|
- rx->offset, rx->status, PAGE_SIZE);
|
|
|
|
+ rx.offset, rx.status, PAGE_SIZE);
|
|
|
|
+ rx.offset, rx.status, PAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
|
|
skb_shinfo(nskb)->nr_frags = 0;
|
|
|
|
skb_shinfo(nskb)->nr_frags = 0;
|
|
|
|
kfree_skb(nskb);
|
|
|
|
kfree_skb(nskb);
|
|
|
|
@@ -987,7 +986,7 @@ static int xennet_poll(struct napi_struct *napi, int budget)
|
|
|
|
@@ -1008,7 +1007,7 @@ static int xennet_poll(struct napi_struct *napi, int budget)
|
|
|
|
i = queue->rx.rsp_cons;
|
|
|
|
i = queue->rx.rsp_cons;
|
|
|
|
work_done = 0;
|
|
|
|
work_done = 0;
|
|
|
|
while ((i != rp) && (work_done < budget)) {
|
|
|
|
while ((i != rp) && (work_done < budget)) {
|
|
|
@ -175,5 +173,5 @@ index d6abf19..2af5100 100644
|
|
|
|
|
|
|
|
|
|
|
|
err = xennet_get_responses(queue, &rinfo, rp, &tmpq);
|
|
|
|
err = xennet_get_responses(queue, &rinfo, rp, &tmpq);
|
|
|
|
--
|
|
|
|
--
|
|
|
|
2.1.0
|
|
|
|
2.17.1
|
|
|
|
|
|
|
|
|
|
|
|