Skip to content

Commit 7f54e00

Browse files
committed
modpost: fix tee MODULE_DEVICE_TABLE built on big-endian host
When MODULE_DEVICE_TABLE(tee, ) is built on a host with a different endianness from the target architecture, it results in an incorrect MODULE_ALIAS(). For example, see a case where drivers/char/hw_random/optee-rng.c is built as a module for ARM little-endian. If you build it on a little-endian host, you will get the correct MODULE_ALIAS: $ grep MODULE_ALIAS drivers/char/hw_random/optee-rng.mod.c MODULE_ALIAS("tee:ab7a617c-b8e7-4d8f-8301-d09b61036b64*"); However, if you build it on a big-endian host, you will get a wrong MODULE_ALIAS: $ grep MODULE_ALIAS drivers/char/hw_random/optee-rng.mod.c MODULE_ALIAS("tee:646b0361-9bd0-0183-8f4d-e7b87c617aab*"); The same problem also occurs when you enable CONFIG_CPU_BIG_ENDIAN, and build it on a little-endian host. This issue has been unnoticed because the ARM kernel is configured for little-endian by default, and most likely built on a little-endian host (cross-build on x86 or native-build on ARM). The uuid field must not be reversed because uuid_t is an array of __u8. Fixes: 0fc1db9 ("tee: add bus driver framework for TEE based devices") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
1 parent a55d4ae commit 7f54e00

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

scripts/mod/file2alias.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,13 +1348,13 @@ static int do_typec_entry(const char *filename, void *symval, char *alias)
13481348
/* Looks like: tee:uuid */
13491349
static int do_tee_entry(const char *filename, void *symval, char *alias)
13501350
{
1351-
DEF_FIELD(symval, tee_client_device_id, uuid);
1351+
DEF_FIELD_ADDR(symval, tee_client_device_id, uuid);
13521352

13531353
sprintf(alias, "tee:%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
1354-
uuid.b[0], uuid.b[1], uuid.b[2], uuid.b[3], uuid.b[4],
1355-
uuid.b[5], uuid.b[6], uuid.b[7], uuid.b[8], uuid.b[9],
1356-
uuid.b[10], uuid.b[11], uuid.b[12], uuid.b[13], uuid.b[14],
1357-
uuid.b[15]);
1354+
uuid->b[0], uuid->b[1], uuid->b[2], uuid->b[3], uuid->b[4],
1355+
uuid->b[5], uuid->b[6], uuid->b[7], uuid->b[8], uuid->b[9],
1356+
uuid->b[10], uuid->b[11], uuid->b[12], uuid->b[13], uuid->b[14],
1357+
uuid->b[15]);
13581358

13591359
add_wildcard(alias);
13601360
return 1;

0 commit comments

Comments
 (0)