From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 3F7B11B489 for ; Fri, 4 Jan 2019 14:27:19 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 996A08666F; Fri, 4 Jan 2019 13:27:18 +0000 (UTC) Received: from ktraynor.remote.csb (ovpn-117-13.ams2.redhat.com [10.36.117.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A1C45C1A1; Fri, 4 Jan 2019 13:27:16 +0000 (UTC) From: Kevin Traynor To: Anatoly Burakov Cc: Yongseok Koh , dpdk stable Date: Fri, 4 Jan 2019 13:24:15 +0000 Message-Id: <20190104132455.15170-33-ktraynor@redhat.com> In-Reply-To: <20190104132455.15170-1-ktraynor@redhat.com> References: <20190104132455.15170-1-ktraynor@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 (mx1.redhat.com [10.5.110.26]); Fri, 04 Jan 2019 13:27:18 +0000 (UTC) Subject: [dpdk-stable] patch 'malloc: make alignment requirements more stringent' has been queued to LTS release 18.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2019 13:27:19 -0000 Hi, FYI, your patch has been queued to LTS release 18.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 01/11/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Kevin Traynor --- >>From a6cabceceb71448498795c29fdd0fc450a8abe5b Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 14 Dec 2018 11:54:01 +0000 Subject: [PATCH] malloc: make alignment requirements more stringent [ upstream commit 646e5260ee5371709042b0e2712822ba3ea63fe3 ] The external heaps API already implicitly expects start address of the external memory area to be page-aligned, but it is not enforced or documented. Fix this by implementing additional parameter checks at memory add call, and document the page alignment requirement explicitly. Fixes: 7d75c31014f7 ("malloc: allow adding memory to named heaps") Suggested-by: Yongseok Koh Signed-off-by: Anatoly Burakov Acked-by: Yongseok Koh --- lib/librte_eal/common/include/rte_malloc.h | 4 ++-- lib/librte_eal/common/rte_malloc.c | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/common/include/rte_malloc.h b/lib/librte_eal/common/include/rte_malloc.h index 7249e6aae..a5290b074 100644 --- a/lib/librte_eal/common/include/rte_malloc.h +++ b/lib/librte_eal/common/include/rte_malloc.h @@ -283,7 +283,7 @@ rte_malloc_get_socket_stats(int socket, * Name of the heap to add memory chunk to * @param va_addr - * Start of virtual area to add to the heap + * Start of virtual area to add to the heap. Must be aligned by ``page_sz``. * @param len - * Length of virtual area to add to the heap + * Length of virtual area to add to the heap. Must be aligned by ``page_sz``. * @param iova_addrs * Array of page IOVA addresses corresponding to each page in this memory diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c index 5f07b981a..06cf1e666 100644 --- a/lib/librte_eal/common/rte_malloc.c +++ b/lib/librte_eal/common/rte_malloc.c @@ -346,4 +346,7 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len, if (heap_name == NULL || va_addr == NULL || page_sz == 0 || !rte_is_power_of_2(page_sz) || + RTE_ALIGN(len, page_sz) != len || + !rte_is_aligned(va_addr, page_sz) || + ((len / page_sz) != n_pages && iova_addrs != NULL) || strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == 0 || strnlen(heap_name, RTE_HEAP_NAME_MAX_LEN) == @@ -368,9 +371,4 @@ rte_malloc_heap_memory_add(const char *heap_name, void *va_addr, size_t len, } n = len / page_sz; - if (n != n_pages && iova_addrs != NULL) { - rte_errno = EINVAL; - ret = -1; - goto unlock; - } rte_spinlock_lock(&heap->lock); -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-01-04 13:23:08.232335009 +0000 +++ 0033-malloc-make-alignment-requirements-more-stringent.patch 2019-01-04 13:23:07.000000000 +0000 @@ -1,8 +1,10 @@ -From 646e5260ee5371709042b0e2712822ba3ea63fe3 Mon Sep 17 00:00:00 2001 +From a6cabceceb71448498795c29fdd0fc450a8abe5b Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Fri, 14 Dec 2018 11:54:01 +0000 Subject: [PATCH] malloc: make alignment requirements more stringent +[ upstream commit 646e5260ee5371709042b0e2712822ba3ea63fe3 ] + The external heaps API already implicitly expects start address of the external memory area to be page-aligned, but it is not enforced or documented. Fix this by implementing additional @@ -10,7 +12,6 @@ alignment requirement explicitly. Fixes: 7d75c31014f7 ("malloc: allow adding memory to named heaps") -Cc: stable@dpdk.org Suggested-by: Yongseok Koh Signed-off-by: Anatoly Burakov