l2: fix array-bounds error for prefetch on Arm 07/33307/2
authorTianyu Li <tianyu.li@arm.com>
Thu, 29 Jul 2021 05:39:24 +0000 (13:39 +0800)
committerDamjan Marion <dmarion@me.com>
Sun, 7 Nov 2021 04:25:14 +0000 (04:25 +0000)
make build-release CC=gcc-10

vpp/src/vppinfra/cache.h:73:31: error: array subscript 80 is outside
array bounds of ‘l2_in_out_feat_arc_main_t[1]’ [-Werror=array-bounds]
__builtin_prefetch (_addr + (n) *CLIB_CACHE_PREFETCH_BYTES,
_CLIB_PREFETCH (3, size, type);
vpp/src/vnet/l2/l2_in_out_feat_arc.c:260:3:
note: in expansion of macro ‘CLIB_PREFETCH’
CLIB_PREFETCH (next_node_indices, 2 * CLIB_CACHE_LINE_BYTES, LOAD);

2 * CLIB_CACHE_LINE_BYTES is 256 bytes on Arm, the offset is out of range of
fam->feat_next_node_index[1], which is 128 bytes, use sizeof array instead.

Type: fix
Signed-off-by: Tianyu Li <tianyu.li@arm.com>
Change-Id: Ib7e06fcb643b2e863985ba89efcc274076752133

src/vnet/l2/l2_in_out_feat_arc.c

index b3b4a8c..94c4c1b 100644 (file)
@@ -257,7 +257,8 @@ l2_in_out_feat_arc_node_fn (vlib_main_t * vm,
   sw_if_index = sw_if_indices;
   n_left = frame->n_vectors;
 
-  CLIB_PREFETCH (next_node_indices, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+  CLIB_PREFETCH (next_node_indices,
+                sizeof (fam->feat_next_node_index[is_output]), LOAD);
 
   while (n_left > 3 * L2_FEAT_ARC_VEC_SIZE)
     {