[PATCH v6 6/9] kselftest/arm64/mte: add address tag related macro and function
Mark Brown
broonie at kernel.org
Wed Jun 11 04:58:04 PDT 2025
On Wed, Jun 11, 2025 at 10:41:04AM +0100, Yeoreum Yun wrote:
> Add address tag related macro and function to test MTE_FAR feature.
> +void *mte_insert_atag(void *ptr)
> +{
> + unsigned char atag;
> +
> + srandom(time(NULL));
> + atag = mtefar_support ? (random() % MT_ATAG_MASK) + 1 : 0;
> + return (void *)MT_SET_ATAG((unsigned long)ptr, atag);
> +}
Ah, this is where the time.h inclusion came from - it just got split
into the wrong patch. I would move that srandom() into the main()
function, we don't need to reset the RNG every time we generate a tag
and since time() has a resolution of a second depending on how fast the
machine is we might manage to end up setting exactly the same value for
every tag insertion the program does which would seem to defeat the
point of using a RNG here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20250611/b15a0f0c/attachment.sig>
More information about the linux-arm-kernel
mailing list