1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #include <bootstate.h> 4 #include <console/console.h> 5 #include <security/tpm/tss.h> 6 #include <vb2_api.h> 7 disable_platform_hierarchy(void * unused)8static void disable_platform_hierarchy(void *unused) 9 { 10 tpm_result_t rc; 11 12 if (!CONFIG(TPM2)) 13 return; 14 15 if (!CONFIG(RESUME_PATH_SAME_AS_BOOT)) 16 return; 17 18 rc = tlcl_lib_init(); 19 20 if (rc != TPM_SUCCESS) { 21 printk(BIOS_ERR, "tlcl_lib_init() failed: %#x\n", rc); 22 return; 23 } 24 25 /* In case both families are enabled, but TPM1 is in use. */ 26 if (tlcl_get_family() != TPM_2) 27 return; 28 29 rc = tlcl2_disable_platform_hierarchy(); 30 if (rc != TPM_SUCCESS) 31 printk(BIOS_ERR, "Platform hierarchy disablement failed: %#x\n", 32 rc); 33 } 34 35 BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, disable_platform_hierarchy, 36 NULL); 37