[PATCH] x86: tpm: Remove a busy bit of the NVS area for supporting AMD's fTPM

From: Seunghun Han
Date: Mon Aug 26 2019 - 04:18:16 EST

I'm Seunghun Han and work at the Affiliated Institute of ETRI. I got
an AMD system which had a Ryzen Threadripper 1950X and MSI mainboard, and
I had a problem with AMD's fTPM. My machine showed an error message below,
and the fTPM didn't work because of it.

[ÂÂ5.732084] tpm_crb MSFT0101:00: can't request region for resource
ÂÂÂÂÂÂÂÂ [mem 0x79b4f000-0x79b4ffff]
[ÂÂ5.732089] tpm_crb: probe of MSFT0101:00 failed with error -16

When I saw the e820 map and iomem, I found two fTPM regions were in
the ACPI NVS area.ÂThe regions are below.

79a39000-79b6afff : ACPI Non-volatile Storage
79b4b000-79b4bfff : MSFT0101:00
79b4f000-79b4ffff : MSFT0101:00

After analyzing this issue, I found out that a busy bit was set to
the ACPI NVS area, and the Linux kernel didn't allow the TPM CRB driver
to assign CRB regions in it.

To support AMD's fTPM, I removed the busy bit from the ACPI NVS area like
the reserved area so that AMD's fTPM regions could be assigned in it.

Signed-off-by: Seunghun Han <kkamagui@xxxxxxxxx>
arch/x86/kernel/e820.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 7da2bcd2b8eb..0d721df8900e 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1085,11 +1085,12 @@ static bool __init do_mark_busy(enum e820_type type, struct resource *res)
case E820_TYPE_PRAM:
case E820_TYPE_PMEM:
+ /* AMD's fTPM regions are in the ACPI NVS area */
+ case E820_TYPE_NVS:
return false;
case E820_TYPE_RAM:
case E820_TYPE_ACPI:
- case E820_TYPE_NVS:
return true;