get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/53810/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 53810,
    "url": "http://patches.dpdk.org/api/patches/53810/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20190529130420.6428-4-maxime.coquelin@redhat.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20190529130420.6428-4-maxime.coquelin@redhat.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20190529130420.6428-4-maxime.coquelin@redhat.com",
    "date": "2019-05-29T13:04:18",
    "name": "[v3,3/5] vhost: do not inline unlikely fragmented buffers code",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "a04abf0772e7f99b2a8dd994f5905a08a369eef9",
    "submitter": {
        "id": 512,
        "url": "http://patches.dpdk.org/api/people/512/?format=api",
        "name": "Maxime Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20190529130420.6428-4-maxime.coquelin@redhat.com/mbox/",
    "series": [
        {
            "id": 4809,
            "url": "http://patches.dpdk.org/api/series/4809/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4809",
            "date": "2019-05-29T13:04:15",
            "name": "vhost: I-cache pressure optimizations",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/4809/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/53810/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/53810/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 6FA9B1B9B8;\n\tWed, 29 May 2019 15:05:17 +0200 (CEST)",
            "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby dpdk.org (Postfix) with ESMTP id B96B41B9AF\n\tfor <dev@dpdk.org>; Wed, 29 May 2019 15:05:13 +0200 (CEST)",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 36EC2C075BC4;\n\tWed, 29 May 2019 13:05:02 +0000 (UTC)",
            "from localhost.localdomain (ovpn-112-24.ams2.redhat.com\n\t[10.36.112.24])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id C555F6149A;\n\tWed, 29 May 2019 13:04:57 +0000 (UTC)"
        ],
        "From": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "To": "dev@dpdk.org, tiwei.bie@intel.com, david.marchand@redhat.com,\n\tjfreimann@redhat.com, bruce.richardson@intel.com,\n\tzhihong.wang@intel.com, \n\tkonstantin.ananyev@intel.com, mattias.ronnblom@ericsson.com",
        "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Wed, 29 May 2019 15:04:18 +0200",
        "Message-Id": "<20190529130420.6428-4-maxime.coquelin@redhat.com>",
        "In-Reply-To": "<20190529130420.6428-1-maxime.coquelin@redhat.com>",
        "References": "<20190529130420.6428-1-maxime.coquelin@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]); Wed, 29 May 2019 13:05:08 +0000 (UTC)",
        "Subject": "[dpdk-dev] [PATCH v3 3/5] vhost: do not inline unlikely fragmented\n\tbuffers code",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Handling of fragmented virtio-net header and indirect descriptors\ntables was implemented to fix CVE-2018-1059. It should never\nhappen with healthy guests and so is already considered as\nunlikely code path.\n\nThis patch moves these bits into non-inline dedicated functions\nto reduce the I-cache pressure.\n\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\nReviewed-by: Tiwei Bie <tiwei.bie@intel.com>\n---\n lib/librte_vhost/vdpa.c       |   2 +-\n lib/librte_vhost/vhost.c      |  33 +++++++++++\n lib/librte_vhost/vhost.h      |  36 +-----------\n lib/librte_vhost/virtio_net.c | 100 +++++++++++++++++++---------------\n 4 files changed, 93 insertions(+), 78 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c\nindex e915488432..24a6698e91 100644\n--- a/lib/librte_vhost/vdpa.c\n+++ b/lib/librte_vhost/vdpa.c\n@@ -181,7 +181,7 @@ rte_vdpa_relay_vring_used(int vid, uint16_t qid, void *vring_m)\n \t\t\t\treturn -1;\n \n \t\t\tif (unlikely(dlen < vq->desc[desc_id].len)) {\n-\t\t\t\tidesc = alloc_copy_ind_table(dev, vq,\n+\t\t\t\tidesc = vhost_alloc_copy_ind_table(dev, vq,\n \t\t\t\t\t\tvq->desc[desc_id].addr,\n \t\t\t\t\t\tvq->desc[desc_id].len);\n \t\t\t\tif (unlikely(!idesc))\ndiff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c\nindex 7d427b60a5..981837b5dd 100644\n--- a/lib/librte_vhost/vhost.c\n+++ b/lib/librte_vhost/vhost.c\n@@ -200,6 +200,39 @@ __vhost_log_cache_write(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t}\n }\n \n+void *\n+vhost_alloc_copy_ind_table(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\t\tuint64_t desc_addr, uint64_t desc_len)\n+{\n+\tvoid *idesc;\n+\tuint64_t src, dst;\n+\tuint64_t len, remain = desc_len;\n+\n+\tidesc = rte_malloc(__func__, desc_len, 0);\n+\tif (unlikely(!idesc))\n+\t\treturn NULL;\n+\n+\tdst = (uint64_t)(uintptr_t)idesc;\n+\n+\twhile (remain) {\n+\t\tlen = remain;\n+\t\tsrc = vhost_iova_to_vva(dev, vq, desc_addr, &len,\n+\t\t\t\tVHOST_ACCESS_RO);\n+\t\tif (unlikely(!src || !len)) {\n+\t\t\trte_free(idesc);\n+\t\t\treturn NULL;\n+\t\t}\n+\n+\t\trte_memcpy((void *)(uintptr_t)dst, (void *)(uintptr_t)src, len);\n+\n+\t\tremain -= len;\n+\t\tdst += len;\n+\t\tdesc_addr += len;\n+\t}\n+\n+\treturn idesc;\n+}\n+\n void\n cleanup_vq(struct vhost_virtqueue *vq, int destroy)\n {\ndiff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h\nindex 3ab7b4950f..691f535530 100644\n--- a/lib/librte_vhost/vhost.h\n+++ b/lib/librte_vhost/vhost.h\n@@ -488,6 +488,9 @@ void vhost_backend_cleanup(struct virtio_net *dev);\n \n uint64_t __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\tuint64_t iova, uint64_t *len, uint8_t perm);\n+void *vhost_alloc_copy_ind_table(struct virtio_net *dev,\n+\t\t\tstruct vhost_virtqueue *vq,\n+\t\t\tuint64_t desc_addr, uint64_t desc_len);\n int vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq);\n void vring_invalidate(struct virtio_net *dev, struct vhost_virtqueue *vq);\n \n@@ -601,39 +604,6 @@ vhost_vring_call_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)\n \t\teventfd_write(vq->callfd, (eventfd_t)1);\n }\n \n-static __rte_always_inline void *\n-alloc_copy_ind_table(struct virtio_net *dev, struct vhost_virtqueue *vq,\n-\t\tuint64_t desc_addr, uint64_t desc_len)\n-{\n-\tvoid *idesc;\n-\tuint64_t src, dst;\n-\tuint64_t len, remain = desc_len;\n-\n-\tidesc = rte_malloc(__func__, desc_len, 0);\n-\tif (unlikely(!idesc))\n-\t\treturn 0;\n-\n-\tdst = (uint64_t)(uintptr_t)idesc;\n-\n-\twhile (remain) {\n-\t\tlen = remain;\n-\t\tsrc = vhost_iova_to_vva(dev, vq, desc_addr, &len,\n-\t\t\t\tVHOST_ACCESS_RO);\n-\t\tif (unlikely(!src || !len)) {\n-\t\t\trte_free(idesc);\n-\t\t\treturn 0;\n-\t\t}\n-\n-\t\trte_memcpy((void *)(uintptr_t)dst, (void *)(uintptr_t)src, len);\n-\n-\t\tremain -= len;\n-\t\tdst += len;\n-\t\tdesc_addr += len;\n-\t}\n-\n-\treturn idesc;\n-}\n-\n static __rte_always_inline void\n free_ind_table(void *idesc)\n {\ndiff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c\nindex 8aeb180016..4564e9bcc9 100644\n--- a/lib/librte_vhost/virtio_net.c\n+++ b/lib/librte_vhost/virtio_net.c\n@@ -337,7 +337,7 @@ fill_vec_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\t * The indirect desc table is not contiguous\n \t\t\t * in process VA space, we have to copy it.\n \t\t\t */\n-\t\t\tidesc = alloc_copy_ind_table(dev, vq,\n+\t\t\tidesc = vhost_alloc_copy_ind_table(dev, vq,\n \t\t\t\t\tvq->desc[idx].addr, vq->desc[idx].len);\n \t\t\tif (unlikely(!idesc))\n \t\t\t\treturn -1;\n@@ -454,7 +454,8 @@ fill_vec_buf_packed_indirect(struct virtio_net *dev,\n \t\t * The indirect desc table is not contiguous\n \t\t * in process VA space, we have to copy it.\n \t\t */\n-\t\tidescs = alloc_copy_ind_table(dev, vq, desc->addr, desc->len);\n+\t\tidescs = vhost_alloc_copy_ind_table(dev,\n+\t\t\t\tvq, desc->addr, desc->len);\n \t\tif (unlikely(!idescs))\n \t\t\treturn -1;\n \n@@ -610,6 +611,36 @@ reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \treturn 0;\n }\n \n+static __rte_noinline void\n+copy_vnet_hdr_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n+\t\tstruct buf_vector *buf_vec,\n+\t\tstruct virtio_net_hdr_mrg_rxbuf *hdr)\n+{\n+\tuint64_t len;\n+\tuint64_t remain = dev->vhost_hlen;\n+\tuint64_t src = (uint64_t)(uintptr_t)hdr, dst;\n+\tuint64_t iova = buf_vec->buf_iova;\n+\n+\twhile (remain) {\n+\t\tlen = RTE_MIN(remain,\n+\t\t\t\tbuf_vec->buf_len);\n+\t\tdst = buf_vec->buf_addr;\n+\t\trte_memcpy((void *)(uintptr_t)dst,\n+\t\t\t\t(void *)(uintptr_t)src,\n+\t\t\t\tlen);\n+\n+\t\tPRINT_PACKET(dev, (uintptr_t)dst,\n+\t\t\t\t(uint32_t)len, 0);\n+\t\tvhost_log_cache_write(dev, vq,\n+\t\t\t\tiova, len);\n+\n+\t\tremain -= len;\n+\t\tiova += len;\n+\t\tsrc += len;\n+\t\tbuf_vec++;\n+\t}\n+}\n+\n static __rte_always_inline int\n copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\t    struct rte_mbuf *m, struct buf_vector *buf_vec,\n@@ -703,30 +734,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t\t\t\t\tnum_buffers);\n \n \t\t\tif (unlikely(hdr == &tmp_hdr)) {\n-\t\t\t\tuint64_t len;\n-\t\t\t\tuint64_t remain = dev->vhost_hlen;\n-\t\t\t\tuint64_t src = (uint64_t)(uintptr_t)hdr, dst;\n-\t\t\t\tuint64_t iova = buf_vec[0].buf_iova;\n-\t\t\t\tuint16_t hdr_vec_idx = 0;\n-\n-\t\t\t\twhile (remain) {\n-\t\t\t\t\tlen = RTE_MIN(remain,\n-\t\t\t\t\t\tbuf_vec[hdr_vec_idx].buf_len);\n-\t\t\t\t\tdst = buf_vec[hdr_vec_idx].buf_addr;\n-\t\t\t\t\trte_memcpy((void *)(uintptr_t)dst,\n-\t\t\t\t\t\t\t(void *)(uintptr_t)src,\n-\t\t\t\t\t\t\tlen);\n-\n-\t\t\t\t\tPRINT_PACKET(dev, (uintptr_t)dst,\n-\t\t\t\t\t\t\t(uint32_t)len, 0);\n-\t\t\t\t\tvhost_log_cache_write(dev, vq,\n-\t\t\t\t\t\t\tiova, len);\n-\n-\t\t\t\t\tremain -= len;\n-\t\t\t\t\tiova += len;\n-\t\t\t\t\tsrc += len;\n-\t\t\t\t\thdr_vec_idx++;\n-\t\t\t\t}\n+\t\t\t\tcopy_vnet_hdr_to_desc(dev, vq, buf_vec, hdr);\n \t\t\t} else {\n \t\t\t\tPRINT_PACKET(dev, (uintptr_t)hdr_addr,\n \t\t\t\t\t\tdev->vhost_hlen, 0);\n@@ -1063,6 +1071,27 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)\n \t}\n }\n \n+static __rte_noinline void\n+copy_vnet_hdr_from_desc(struct virtio_net_hdr *hdr,\n+\t\tstruct buf_vector *buf_vec)\n+{\n+\tuint64_t len;\n+\tuint64_t remain = sizeof(struct virtio_net_hdr);\n+\tuint64_t src;\n+\tuint64_t dst = (uint64_t)(uintptr_t)hdr;\n+\n+\twhile (remain) {\n+\t\tlen = RTE_MIN(remain, buf_vec->buf_len);\n+\t\tsrc = buf_vec->buf_addr;\n+\t\trte_memcpy((void *)(uintptr_t)dst,\n+\t\t\t\t(void *)(uintptr_t)src, len);\n+\n+\t\tremain -= len;\n+\t\tdst += len;\n+\t\tbuf_vec++;\n+\t}\n+}\n+\n static __rte_always_inline int\n copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \t\t  struct buf_vector *buf_vec, uint16_t nr_vec,\n@@ -1094,28 +1123,11 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,\n \n \tif (virtio_net_with_host_offload(dev)) {\n \t\tif (unlikely(buf_len < sizeof(struct virtio_net_hdr))) {\n-\t\t\tuint64_t len;\n-\t\t\tuint64_t remain = sizeof(struct virtio_net_hdr);\n-\t\t\tuint64_t src;\n-\t\t\tuint64_t dst = (uint64_t)(uintptr_t)&tmp_hdr;\n-\t\t\tuint16_t hdr_vec_idx = 0;\n-\n \t\t\t/*\n \t\t\t * No luck, the virtio-net header doesn't fit\n \t\t\t * in a contiguous virtual area.\n \t\t\t */\n-\t\t\twhile (remain) {\n-\t\t\t\tlen = RTE_MIN(remain,\n-\t\t\t\t\tbuf_vec[hdr_vec_idx].buf_len);\n-\t\t\t\tsrc = buf_vec[hdr_vec_idx].buf_addr;\n-\t\t\t\trte_memcpy((void *)(uintptr_t)dst,\n-\t\t\t\t\t\t   (void *)(uintptr_t)src, len);\n-\n-\t\t\t\tremain -= len;\n-\t\t\t\tdst += len;\n-\t\t\t\thdr_vec_idx++;\n-\t\t\t}\n-\n+\t\t\tcopy_vnet_hdr_from_desc(&tmp_hdr, buf_vec);\n \t\t\thdr = &tmp_hdr;\n \t\t} else {\n \t\t\thdr = (struct virtio_net_hdr *)((uintptr_t)buf_addr);\n",
    "prefixes": [
        "v3",
        "3/5"
    ]
}