tpm2-cmd.c (9aa36b399a50bf8a1c9dae33c25164afae14e1e3) | tpm2-cmd.c (58472f5cd4f6ff02488c8da3cdbf719e9dd21e48) |
---|---|
1/* 2 * Copyright (C) 2014, 2015 Intel Corporation 3 * 4 * Authors: 5 * Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> 6 * 7 * Maintained by: <tpmdd-devel@lists.sourceforge.net> 8 * --- 1049 unchanged lines hidden (view full) --- 1058 if (i < ARRAY_SIZE(chip->active_banks)) 1059 chip->active_banks[i] = TPM2_ALG_ERROR; 1060 1061 tpm_buf_destroy(&buf); 1062 1063 return rc; 1064} 1065 | 1/* 2 * Copyright (C) 2014, 2015 Intel Corporation 3 * 4 * Authors: 5 * Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> 6 * 7 * Maintained by: <tpmdd-devel@lists.sourceforge.net> 8 * --- 1049 unchanged lines hidden (view full) --- 1058 if (i < ARRAY_SIZE(chip->active_banks)) 1059 chip->active_banks[i] = TPM2_ALG_ERROR; 1060 1061 tpm_buf_destroy(&buf); 1062 1063 return rc; 1064} 1065 |
1066static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip) 1067{ 1068 struct tpm_buf buf; 1069 u32 nr_commands; 1070 u32 *attrs; 1071 u32 cc; 1072 int i; 1073 int rc; 1074 1075 rc = tpm2_get_tpm_pt(chip, TPM_PT_TOTAL_COMMANDS, &nr_commands, NULL); 1076 if (rc) 1077 goto out; 1078 1079 if (nr_commands > 0xFFFFF) { 1080 rc = -EFAULT; 1081 goto out; 1082 } 1083 1084 chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands, 1085 GFP_KERNEL); 1086 1087 rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); 1088 if (rc) 1089 goto out; 1090 1091 tpm_buf_append_u32(&buf, TPM2_CAP_COMMANDS); 1092 tpm_buf_append_u32(&buf, TPM2_CC_FIRST); 1093 tpm_buf_append_u32(&buf, nr_commands); 1094 1095 rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 9 + 4 * nr_commands, 1096 0, NULL); 1097 if (rc) { 1098 tpm_buf_destroy(&buf); 1099 goto out; 1100 } 1101 1102 if (nr_commands != 1103 be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) { 1104 tpm_buf_destroy(&buf); 1105 goto out; 1106 } 1107 1108 chip->nr_commands = nr_commands; 1109 1110 attrs = (u32 *)&buf.data[TPM_HEADER_SIZE + 9]; 1111 for (i = 0; i < nr_commands; i++, attrs++) { 1112 chip->cc_attrs_tbl[i] = be32_to_cpup(attrs); 1113 cc = chip->cc_attrs_tbl[i] & 0xFFFF; 1114 1115 if (cc == TPM2_CC_CONTEXT_SAVE || cc == TPM2_CC_FLUSH_CONTEXT) { 1116 chip->cc_attrs_tbl[i] &= 1117 ~(GENMASK(2, 0) << TPM2_CC_ATTR_CHANDLES); 1118 chip->cc_attrs_tbl[i] |= 1 << TPM2_CC_ATTR_CHANDLES; 1119 } 1120 } 1121 1122 tpm_buf_destroy(&buf); 1123 1124out: 1125 if (rc > 0) 1126 rc = -ENODEV; 1127 return rc; 1128} 1129 |
|
1066/** 1067 * tpm2_auto_startup - Perform the standard automatic TPM initialization 1068 * sequence 1069 * @chip: TPM chip to use 1070 * | 1130/** 1131 * tpm2_auto_startup - Perform the standard automatic TPM initialization 1132 * sequence 1133 * @chip: TPM chip to use 1134 * |
1071 * Initializes timeout values for operation and command durations, conducts 1072 * a self-test and reads the list of active PCR banks. 1073 * 1074 * Return: 0 on success. Otherwise, a system error code is returned. | 1135 * Returns 0 on success, < 0 in case of fatal error. |
1075 */ 1076int tpm2_auto_startup(struct tpm_chip *chip) 1077{ 1078 int rc; 1079 1080 rc = tpm_get_timeouts(chip); 1081 if (rc) 1082 goto out; --- 12 unchanged lines hidden (view full) --- 1095 rc = tpm2_do_selftest(chip); 1096 if (rc) { 1097 dev_err(&chip->dev, "TPM self test failed\n"); 1098 goto out; 1099 } 1100 } 1101 1102 rc = tpm2_get_pcr_allocation(chip); | 1136 */ 1137int tpm2_auto_startup(struct tpm_chip *chip) 1138{ 1139 int rc; 1140 1141 rc = tpm_get_timeouts(chip); 1142 if (rc) 1143 goto out; --- 12 unchanged lines hidden (view full) --- 1156 rc = tpm2_do_selftest(chip); 1157 if (rc) { 1158 dev_err(&chip->dev, "TPM self test failed\n"); 1159 goto out; 1160 } 1161 } 1162 1163 rc = tpm2_get_pcr_allocation(chip); |
1164 if (rc) 1165 goto out; |
|
1103 | 1166 |
1167 rc = tpm2_get_cc_attrs_tbl(chip); 1168 |
|
1104out: 1105 if (rc > 0) 1106 rc = -ENODEV; 1107 return rc; 1108} | 1169out: 1170 if (rc > 0) 1171 rc = -ENODEV; 1172 return rc; 1173} |
1174 1175int tpm2_find_cc(struct tpm_chip *chip, u32 cc) 1176{ 1177 int i; 1178 1179 for (i = 0; i < chip->nr_commands; i++) 1180 if (cc == (chip->cc_attrs_tbl[i] & GENMASK(15, 0))) 1181 return i; 1182 1183 return -1; 1184} |
|