Angel Pons | 3ef916f | 2020-04-02 23:49:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 2 | |
3 | #include <bootstate.h> | ||||
4 | #include <console/console.h> | ||||
Philipp Deppenwiese | d88fb36 | 2017-10-18 20:26:18 +0200 | [diff] [blame] | 5 | #include <security/tpm/tss.h> |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 6 | #include <vb2_api.h> |
7 | |||||
8 | static void disable_platform_hierarchy(void *unused) | ||||
9 | { | ||||
Jon Murphy | d7b8dc9 | 2023-09-05 11:36:43 -0600 | [diff] [blame] | 10 | tpm_result_t rc; |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 11 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 12 | if (!CONFIG(TPM2)) |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 13 | return; |
14 | |||||
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 15 | if (!CONFIG(RESUME_PATH_SAME_AS_BOOT)) |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 16 | return; |
17 | |||||
Jon Murphy | 2460481 | 2023-09-05 10:37:05 -0600 | [diff] [blame] | 18 | rc = tlcl_lib_init(); |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 19 | |
Jon Murphy | d7b8dc9 | 2023-09-05 11:36:43 -0600 | [diff] [blame] | 20 | if (rc != TPM_SUCCESS) { |
Jon Murphy | 53fc667 | 2023-09-26 21:05:37 -0600 | [diff] [blame] | 21 | printk(BIOS_ERR, "tlcl_lib_init() failed: %#x\n", rc); |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 22 | return; |
23 | } | ||||
24 | |||||
Sergii Dmytruk | 47e9e8c | 2022-11-02 00:50:03 +0200 | [diff] [blame^] | 25 | /* In case both families are enabled, but TPM1 is in use. */ |
26 | if (tlcl_get_family() != TPM_2) | ||||
27 | return; | ||||
28 | |||||
Sergii Dmytruk | 094a051 | 2022-10-31 18:41:52 +0200 | [diff] [blame] | 29 | rc = tlcl2_disable_platform_hierarchy(); |
Jon Murphy | 2460481 | 2023-09-05 10:37:05 -0600 | [diff] [blame] | 30 | if (rc != TPM_SUCCESS) |
Jon Murphy | 53fc667 | 2023-09-26 21:05:37 -0600 | [diff] [blame] | 31 | printk(BIOS_ERR, "Platform hierarchy disablement failed: %#x\n", |
Jon Murphy | 2460481 | 2023-09-05 10:37:05 -0600 | [diff] [blame] | 32 | rc); |
Aaron Durbin | f56c778 | 2017-01-10 17:44:42 -0600 | [diff] [blame] | 33 | } |
34 | |||||
35 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, disable_platform_hierarchy, | ||||
36 | NULL); |