On 02/08/21 18:56, Jing Zhang wrote:
+ index = array_index_nospec(index, size);
+ ++data[index];
This would have to use
index = min(index, size-1);
index = array_index_nospec(index, size);
But thinking more about it there should be no way to do *two*
consecutive accesses. Thus, it would be possible to bring an out of
bounds element of data[] in the cache, but it would not be possible to
deduce its value.
This might have to be taken into account when adding more statistics,
but for now I've simply replaced array_index_nospec with the min() above.
Paolo