Changeset 91115 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 5, 2021 3:15:23 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Security/DevTpm.cpp
r91086 r91115 449 449 /** TPM ran into a fatal error and is not operational. */ 450 450 DEVTPMSTATE_FATAL_ERROR, 451 /** Last valid state (used for saved state sanity check). */ 452 DEVTPMSTATE_LAST_VALID = DEVTPMSTATE_FATAL_ERROR, 451 453 /** 32bit hack. */ 452 454 DEVTPMSTATE_32BIT_HACK = 0x7fffffff … … 570 572 #ifndef VBOX_DEVICE_STRUCT_TESTCASE 571 573 574 /********************************************************************************************************************************* 575 * Global Variables * 576 *********************************************************************************************************************************/ 577 #ifdef IN_RING3 578 /** 579 * SSM descriptor table for the TPM structure. 580 */ 581 static SSMFIELD const g_aTpmFields[] = 582 { 583 SSMFIELD_ENTRY(DEVTPM, fEstablishmentSet), 584 SSMFIELD_ENTRY(DEVTPM, bLoc), 585 SSMFIELD_ENTRY(DEVTPM, aLoc[0].uRegIntEn), 586 SSMFIELD_ENTRY(DEVTPM, aLoc[0].uRegIntSts), 587 SSMFIELD_ENTRY(DEVTPM, aLoc[1].uRegIntEn), 588 SSMFIELD_ENTRY(DEVTPM, aLoc[1].uRegIntSts), 589 SSMFIELD_ENTRY(DEVTPM, aLoc[2].uRegIntEn), 590 SSMFIELD_ENTRY(DEVTPM, aLoc[2].uRegIntSts), 591 SSMFIELD_ENTRY(DEVTPM, aLoc[3].uRegIntEn), 592 SSMFIELD_ENTRY(DEVTPM, aLoc[3].uRegIntSts), 593 SSMFIELD_ENTRY(DEVTPM, aLoc[4].uRegIntEn), 594 SSMFIELD_ENTRY(DEVTPM, aLoc[4].uRegIntSts), 595 SSMFIELD_ENTRY(DEVTPM, bmLocReqAcc), 596 SSMFIELD_ENTRY(DEVTPM, bmLocSeizedAcc), 597 SSMFIELD_ENTRY(DEVTPM, enmState), 598 SSMFIELD_ENTRY(DEVTPM, offCmdResp), 599 SSMFIELD_ENTRY(DEVTPM, abCmdResp), 600 SSMFIELD_ENTRY_TERM() 601 }; 602 #endif 572 603 573 604 … … 1421 1452 RT_NOREF(uPass); 1422 1453 1423 pHlp->pfnSSMPutU8(pSSM, pThis->uIrq); 1454 /* Save the part of the config used for verification purposes when restoring. */ 1455 pHlp->pfnSSMPutGCPhys(pSSM, pThis->GCPhysMmio); 1456 pHlp->pfnSSMPutU16( pSSM, pThis->uVenId); 1457 pHlp->pfnSSMPutU16( pSSM, pThis->uDevId); 1458 pHlp->pfnSSMPutU8( pSSM, pThis->bRevId); 1459 pHlp->pfnSSMPutU8( pSSM, pThis->uIrq); 1460 pHlp->pfnSSMPutBool( pSSM, pThis->fLocChangeSup); 1461 pHlp->pfnSSMPutU32( pSSM, (uint32_t)pThis->enmTpmVers); 1462 pHlp->pfnSSMPutU32( pSSM, pThis->cbCmdResp); 1463 1424 1464 return VINF_SSM_DONT_CALL_AGAIN; 1425 1465 } … … 1434 1474 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1435 1475 1436 pHlp->pfnSSMPutU8(pSSM, pThis->uIrq); 1476 tpmR3LiveExec(pDevIns, pSSM, SSM_PASS_FINAL); 1477 1478 int rc = pHlp->pfnSSMPutStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aTpmFields[0], NULL); 1479 AssertRCReturn(rc, rc); 1437 1480 1438 1481 return pHlp->pfnSSMPutU32(pSSM, UINT32_MAX); /* sanity/terminator */ … … 1447 1490 PDEVTPM pThis = PDMDEVINS_2_DATA(pDevIns, PDEVTPM); 1448 1491 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1449 uint8_t bIrq; 1450 int rc; 1451 1452 AssertMsgReturn(uVersion >= TPM_SAVED_STATE_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 1453 pHlp->pfnSSMGetU8( pSSM, &bIrq); 1492 uint8_t u8; 1493 uint16_t u16; 1494 uint32_t u32; 1495 bool f; 1496 RTGCPHYS GCPhysMmio; 1497 TPMVERSION enmTpmVers; 1498 1499 Assert(uPass == SSM_PASS_FINAL); RT_NOREF(uPass); 1500 AssertMsgReturn(uVersion == TPM_SAVED_STATE_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 1501 1502 /* Verify the config first. */ 1503 int rc = pHlp->pfnSSMGetGCPhys(pSSM, &GCPhysMmio); 1504 AssertRCReturn(rc, rc); 1505 if (GCPhysMmio != pThis->GCPhysMmio) 1506 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1507 N_("Config mismatch - saved GCPhysMmio=%#RGp; configured GCPhysMmio=%#RGp"), 1508 GCPhysMmio, pThis->GCPhysMmio); 1509 1510 rc = pHlp->pfnSSMGetU16(pSSM, &u16); 1511 AssertRCReturn(rc, rc); 1512 if (u16 != pThis->uVenId) 1513 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1514 N_("Config mismatch - saved uVenId=%#RX16; configured uVenId=%#RX16"), 1515 u16, pThis->uVenId); 1516 1517 rc = pHlp->pfnSSMGetU16(pSSM, &u16); 1518 AssertRCReturn(rc, rc); 1519 if (u16 != pThis->uDevId) 1520 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1521 N_("Config mismatch - saved uDevId=%#RX16; configured uDevId=%#RX16"), 1522 u16, pThis->uDevId); 1523 1524 rc = pHlp->pfnSSMGetU8(pSSM, &u8); 1525 AssertRCReturn(rc, rc); 1526 if (u8 != pThis->bRevId) 1527 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1528 N_("Config mismatch - saved bRevId=%#RX8; configured bDevId=%#RX8"), 1529 u8, pThis->bRevId); 1530 1531 rc = pHlp->pfnSSMGetU8(pSSM, &u8); 1532 AssertRCReturn(rc, rc); 1533 if (u8 != pThis->uIrq) 1534 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1535 N_("Config mismatch - saved uIrq=%#RX8; configured uIrq=%#RX8"), 1536 u8, pThis->uIrq); 1537 1538 rc = pHlp->pfnSSMGetBool(pSSM, &f); 1539 AssertRCReturn(rc, rc); 1540 if (f != pThis->fLocChangeSup) 1541 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1542 N_("Config mismatch - saved fLocChangeSup=%RTbool; configured fLocChangeSup=%RTbool"), 1543 f, pThis->fLocChangeSup); 1544 1545 rc = pHlp->pfnSSMGetU32(pSSM, (uint32_t *)&enmTpmVers); 1546 AssertRCReturn(rc, rc); 1547 if (enmTpmVers != pThis->enmTpmVers) 1548 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1549 N_("Config mismatch - saved enmTpmVers=%RU32; configured enmTpmVers=%RU32"), 1550 enmTpmVers, pThis->enmTpmVers); 1551 1552 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 1553 AssertRCReturn(rc, rc); 1554 if (u32 != pThis->cbCmdResp) 1555 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS, 1556 N_("Config mismatch - saved cbCmdResp=%RU32; configured cbCmdResp=%RU32"), 1557 u32, pThis->cbCmdResp); 1558 1454 1559 if (uPass == SSM_PASS_FINAL) 1455 1560 { 1561 rc = pHlp->pfnSSMGetStructEx(pSSM, pThis, sizeof(*pThis), 0 /*fFlags*/, &g_aTpmFields[0], NULL); 1562 1456 1563 /* The marker. */ 1457 uint32_t u32;1458 1564 rc = pHlp->pfnSSMGetU32(pSSM, &u32); 1459 1565 AssertRCReturn(rc, rc); 1460 1566 AssertMsgReturn(u32 == UINT32_MAX, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 1567 1568 /* Verify device state sanity. */ 1569 AssertLogRelMsgReturn( pThis->enmState > DEVTPMSTATE_INVALID 1570 && pThis->enmState <= DEVTPMSTATE_LAST_VALID, 1571 ("Invalid TPM state loaded from saved state: %#x\n", pThis->enmState), 1572 VERR_SSM_UNEXPECTED_DATA); 1573 1574 AssertLogRelMsgReturn(pThis->offCmdResp <= pThis->cbCmdResp, 1575 ("Invalid TPM command/response buffer offset loaded from saved state: %#x\n", pThis->offCmdResp), 1576 VERR_SSM_UNEXPECTED_DATA); 1461 1577 } 1462 1463 /*1464 * Check the config.1465 */1466 if (pThis->uIrq != bIrq)1467 return pHlp->pfnSSMSetCfgError(pSSM, RT_SRC_POS,1468 N_("Config mismatch - saved IRQ=%#x; configured IRQ=%#x"),1469 bIrq, pThis->uIrq);1470 1578 1471 1579 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.