blob: 8823978de448e5d70bba8d4ecc06eceb358b449f [file] [log] [blame]
Angel Pons3ef916f2020-04-02 23:49:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbinf56c7782017-01-10 17:44:42 -06002
3#include <bootstate.h>
4#include <console/console.h>
Philipp Deppenwiesed88fb362017-10-18 20:26:18 +02005#include <security/tpm/tss.h>
Aaron Durbinf56c7782017-01-10 17:44:42 -06006#include <vb2_api.h>
7
8static void disable_platform_hierarchy(void *unused)
9{
Jon Murphyd7b8dc92023-09-05 11:36:43 -060010 tpm_result_t rc;
Aaron Durbinf56c7782017-01-10 17:44:42 -060011
Julius Wernercd49cce2019-03-05 16:53:33 -080012 if (!CONFIG(TPM2))
Aaron Durbinf56c7782017-01-10 17:44:42 -060013 return;
14
Julius Wernercd49cce2019-03-05 16:53:33 -080015 if (!CONFIG(RESUME_PATH_SAME_AS_BOOT))
Aaron Durbinf56c7782017-01-10 17:44:42 -060016 return;
17
Jon Murphy24604812023-09-05 10:37:05 -060018 rc = tlcl_lib_init();
Aaron Durbinf56c7782017-01-10 17:44:42 -060019
Jon Murphyd7b8dc92023-09-05 11:36:43 -060020 if (rc != TPM_SUCCESS) {
Jon Murphy53fc6672023-09-26 21:05:37 -060021 printk(BIOS_ERR, "tlcl_lib_init() failed: %#x\n", rc);
Aaron Durbinf56c7782017-01-10 17:44:42 -060022 return;
23 }
24
Sergii Dmytruk47e9e8c2022-11-02 00:50:03 +020025 /* In case both families are enabled, but TPM1 is in use. */
26 if (tlcl_get_family() != TPM_2)
27 return;
28
Sergii Dmytruk094a0512022-10-31 18:41:52 +020029 rc = tlcl2_disable_platform_hierarchy();
Jon Murphy24604812023-09-05 10:37:05 -060030 if (rc != TPM_SUCCESS)
Jon Murphy53fc6672023-09-26 21:05:37 -060031 printk(BIOS_ERR, "Platform hierarchy disablement failed: %#x\n",
Jon Murphy24604812023-09-05 10:37:05 -060032 rc);
Aaron Durbinf56c7782017-01-10 17:44:42 -060033}
34
35BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, disable_platform_hierarchy,
36 NULL);