numam-dpdk/lib
Anatoly Burakov 20d2159d46 malloc: fix end for bounded elements
In cases when alignment is bigger than boundary, we may incorrectly
calculate end of a bounded malloc element.

Consider this: suppose we are allocating a bounded malloc element
that should be of 128 bytes in size, bounded to 128 bytes and
aligned on a 256-byte boundary. Suppose our malloc element ends
at 0x140 - that is, 256 plus one cacheline.

So, right at the start, we are aligning our new_data_start to
include the required element size, and to be aligned on a specified
boundary - so new_data_start becomes 0. This fails the following
bounds check, because our element cannot go above 128 bytes from
the start, and we are at 320. So, we enter the bounds handling
branch.

While we're in there, we are aligning end_pt to our boundedness
requirement of 128 byte, and end up with 0x100 (since 256 is
128-byte aligned). We recalculate new_data_size and it stays at
0, however our end is at 0x100, which is beyond the 128 byte
boundary, and we report inability to reserve a bounded element
when we could have.

This patch adds an end_pt recalculation after new_data_start
adjustment - we already know that size <= bound, so we can do it
safely - and we then correctly report that we can, in fact, try
using this element for bounded malloc allocation.

Fixes: fafcc11985 ("mem: rework memzone to be allocated by malloc")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
2018-01-12 15:50:13 +01:00
..
librte_acl lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_bitratestats lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_cfgfile lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_cmdline lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_compat fix typos using codespell utility 2017-06-14 23:54:13 +02:00
librte_cryptodev lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_distributor distributor: remove unnecessary parenthesis 2018-01-05 22:08:24 +01:00
librte_eal malloc: fix end for bounded elements 2018-01-12 15:50:13 +01:00
librte_efd lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_ether ethdev: remove redundant parenthesis 2018-01-05 22:08:15 +01:00
librte_eventdev lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_flow_classify flow_classify: remove table id parameter from API 2018-01-11 19:15:26 +01:00
librte_gro gro: support VxLAN GRO 2018-01-11 23:18:36 +01:00
librte_gso lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_hash lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_ip_frag lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_jobstats lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_kni lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_kvargs mk: do not generate LDLIBS from directory dependencies 2017-10-24 02:14:57 +02:00
librte_latencystats lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_lpm lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_mbuf mbuf: check sanity of data and packet lengths 2018-01-12 00:37:07 +01:00
librte_member lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_mempool lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_meter lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_metrics lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_net lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_pci remove useless memzone includes 2017-11-06 22:12:08 +01:00
librte_pdump lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_pipeline lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_port lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_power power: clean KVM files 2018-01-12 00:37:07 +01:00
librte_reorder lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_ring lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_sched lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_security lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_table lib: use SPDX tag for Cavium copyright files 2018-01-09 16:19:01 +01:00
librte_timer lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
librte_vhost lib: use SPDX tag for Intel copyright files 2018-01-04 22:41:39 +01:00
Makefile kni: fix build dependency 2018-01-11 19:15:26 +01:00