[v1,1/2] linux-gen: pool: use 64-bit shm sizes

Message ID 1519113607-26653-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Fix creating pools larger than 4.29GB
Related show

Commit Message

Github ODP bot Feb. 20, 2018, 8 a.m.
From: Matias Elo <matias.elo@nokia.com>


odp_shm_reserve() takes a 64-bit size argument. The previous 32-bit values
could wrap around in case of very large pools.

Fixes: https://bugs.linaro.org/show_bug.cgi?id=3632

Signed-off-by: Matias Elo <matias.elo@nokia.com>

---
/** Email created from pull request 490 (matiaselo:fix/pool_create)
 ** https://github.com/Linaro/odp/pull/490
 ** Patch: https://github.com/Linaro/odp/pull/490.patch
 ** Base sha: d5419e8857b2bc61d3be17fe53f171550fee426b
 ** Merge commit sha: ad05fc232e7d91885e16f718adc44c77eef01988
 **/
 platform/linux-generic/include/odp_pool_internal.h | 4 ++--
 platform/linux-generic/odp_pool.c                  | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

Patch

diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h
index 8284bcd7d..70e7bd24e 100644
--- a/platform/linux-generic/include/odp_pool_internal.h
+++ b/platform/linux-generic/include/odp_pool_internal.h
@@ -55,6 +55,8 @@  typedef struct pool_t {
 	uint32_t         ring_mask;
 	odp_shm_t        shm;
 	odp_shm_t        uarea_shm;
+	uint64_t         shm_size;
+	uint64_t         uarea_shm_size;
 	int              reserved;
 	uint32_t         num;
 	uint32_t         align;
@@ -65,8 +67,6 @@  typedef struct pool_t {
 	uint32_t         max_len;
 	uint32_t         uarea_size;
 	uint32_t         block_size;
-	uint32_t         shm_size;
-	uint32_t         uarea_shm_size;
 	uint8_t         *base_addr;
 	uint8_t         *uarea_base_addr;
 
diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index e5ba8982a..357595317 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -478,8 +478,8 @@  static odp_pool_t pool_create(const char *name, odp_pool_param_t *params,
 	pool->tailroom       = tailroom;
 	pool->block_size     = block_size;
 	pool->uarea_size     = uarea_size;
-	pool->shm_size       = (num + num_extra) * block_size;
-	pool->uarea_shm_size = num * uarea_size;
+	pool->shm_size       = (num + num_extra) * (uint64_t)block_size;
+	pool->uarea_shm_size = num * (uint64_t)uarea_size;
 	pool->ext_desc       = NULL;
 	pool->ext_destroy    = NULL;
 
@@ -956,9 +956,9 @@  void odp_pool_print(odp_pool_t pool_hdl)
 	ODP_PRINT("  tailroom        %u\n", pool->tailroom);
 	ODP_PRINT("  block size      %u\n", pool->block_size);
 	ODP_PRINT("  uarea size      %u\n", pool->uarea_size);
-	ODP_PRINT("  shm size        %u\n", pool->shm_size);
+	ODP_PRINT("  shm size        %" PRIu64 "\n", pool->shm_size);
 	ODP_PRINT("  base addr       %p\n", pool->base_addr);
-	ODP_PRINT("  uarea shm size  %u\n", pool->uarea_shm_size);
+	ODP_PRINT("  uarea shm size  %" PRIu64 "\n", pool->uarea_shm_size);
 	ODP_PRINT("  uarea base addr %p\n", pool->uarea_base_addr);
 	ODP_PRINT("\n");
 }