[PATCH] fTPM: make sure TEE is initialized before fTPM

From: Wei Liu
Date: Fri Jan 15 2021 - 19:14:02 EST


For built-in drivers, the order of initialization function invocation is
determined by their link order.

The original code linked TPM drivers before TEE driver when they were
both built in. That caused fTPM's initialization to be deferred to a
worker thread instead of running on PID 1.

That is problematic because IMA's initialization routine, which runs on
PID 1 as a late initcall, needs to have access to the default TPM
instance. If fTPM's initialization is deferred, IMA will not be able to
get hold of a TPM instance in time.

Fix this by modifying Makefile to make sure TEE is initialized before
fTPM when they are both built in.

Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx>
---
drivers/Makefile | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/Makefile b/drivers/Makefile
index fd11b9ac4cc3..45ea5ec9d0fd 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -180,6 +180,11 @@ obj-$(CONFIG_NVMEM) += nvmem/
obj-$(CONFIG_FPGA) += fpga/
obj-$(CONFIG_FSI) += fsi/
obj-$(CONFIG_TEE) += tee/
+
+# TPM drivers must come after TEE, otherwise fTPM initialization will be
+# deferred, which causes IMA to not get a TPM device in time
+obj-$(CONFIG_TCG_TPM) += char/tpm/
+
obj-$(CONFIG_MULTIPLEXER) += mux/
obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/
obj-$(CONFIG_SIOX) += siox/
--
2.20.1