Skip to contentSkip to conversation

tpm: Don't make vendor check required for probe

PATCH In review Mario Limonciello 5 participants 10 messages Aug 21, 2023 – Aug 22, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tpm: Don't make vendor check required for probe

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
 drivers/char/tpm/tpm_crb.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +6 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
 static int crb_check_flags(struct tpm_chip *chip)
 {
+	int ret = 0;
+#ifdef CONFIG_X86
 	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
 	ret = crb_request_locality(chip, 0);
 	if (ret)
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
 release:
 	crb_relinquish_locality(chip, 0);
+#endif
 
 	return ret;
 }
Signature · 1 line
2.34.1
#2 lore raw
Quoted 51 lines

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
 drivers/char/tpm/tpm_crb.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +6 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
 static int crb_check_flags(struct tpm_chip *chip)
 {
+	int ret = 0;
+#ifdef CONFIG_X86
 	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
 	ret = crb_request_locality(chip, 0);
 	if (ret)
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
 release:
 	crb_relinquish_locality(chip, 0);
+#endif
 
 	return ret;
 }
Signature · 1 line
2.34.1

Fixes problem on my machine.

maintainer
#3 lore raw
In reply to Mario Limonciello
Quoted 42 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
 drivers/char/tpm/tpm_crb.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +5 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
 static int crb_check_flags(struct tpm_chip *chip)
 {
+	int ret = 0;
+#ifdef CONFIG_X86
 	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
 	ret = crb_request_locality(chip, 0);
 	if (ret)

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 4 lines
drivers/char/tpm/tpm_crb.c +1 -0
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
 release:
 	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

#4 lore raw
Quoted 51 lines · Jarkko Sakkinen
Quoted 42 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +5 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;
+#ifdef CONFIG_X86
  	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
  	ret = crb_request_locality(chip, 0);
  	if (ret)

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 4 lines
drivers/char/tpm/tpm_crb.c +1 -0
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

maintainer Tested-by Reviewed-by
#5 lore raw
Quoted 52 lines · Mario Limonciello
Quoted 51 lines · Jarkko Sakkinen
Quoted 42 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +5 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;
+#ifdef CONFIG_X86
  	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
  	ret = crb_request_locality(chip, 0);
  	if (ret)

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 4 lines
drivers/char/tpm/tpm_crb.c +1 -0
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 8 lines
Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

Then I guess we'll go with this for now. Thanks for the effort.

I'm planning to send a pull request right after this with the fix so it will land to v6.6-rc1 or v6.6-rc2:
https://lore.kernel.org/linux-integrity/[email protected]/

BR, Jarkko

#6 lore raw
Quoted 64 lines · Jarkko Sakkinen
Quoted 52 lines · Mario Limonciello
Quoted 51 lines · Jarkko Sakkinen
Quoted 42 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +5 -1
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;
+#ifdef CONFIG_X86
  	u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;
 
  	ret = crb_request_locality(chip, 0);
  	if (ret)

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 4 lines
drivers/char/tpm/tpm_crb.c +1 -0
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 8 lines
Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

Then I guess we'll go with this for now. Thanks for the effort.

Quoted 8 lines

I'm planning to send a pull request right after this with the fix so it will land to v6.6-rc1 or v6.6-rc2:
https://lore.kernel.org/linux-integrity/[email protected]/

BR, Jarkko

Super minor nit that isn't this patch in particular so don't hold this up, but it seems like the function name for the earlier attempt to solve this issue that mentioned amd and ftpm was a clearer description of what was happening than crb_check_flags.

Regards,
Jerry

maintainer
#7 lore raw
Quoted 33 lines · Jerry Snitselaar
Quoted 32 lines · Jarkko Sakkinen
Quoted 31 lines · Mario Limonciello
Quoted 30 lines · Jarkko Sakkinen
Quoted 29 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +0 -0
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 468

Quoted 3 lines
drivers/char/tpm/tpm_crb.c +1 -0
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;

Oops I missed this. This adds unnecessary clutter to the diff.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 473

Quoted 5 lines
drivers/char/tpm/tpm_crb.c +4 -1
+#ifdef CONFIG_X86 u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;

No reason to use variable here. Should be just "return 0". It also documents what is going on. Now this gives impression as the "ret" could change.

I dropped the current version from my -next. I did not notice the change in declarations earlier, sorry.

Quoted 30 lines
Quoted 30 lines
Quoted 12 lines
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 8 lines
drivers/char/tpm/tpm_crb.c +1 -0
  	ret = crb_request_locality(chip, 0);
  	if (ret)
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 8 lines
Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

Then I guess we'll go with this for now. Thanks for the effort.

I'm planning to send a pull request right after this with the fix so it will land to v6.6-rc1 or v6.6-rc2:
https://lore.kernel.org/linux-integrity/[email protected]/

Quoted 7 lines
Quoted 1 line

BR, Jarkko

Super minor nit that isn't this patch in particular so don't hold this up, but it seems like the function name for the earlier attempt to solve this issue that mentioned amd and ftpm was a clearer description of what was happening than crb_check_flags.

I posted an alternative: https://lkml.org/lkml/2023/8/22/1188

BR, Jarkko

maintainer
#8 lore raw
Quoted 85 lines · Jarkko Sakkinen
Quoted 33 lines · Jerry Snitselaar
Quoted 32 lines · Jarkko Sakkinen
Quoted 31 lines · Mario Limonciello
Quoted 30 lines · Jarkko Sakkinen
Quoted 29 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +0 -0
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 468

Quoted 3 lines
drivers/char/tpm/tpm_crb.c +1 -0
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;

Oops I missed this. This adds unnecessary clutter to the diff.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 473

Quoted 5 lines
drivers/char/tpm/tpm_crb.c +4 -1
+#ifdef CONFIG_X86 u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;

No reason to use variable here. Should be just "return 0". It also documents what is going on. Now this gives impression as the "ret" could change.

I dropped the current version from my -next. I did not notice the change in declarations earlier, sorry.

Quoted 33 lines
Quoted 31 lines
Quoted 12 lines
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 8 lines
drivers/char/tpm/tpm_crb.c +1 -0
  	ret = crb_request_locality(chip, 0);
  	if (ret)
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 8 lines
Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

Then I guess we'll go with this for now. Thanks for the effort.

I'm planning to send a pull request right after this with the fix so it will land to v6.6-rc1 or v6.6-rc2:
https://lore.kernel.org/linux-integrity/[email protected]/

BR, Jarkko

Quoted 6 lines
Quoted 4 lines

Super minor nit that isn't this patch in particular so don't hold this up, but it seems like the function name for the earlier attempt to solve this issue that mentioned amd and ftpm was a clearer description of what was happening than crb_check_flags.

I posted an alternative: https://lkml.org/lkml/2023/8/22/1188

Ignore my reviewed-by (I cannot review my own patches) :-)

Also should be probably v6.4+ (should check when the fix landed)?

BR, Jarkko

maintainer
#9 lore raw
Quoted 91 lines · Jarkko Sakkinen
Quoted 90 lines · Jarkko Sakkinen
Quoted 33 lines · Jerry Snitselaar
Quoted 32 lines · Jarkko Sakkinen
Quoted 31 lines · Mario Limonciello
Quoted 30 lines · Jarkko Sakkinen
Quoted 29 lines · Mario Limonciello

The vendor check introduced by commit 554b841d4703 ("tpm: Disable RNG for all AMD fTPMs") doesn't work properly on a number of Intel fTPMs. On the reported systems the TPM doesn't reply at bootup and returns back the command code. This makes the TPM fail probe.

As this isn't crucial for anything but AMD fTPM and AMD fTPM works, check the chip vendor and if it's not AMD don't run the checks.

---
v1->v2:
* Check x86 vendor for AMD

---
  drivers/char/tpm/tpm_crb.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_crb.c +0 -0
index 9eb1a18590123..7faf670201ccc 100644
@@ -465,8 +465,12 @@ static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 468

Quoted 3 lines
drivers/char/tpm/tpm_crb.c +1 -0
  static int crb_check_flags(struct tpm_chip *chip)
  {
+	int ret = 0;

Oops I missed this. This adds unnecessary clutter to the diff.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

drivers/char/tpm/tpm_crb.c static bool crb_req_canceled(struct tpm_chip *chip, u8 status) · line 472

Quoted 5 lines
drivers/char/tpm/tpm_crb.c +4 -1
+#ifdef CONFIG_X86 u32 val;
-	int ret;
+
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return ret;

No reason to use variable here. Should be just "return 0". It also documents what is going on. Now this gives impression as the "ret" could change.

I dropped the current version from my -next. I did not notice the change in declarations earlier, sorry.

Quoted 37 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines

drivers/char/tpm/tpm_crb.c static int crb_check_flags(struct tpm_chip *chip) · line 488

Quoted 8 lines
drivers/char/tpm/tpm_crb.c +1 -0
  	ret = crb_request_locality(chip, 0);
  	if (ret)
@@ -481,6 +485,7 @@ static int crb_check_flags(struct tpm_chip *chip)
 
  release:
  	crb_relinquish_locality(chip, 0);
+#endif

Looks much better but the main question here is that is this combination possible:

Quoted 8 lines
Quoted 4 lines

1. AMD CPU
2. Non-AMD fTPM (i.e. manufacturer property differs)

BR, Jarkko

Yes that combination is possible.

Pluton TPM uses the tpm_crb driver.

Then I guess we'll go with this for now. Thanks for the effort.

Quoted 8 lines

I'm planning to send a pull request right after this with the fix so it will land to v6.6-rc1 or v6.6-rc2:
https://lore.kernel.org/linux-integrity/[email protected]/

BR, Jarkko

Super minor nit that isn't this patch in particular so don't hold this up, but it seems like the function name for the earlier attempt to solve this issue that mentioned amd and ftpm was a clearer description of what was happening than crb_check_flags.

Quoted 5 lines
Quoted 1 line

I posted an alternative: https://lkml.org/lkml/2023/8/22/1188

Ignore my reviewed-by (I cannot review my own patches) :-)

Also should be probably v6.4+ (should check when the fix landed)?

v2: https://lkml.org/lkml/2023/8/22/1197

BR, Jarkko