Skip to contentSkip to conversation

small amdtee cleanups

PATCH In review Mario Limonciello 3 participants 11 messages Apr 21, 2025 – Apr 29, 2025 TEE

lore
Share & tools
lore
#0 lore raw

cover small amdtee cleanups

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

 drivers/tee/amdtee/core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 tee: Use pr_fmt for messages

From: Mario Limonciello <[email protected]>

amd-tee inconsistently uses the word amd-tee in error messages.

Add a pr_fmt() define and remove the hardcoded use of amd-tee. Also, remove the unnecessary driver init successful message because there will be a message if failed and a user can assume it was successful otherwise.

---
 drivers/tee/amdtee/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/tee/amdtee/core.c +4 -3
index e487231d25dc0..a44625d076401 100644
@@ -3,6 +3,8 @@
  * Copyright 2019 Advanced Micro Devices, Inc.
  */
 
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -458,7 +460,7 @@ static int __init amdtee_driver_init(void)
 
 	rc = psp_check_tee_status();
 	if (rc) {
-		pr_err("amd-tee driver: tee not present\n");
+		pr_err("tee not present\n");
 		return rc;
 	}
 
@@ -494,7 +496,6 @@ static int __init amdtee_driver_init(void)
 
 	drv_data->amdtee = amdtee;
 
-	pr_info("amd-tee driver initialization successful\n");
 	return 0;
 
 err_device_unregister:
@@ -510,7 +511,7 @@ static int __init amdtee_driver_init(void)
 	kfree(drv_data);
 	drv_data = NULL;
 
-	pr_err("amd-tee driver initialization failed\n");
+	pr_err("initialization failed\n");
 	return rc;
 }
 module_init(amdtee_driver_init);
Signature · 1 line
2.43.0
#3 lore raw

PATCH 2/2 tee: Sort header includes

In reply to Mario Limonciello

From: Mario Limonciello <[email protected]>

Various headers have been added over time that are not added alphabetically and a private header is used before one of the linux/ headers.

Resort the list.

---
 drivers/tee/amdtee/core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tee/amdtee/core.c +5 -4
index a44625d076401..fb39d9a19c698 100644
@@ -6,18 +6,19 @@
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/errno.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
 #include <linux/io.h>
+#include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/psp-tee.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/device.h>
 #include <linux/tee_core.h>
 #include <linux/types.h>
-#include <linux/mm.h>
 #include <linux/uaccess.h>
-#include <linux/firmware.h>
+
 #include "amdtee_private.h"
-#include <linux/psp-tee.h>
 
 static struct amdtee_driver_data *drv_data;
 static DEFINE_MUTEX(session_list_mutex);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] tee: Use pr_fmt for messages

In reply to Mario Limonciello
Quoted 9 lines · Mario Limonciello via OP-TEE

From: Mario Limonciello <[email protected]>

amd-tee inconsistently uses the word amd-tee in error messages.

Add a pr_fmt() define and remove the hardcoded use of amd-tee. Also, remove the unnecessary driver init successful message because there will be a message if failed and a user can assume it was successful otherwise.

Quoted 5 lines
---
 drivers/tee/amdtee/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-Sumit

Quoted 42 lines
drivers/tee/amdtee/core.c +4 -3
index e487231d25dc0..a44625d076401 100644
@@ -3,6 +3,8 @@
  * Copyright 2019 Advanced Micro Devices, Inc.
  */
 
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/errno.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -458,7 +460,7 @@ static int __init amdtee_driver_init(void)
 
 	rc = psp_check_tee_status();
 	if (rc) {
-		pr_err("amd-tee driver: tee not present\n");
+		pr_err("tee not present\n");
 		return rc;
 	}
 
@@ -494,7 +496,6 @@ static int __init amdtee_driver_init(void)
 
 	drv_data->amdtee = amdtee;
 
-	pr_info("amd-tee driver initialization successful\n");
 	return 0;
 
 err_device_unregister:
@@ -510,7 +511,7 @@ static int __init amdtee_driver_init(void)
 	kfree(drv_data);
 	drv_data = NULL;
 
-	pr_err("amd-tee driver initialization failed\n");
+	pr_err("initialization failed\n");
 	return rc;
 }
 module_init(amdtee_driver_init);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] tee: Sort header includes

In reply to Mario Limonciello
Quoted 11 lines · Mario Limonciello via OP-TEE

From: Mario Limonciello <[email protected]>

Various headers have been added over time that are not added alphabetically and a private header is used before one of the linux/ headers.

Resort the list.

---
 drivers/tee/amdtee/core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

-Sumit

Quoted 32 lines
drivers/tee/amdtee/core.c +5 -4
index a44625d076401..fb39d9a19c698 100644
@@ -6,18 +6,19 @@
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/errno.h>
+#include <linux/device.h>
+#include <linux/firmware.h>
 #include <linux/io.h>
+#include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/psp-tee.h>
 #include <linux/slab.h>
 #include <linux/string.h>
-#include <linux/device.h>
 #include <linux/tee_core.h>
 #include <linux/types.h>
-#include <linux/mm.h>
 #include <linux/uaccess.h>
-#include <linux/firmware.h>
+
 #include "amdtee_private.h"
-#include <linux/psp-tee.h>
 
 static struct amdtee_driver_data *drv_data;
 static DEFINE_MUTEX(session_list_mutex);
Signature · 1 line
2.43.0
#5 lore raw
In reply to Mario Limonciello

Hi,

Quoted 7 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

Quoted 8 lines

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

 drivers/tee/amdtee/core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

I'm trying to build this, but I run into some selinux build error. How did you build this?

Cheers,
Jens

Quoted 4 lines

--
2.43.0

#6 lore raw
Quoted 16 lines · Jens Wiklander

Hi,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

Quoted 5 lines
Quoted 2 lines
  drivers/tee/amdtee/core.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)

I'm trying to build this, but I run into some selinux build error. How did you build this?

I used kworkflow (kw b). It was based off linux-next at the time I submitted it.

Can you share your .config? Is it a defconfig?

Let me pull the tee tree directly and try again with that tree and I'll see if I can reproduce the build error.

#7 lore raw
Quoted 18 lines · Mario Limonciello
Quoted 16 lines · Jens Wiklander

Hi,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
  drivers/tee/amdtee/core.c | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)

I'm trying to build this, but I run into some selinux build error. How did you build this?

I used kworkflow (kw b). It was based off linux-next at the time I submitted it.

I wasn't aware of kworkflow. I'm usually building manually locally or with tuxbuild.

Quoted 2 lines

Can you share your .config? Is it a defconfig?

It's defconfig + CONFIG_CRYPTO_DEV_CCP=y to get AMDTEE enabled. If you have an easier way, please let me know.

Quoted 3 lines

Let me pull the tee tree directly and try again with that tree and I'll see if I can reproduce the build error.

The error is:
security/selinux/nlmsgtab.c: In function ‘selinux_nlmsg_lookup’:
security/selinux/nlmsgtab.c:188:33: error:
‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_ROUTE_SOCKET__LOCK’?
188 | *perm = NETLINK_ROUTE_SOCKET__NLMSG;

Cheers,
Jens

#8 lore raw
Quoted 49 lines · Jens Wiklander
Quoted 18 lines · Mario Limonciello
Quoted 16 lines · Jens Wiklander

Hi,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
   drivers/tee/amdtee/core.c | 16 +++++++++-------
   1 file changed, 9 insertions(+), 7 deletions(-)

I'm trying to build this, but I run into some selinux build error. How did you build this?

I used kworkflow (kw b). It was based off linux-next at the time I submitted it.

I wasn't aware of kworkflow. I'm usually building manually locally or with tuxbuild.

Quoted 2 lines

Can you share your .config? Is it a defconfig?

It's defconfig + CONFIG_CRYPTO_DEV_CCP=y to get AMDTEE enabled. If you have an easier way, please let me know.

Quoted 3 lines

Let me pull the tee tree directly and try again with that tree and I'll see if I can reproduce the build error.

The error is:
security/selinux/nlmsgtab.c: In function ‘selinux_nlmsg_lookup’:
security/selinux/nlmsgtab.c:188:33: error:
‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_ROUTE_SOCKET__LOCK’?
188 | *perm = NETLINK_ROUTE_SOCKET__NLMSG;

Quoted 2 lines

Cheers,
Jens

Hmm, I couldn't reproduce. I did defconfig + CONFIG_AMDTEE=m

Here's your tree I based it from (tee/next):

9d172b0d7150c (HEAD) tee: Sort header includes 931240733ee67 tee: Use pr_fmt for messages
34e4aaeff2a84 (tee/next) Merge branch 'tee_for_v6_16' into next 26104d8156737 tee: optee: smc: remove unnecessary NULL check before release_firmware()
8ffd015db85fe (tag: v6.15-rc2, tip/x86/platform) Linux 6.15-rc2

I also tried with this successfully.

❯ make drivers/tee/amdtee/ -j16 W=1

   CC [M]  drivers/tee/amdtee/core.o
   CC [M]  drivers/tee/amdtee/call.o
   CC [M]  drivers/tee/amdtee/shm_pool.o
   LD [M]  drivers/tee/amdtee/amdtee.o
#9 lore raw
Quoted 65 lines · Mario Limonciello
Quoted 49 lines · Jens Wiklander
Quoted 18 lines · Mario Limonciello
Quoted 16 lines · Jens Wiklander

Hi,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

I just noticed a few small things for amdtee where the error messages didn't consistently use the driver name. While fixing that I noticed the headers weren't sorted.

These patches fix both issues.

Mario Limonciello (2):
tee: Use pr_fmt for messages
tee: Sort header includes

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
   drivers/tee/amdtee/core.c | 16 +++++++++-------
   1 file changed, 9 insertions(+), 7 deletions(-)

I'm trying to build this, but I run into some selinux build error. How did you build this?

I used kworkflow (kw b). It was based off linux-next at the time I submitted it.

I wasn't aware of kworkflow. I'm usually building manually locally or with tuxbuild.

Quoted 2 lines

Can you share your .config? Is it a defconfig?

It's defconfig + CONFIG_CRYPTO_DEV_CCP=y to get AMDTEE enabled. If you have an easier way, please let me know.

Quoted 3 lines

Let me pull the tee tree directly and try again with that tree and I'll see if I can reproduce the build error.

The error is:
security/selinux/nlmsgtab.c: In function ‘selinux_nlmsg_lookup’:
security/selinux/nlmsgtab.c:188:33: error:
‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_ROUTE_SOCKET__LOCK’?
188 | *perm = NETLINK_ROUTE_SOCKET__NLMSG;

Quoted 2 lines

Cheers,
Jens

Hmm, I couldn't reproduce. I did defconfig + CONFIG_AMDTEE=m

Here's your tree I based it from (tee/next):

9d172b0d7150c (HEAD) tee: Sort header includes 931240733ee67 tee: Use pr_fmt for messages
34e4aaeff2a84 (tee/next) Merge branch 'tee_for_v6_16' into next 26104d8156737 tee: optee: smc: remove unnecessary NULL check before release_firmware()
8ffd015db85fe (tag: v6.15-rc2, tip/x86/platform) Linux 6.15-rc2

Quoted 7 lines

I also tried with this successfully.

❯ make drivers/tee/amdtee/ -j16 W=1

   CC [M]  drivers/tee/amdtee/core.o
   CC [M]  drivers/tee/amdtee/call.o
   CC [M]  drivers/tee/amdtee/shm_pool.o
   LD [M]  drivers/tee/amdtee/amdtee.o

I had some junk in my tree, It builds for me now.

I'm picking up this patch set. By the way, I'm replacing the prefix for the patch titles with "amdtee" instead of "tee".

Cheers,
Jens

#10 lore raw
Quoted 7 lines

I had some junk in my tree, It builds for me now.

I'm picking up this patch set. By the way, I'm replacing the prefix for the patch titles with "amdtee" instead of "tee".

Cheers,
Jens

Much appreciated - thanks!