tee: amdtee: Use %pUl printk() format specifier to print GUIDs
PATCH 1/1 tee: amdtee: Use %pUl printk() format specifier to print GUIDs
Replace the custom approach with the %pUl printk() format specifier. No functional change intended.
--- drivers/tee/amdtee/core.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/tee/amdtee/core.c +4 -13
@@ -14,6 +14,7 @@#include <linux/mm.h> #include <linux/uaccess.h> #include <linux/firmware.h> +#include <linux/uuid.h> #include "amdtee_private.h" #include <linux/psp-tee.h>
@@ -172,21 +173,11 @@ static int copy_ta_binary(struct tee_context *ctx, void *ptr, void **ta, {const struct firmware *fw;char fw_name[TA_PATH_MAX ]; -struct { -u32 lo; -u16 mid; -u16 hi_ver; -u8 seq_n[8 ]; - } *uuid = ptr;int n, rc =0 ; +guid_t uuid; - n =snprintf (fw_name,TA_PATH_MAX , -"%s/%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.bin" , -TA_LOAD_PATH , uuid->lo, uuid->mid, uuid->hi_ver, - uuid->seq_n[0 ], uuid->seq_n[1 ], - uuid->seq_n[2 ], uuid->seq_n[3 ], - uuid->seq_n[4 ], uuid->seq_n[5 ], - uuid->seq_n[6 ], uuid->seq_n[7 ]); +import_guid (&uuid, ptr); + n =snprintf (fw_name,TA_PATH_MAX ,"%s/%pUl.bin" ,TA_LOAD_PATH , &uuid);if (n <0 || n >=TA_PATH_MAX ) {pr_err ("failed to get firmware name\n" );return -EINVAL ;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 8 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/tee/amdtee/core.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
Thanks, the patch looks like a nice simplificatrion.
Rijo, Devaraj, does this work for you?
Cheers,
Jens
Quoted 41 lines
drivers/tee/amdtee/core.c +4
-14@@ -14,6 +14,7 @@#include <linux/mm.h> #include <linux/uaccess.h> #include <linux/firmware.h> +#include <linux/uuid.h> #include "amdtee_private.h" #include <linux/psp-tee.h> @@ -172,21 +173,11 @@ static int copy_ta_binary(struct tee_context *ctx, void *ptr, void **ta, {const struct firmware *fw;char fw_name[TA_PATH_MAX ]; -struct { -u32 lo; -u16 mid; -u16 hi_ver; -u8 seq_n[8 ]; - } *uuid = ptr;int n, rc =0 ; +guid_t uuid; - n =snprintf (fw_name,TA_PATH_MAX , -"%s/%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.bin" , -TA_LOAD_PATH , uuid->lo, uuid->mid, uuid->hi_ver, - uuid->seq_n[0 ], uuid->seq_n[1 ], - uuid->seq_n[2 ], uuid->seq_n[3 ], - uuid->seq_n[4 ], uuid->seq_n[5 ], - uuid->seq_n[6 ], uuid->seq_n[7 ]); +import_guid (&uuid, ptr); + n =snprintf (fw_name,TA_PATH_MAX ,"%s/%pUl.bin" ,TA_LOAD_PATH , &uuid);if (n <0 || n >=TA_PATH_MAX ) {pr_err ("failed to get firmware name\n" );return -EINVAL ; --2.43.0.rc1.1336.g36b5255a03ac
Quoted 7 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use uuid_t (UUID BE) for TEE, but in this driver IIUC it's guid_t (UUID LE).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.
Quoted 9 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).
No, this does not work for us. I tested this patch, it does not work as expected.
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Thanks,
Rijo
Quoted 17 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).
Quoted 7 lines
No, this does not work for us. I tested this patch, it does not work as expected.
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
P.S. Thank you for testing!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 23 lines · Andy Shevchenko
Quoted 22 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).No, this does not work for us. I tested this patch, it does not work as expected.
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Quoted 7 lines
Quoted 2 lines
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
P.S. Thank you for testing!
Alternatively we may get rid of that hyphen. I can send a patch.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 27 lines · Andy Shevchenko
Quoted 26 lines · Andy Shevchenko
Quoted 24 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).No, this does not work for us. I tested this patch, it does not work as expected.
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Quoted 6 lines
Quoted 4 lines
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
P.S. Thank you for testing!Alternatively we may get rid of that hyphen. I can send a patch.
Something like this on top of this patch (meaning squashed at the end):
+ /*
+ * Firmware name uses non-standard human-readable GUID representation:
+ * %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x (no last hyphen).
+ */
+ p = strrchr(fw_name, '-');
+ memmove(p, p + 1, strlen(p + 1));
+
mutex_lock(&drv_mutex);
n = request_firmware(&fw, fw_name, &ctx->teedev->dev);
What do you think?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).No, this does not work for us. I tested this patch, it does not work as expected.
Quoted 8 lines
Quoted 5 lines
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
Could this be due to some copying/pasting from the OP-TEE code base which had a similar mistake prior to v2.3.0 [1][2][3]?
[1] https://github.com/OP-TEE/optee_os/blob/2.3.0/CHANGELOG.md?plain=1#L40-L45
[2] https://github.com/OP-TEE/optee_client/commit/a5b1ffcd26e3
[3] https://github.com/OP-TEE/optee_client/commit/365657667f89
Quoted 3 lines
P.S. Thank you for testing!
Regards,
Signature · 1 line
Jerome
Quoted 30 lines · Jerome Forissier
Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).No, this does not work for us. I tested this patch, it does not work as expected.
Quoted 8 lines
Quoted 5 lines
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
Quoted 6 lines
Could this be due to some copying/pasting from the OP-TEE code base which had a similar mistake prior to v2.3.0 [1][2][3]?
[1] https://github.com/OP-TEE/optee_os/blob/2.3.0/CHANGELOG.md?plain=1#L40-L45
[2] https://github.com/OP-TEE/optee_client/commit/a5b1ffcd26e3
[3] https://github.com/OP-TEE/optee_client/commit/365657667f89
Interesting... Is somebody going to update this to follow the proper format? (yes, I understand that the old one has still to be supported)
Quoted 1 line
Quoted 1 line
P.S. Thank you for testing!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 40 lines · Jerome Forissier
Quoted 20 lines · Andy Shevchenko
Quoted 19 lines · Rijo Thomas
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Jens Wiklander
Quoted 3 lines · Andy Shevchenko
Replace the custom approach with the %pUl
printk()format specifier. No functional change intended.Quoted 8 lines
Quoted 1 line
Thanks, the patch looks like a nice simplificatrion.
Thank you for the review.
Quoted 1 line
Rijo, Devaraj, does this work for you?
Yes, please test, because seems others use
uuid_t(UUID BE) for TEE, but in this driver IIUC it'sguid_t(UUID LE).No, this does not work for us. I tested this patch, it does not work as expected.
Quoted 8 lines
Quoted 5 lines
%pUl gives output in uuid format (%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x). But, what we need, is a name with the format %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x.
Endian-ness is not an issue here. uuid generates name with 4 hypens (-). While, in our TA naming we are using 3 hyphens (-).
Ah, good catch! Can somebody add a comment there to explain that this uses non-standard human-readable representation of GUID/UUID?
Could this be due to some copying/pasting from the OP-TEE code base which had a similar mistake prior to v2.3.0 [1][2][3]?
[1] https://github.com/OP-TEE/optee_os/blob/2.3.0/CHANGELOG.md?plain=1#L40-L45
[2] https://github.com/OP-TEE/optee_client/commit/a5b1ffcd26e3
[3] https://github.com/OP-TEE/optee_client/commit/365657667f89Quoted 1 line
Quoted 5 lines
Quoted 2 lines
P.S. Thank you for testing!Regards,
Thanks Jerome for the information. We will update and post a patch for this.
Regards,
Rijo