Changeset 91084 in vbox for trunk/src/VBox/Devices/Security/DevTpm.cpp
- Timestamp:
- Sep 2, 2021 9:18:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Security/DevTpm.cpp
r91067 r91084 493 493 /** Flag whether the TPM driver below supportes other localities than 0. */ 494 494 bool fLocChangeSup; 495 /** Flag whether the establishment bit is set. */ 496 bool fEstablishmentSet; 495 497 496 498 /** Currently selected locality. */ … … 709 711 && pThis->bmLocReqAcc & RT_BIT_32(bLoc)) 710 712 u64 |= TPM_FIFO_LOCALITY_REG_ACCESS_REQUEST_USE; 711 /** @todo Establishment bit. */ 713 if (pThis->fEstablishmentSet) 714 u64 |= TPM_FIFO_LOCALITY_REG_ACCESS_ESTABLISHMENT; 712 715 break; 713 716 case TPM_FIFO_LOCALITY_REG_INT_ENABLE: … … 800 803 uint8_t bLoc, uint32_t uReg, uint64_t u64, size_t cb) 801 804 { 802 RT_NOREF(pDevIns); 805 #ifdef IN_RING3 806 PDEVTPMR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVTPMR3); 807 #endif 803 808 804 809 /* Special path for the data buffer. */ … … 871 876 if (bLoc != pThis->bLoc) 872 877 break; 873 /** @todo */ 878 pLoc->uRegIntEn = u32; 879 tpmLocIrqUpdate(pDevIns, pThis, pLoc); 874 880 break; 875 881 case TPM_FIFO_LOCALITY_REG_INT_STS: … … 904 910 rc = PDMDevHlpTaskTrigger(pDevIns, pThis->hTpmCmdTask); 905 911 } 906 /** @todo Cancel and reset establishment. */ 912 913 if ( (u64 & TPM_FIFO_LOCALITY_REG_STS_RST_ESTABLISHMENT) 914 && pThis->bLoc >= 3 915 && ( pThis->enmState == DEVTPMSTATE_IDLE 916 || pThis->enmState == DEVTPMSTATE_CMD_COMPLETION)) 917 { 918 #ifndef IN_RING3 919 rc = VINF_IOM_R3_MMIO_WRITE; 920 break; 921 #else 922 if (pThisCC->pDrvTpm) 923 { 924 int rc2 = pThisCC->pDrvTpm->pfnResetEstablishedFlag(pThisCC->pDrvTpm, pThis->bLoc); 925 if (RT_SUCCESS(rc2)) 926 pThis->fEstablishmentSet = false; 927 else 928 pThis->enmState == DEVTPMSTATE_FATAL_ERROR; 929 } 930 else 931 pThis->fEstablishmentSet = false; 932 #endif 933 } 934 935 if ( (u64 & TPM_FIFO_LOCALITY_REG_STS_CMD_CANCEL) 936 && pThis->enmState == DEVTPMSTATE_CMD_EXEC) 937 { 938 #ifndef IN_RING3 939 rc = VINF_IOM_R3_MMIO_WRITE; 940 break; 941 #else 942 if (pThisCC->pDrvTpm) 943 { 944 pThis->enmState = DEVTPMSTATE_CMD_CANCEL; 945 int rc2 = pThisCC->pDrvTpm->pfnCmdCancel(pThisCC->pDrvTpm); 946 if (RT_FAILURE(rc2)) 947 pThis->enmState == DEVTPMSTATE_FATAL_ERROR; 948 } 949 #endif 950 } 951 907 952 break; 908 953 case TPM_FIFO_LOCALITY_REG_INT_VEC: … … 954 999 ? TPM_CRB_LOCALITY_REG_STATE_ACTIVE_LOC_SET(pThis->bLoc) | TPM_CRB_LOCALITY_REG_STATE_LOC_ASSIGNED 955 1000 : TPM_CRB_LOCALITY_REG_STATE_ACTIVE_LOC_SET(0)); 1001 if (pThis->fEstablishmentSet) 1002 u64 |= TPM_CRB_LOCALITY_REG_ESTABLISHMENT; 956 1003 break; 957 1004 case TPM_CRB_LOCALITY_REG_STS: … … 1061 1108 uint8_t bLoc, uint32_t uReg, uint64_t u64, size_t cb) 1062 1109 { 1110 #ifdef IN_RING3 1111 PDEVTPMR3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVTPMR3); 1112 #endif 1113 1063 1114 VBOXSTRICTRC rc = VINF_SUCCESS; 1064 1115 uint32_t u32 = (uint32_t)u64; … … 1081 1132 { 1082 1133 /* See chapter 6.5.3.2.2.1. */ 1083 #if 0 1084 if (u64 & TPM_CRB_LOCALITY_REG_CTRL_RST_ESTABLISHMENT) 1085 /** @todo */; 1134 if ( (u64 & TPM_CRB_LOCALITY_REG_CTRL_RST_ESTABLISHMENT) 1135 && pThis->bLoc >= 3 1136 && ( pThis->enmState == DEVTPMSTATE_IDLE 1137 || pThis->enmState == DEVTPMSTATE_CMD_COMPLETION)) 1138 { 1139 #ifndef IN_RING3 1140 rc = VINF_IOM_R3_MMIO_WRITE; 1141 break; 1142 #else 1143 if (pThisCC->pDrvTpm) 1144 { 1145 int rc2 = pThisCC->pDrvTpm->pfnResetEstablishedFlag(pThisCC->pDrvTpm, pThis->bLoc); 1146 if (RT_SUCCESS(rc2)) 1147 pThis->fEstablishmentSet = false; 1148 else 1149 pThis->enmState == DEVTPMSTATE_FATAL_ERROR; 1150 } 1151 else 1152 pThis->fEstablishmentSet = false; 1086 1153 #endif 1154 } 1087 1155 1088 1156 /* … … 1095 1163 && bLoc > pThis->bLoc) 1096 1164 { 1165 if (pThis->enmState == DEVTPMSTATE_CMD_EXEC) 1166 { 1167 #ifndef IN_RING3 1168 rc = VINF_IOM_R3_MMIO_WRITE; 1169 break; 1170 #else 1171 pThis->enmState = DEVTPMSTATE_CMD_CANCEL; 1172 if (pThisCC->pDrvTpm) 1173 { 1174 int rc2 = pThisCC->pDrvTpm->pfnCmdCancel(pThisCC->pDrvTpm); 1175 if (RT_FAILURE(rc2)) 1176 pThis->enmState == DEVTPMSTATE_FATAL_ERROR; 1177 else 1178 { 1179 pThis->enmState = DEVTPMSTATE_CMD_COMPLETION; 1180 tpmLocSetIntSts(pDevIns, pThis, pLoc, TPM_CRB_LOCALITY_REG_INT_STS_START); 1181 } 1182 } 1183 #endif 1184 } 1185 1097 1186 pThis->bmLocSeizedAcc |= RT_BIT_32(pThis->bLoc); 1098 /** @todo Abort command. */1099 1187 pThis->bLoc = bLoc; 1100 1188 } … … 1150 1238 && u32 == 0x1) 1151 1239 { 1240 #ifndef IN_RING3 1241 rc = VINF_IOM_R3_MMIO_WRITE; 1242 break; 1243 #else 1152 1244 pThis->enmState = DEVTPMSTATE_CMD_CANCEL; 1153 /** @todo Cancel. */ 1154 pThis->enmState = DEVTPMSTATE_CMD_COMPLETION; 1155 tpmLocSetIntSts(pDevIns, pThis, pLoc, TPM_CRB_LOCALITY_REG_INT_STS_START); 1245 if (pThisCC->pDrvTpm) 1246 { 1247 int rc2 = pThisCC->pDrvTpm->pfnCmdCancel(pThisCC->pDrvTpm); 1248 if (RT_FAILURE(rc2)) 1249 pThis->enmState == DEVTPMSTATE_FATAL_ERROR; 1250 else 1251 { 1252 pThis->enmState = DEVTPMSTATE_CMD_COMPLETION; 1253 tpmLocSetIntSts(pDevIns, pThis, pLoc, TPM_CRB_LOCALITY_REG_INT_STS_START); 1254 } 1255 } 1256 #endif 1156 1257 } 1157 1258 break; … … 1521 1622 AssertLogRelMsgReturn(pThisCC->pDrvTpm, ("TPM#%d: Driver is missing the TPM interface.\n", iInstance), VERR_PDM_MISSING_INTERFACE); 1522 1623 1523 pThis->fLocChangeSup = pThisCC->pDrvTpm->pfnGetLocalityMax(pThisCC->pDrvTpm) > 0; 1524 pThis->cbCmdResp = RT_MIN(pThisCC->pDrvTpm->pfnGetBufferSize(pThisCC->pDrvTpm), TPM_DATA_BUFFER_SIZE_MAX); 1624 pThis->fLocChangeSup = pThisCC->pDrvTpm->pfnGetLocalityMax(pThisCC->pDrvTpm) > 0; 1625 pThis->fEstablishmentSet = pThisCC->pDrvTpm->pfnGetEstablishedFlag(pThisCC->pDrvTpm); 1626 pThis->cbCmdResp = RT_MIN(pThisCC->pDrvTpm->pfnGetBufferSize(pThisCC->pDrvTpm), TPM_DATA_BUFFER_SIZE_MAX); 1525 1627 1526 1628 /* Startup the TPM here instead of in the power on callback as we can convey errors here to the upper layer. */ … … 1535 1637 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 1536 1638 { 1537 pThis->fLocChangeSup = false; 1639 pThis->fLocChangeSup = false; 1640 pThis->fEstablishmentSet = false; 1538 1641 1539 1642 pThisCC->pDrvBase = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.