Changeset 90908 in vbox
- Timestamp:
- Aug 26, 2021 10:27:04 AM (3 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 1 added
- 4 edited
-
Makefile.kmk (modified) (3 diffs)
-
PC/ACPI/VBoxAcpi.cpp (modified) (2 diffs)
-
PC/DevACPI.cpp (modified) (13 diffs)
-
PC/vbox-tpm.dsl (added)
-
build/VBoxDD.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Makefile.kmk
r90530 r90908 907 907 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.aml \ 908 908 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.aml.tmp \ 909 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.aml.pre 909 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.aml.pre \ 910 $(if $(VBOX_WITH_TPM),$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.hex,) \ 911 $(if $(VBOX_WITH_TPM),$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.aml,) \ 912 $(if $(VBOX_WITH_TPM),$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.aml.tmp,) 910 913 PC/ACPI/VBoxAcpi.cpp_DEPS = \ 911 914 $(VBoxDD_0_OUTDIR)/vboxaml.hex \ 912 915 $(VBoxDD_0_OUTDIR)/vboxssdt_standard.hex \ 913 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.hex 916 $(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.hex \ 917 $(if $(VBOX_WITH_TPM),$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.hex,) 914 918 915 919 $$(VBoxDD_0_OUTDIR)/vboxaml.hex: $(PATH_SUB_CURRENT)/PC/vbox.dsl | $$(dir $$@) … … 949 953 950 954 vboxssdt_cpuhotplug.hex:: $$(VBoxDD_0_OUTDIR)/vboxssdt_cpuhotplug.hex 955 956 if defined(VBOX_WITH_TPM) 957 $$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.hex: $(PATH_SUB_CURRENT)/PC/vbox-tpm.dsl | $$(dir $$@) 958 $(call MSG_TOOL,iasl,VBoxDD,$<,$@) 959 $(QUIET)$(RM) -f $@ $@.tmp 960 $(QUIET)$(VBOX_IASLCMD) -tc -vs -p $@ $< 961 $(QUIET)$(MV) -f $@ $@.tmp 962 $(QUIET)$(SED) -e "s/AmlCode\|vboxssdt_tpm_aml_code/AmlCodeSsdtTpm/g" \ 963 --output $@ $@.tmp 964 $(QUIET)$(RM) -f $@.tmp 965 966 vboxssdt_tpm.hex:: $$(VBoxDD_0_OUTDIR)/vboxssdt_tpm.hex 967 endif # !VBOX_WITH_TPM 951 968 952 969 endif # !VBOX_WITH_DYNAMIC_DSDT … … 1338 1355 endif 1339 1356 1357 if defined(VBOX_WITH_TPM) 1358 VBoxDDR0_DEFS += VBOX_WITH_TPM 1359 VBoxDDR0_SOURCES += \ 1360 Security/DevTpm.cpp 1361 endif 1362 1340 1363 ifdef VBOX_WITH_HGSMI 1341 1364 VBoxDDR0_DEFS += VBOX_WITH_HGSMI -
trunk/src/VBox/Devices/PC/ACPI/VBoxAcpi.cpp
r85992 r90908 45 45 # include <vboxssdt_standard.hex> 46 46 # include <vboxssdt_cpuhotplug.hex> 47 # ifdef VBOX_WITH_TPM 48 # include <vboxssdt_tpm.hex> 49 # endif 47 50 #endif 48 51 … … 443 446 } 444 447 448 #ifdef VBOX_WITH_TPM 449 /** No docs, lazy coder. */ 450 int acpiPrepareTpmSsdt(PPDMDEVINS pDevIns, void **ppvPtr, size_t *pcbSsdt) 451 { 452 uint8_t *pabAmlCodeSsdt = NULL; 453 size_t cbAmlCodeSsdt = 0; 454 int rc = acpiAmlLoadExternal(pDevIns, "SsdtTpmFilePath", "SSDT", &pabAmlCodeSsdt, &cbAmlCodeSsdt); 455 if (rc == VERR_CFGM_VALUE_NOT_FOUND) 456 { 457 rc = VINF_SUCCESS; 458 cbAmlCodeSsdt = sizeof(AmlCodeSsdtTpm); 459 pabAmlCodeSsdt = (uint8_t *)RTMemDup(AmlCodeSsdtTpm, sizeof(AmlCodeSsdtTpm)); 460 if (!pabAmlCodeSsdt) 461 rc = VERR_NO_MEMORY; 462 } 463 else if (RT_FAILURE(rc)) 464 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"SsdtFilePath\"")); 465 466 if (RT_SUCCESS(rc)) 467 { 468 *ppvPtr = pabAmlCodeSsdt; 469 *pcbSsdt = cbAmlCodeSsdt; 470 } 471 return rc; 472 } 473 474 /** No docs, lazy coder. */ 475 int acpiCleanupTpmSsdt(PPDMDEVINS pDevIns, void *pvPtr) 476 { 477 RT_NOREF1(pDevIns); 478 if (pvPtr) 479 RTMemFree(pvPtr); 480 return VINF_SUCCESS; 481 } 482 #endif 483 -
trunk/src/VBox/Devices/PC/DevACPI.cpp
r90447 r90908 296 296 * Structures and Typedefs * 297 297 *********************************************************************************************************************************/ 298 /** 299 * The TPM mode configured. 300 */ 301 typedef enum ACPITPMMODE 302 { 303 ACPITPMMODE_INVALID = 0, 304 ACPITPMMODE_DISABLED, 305 ACPITPMMODE_TIS_1_2, 306 ACPITPMMODE_CRB_2_0, 307 ACPITPMMODE_FIFO_2_0, 308 ACPITPMMODE_32BIT_HACK = 0x7fffffff 309 } ACPITPMMODE; 310 311 298 312 /** 299 313 * The shared ACPI device state. … … 439 453 uint8_t uParallel1Irq; 440 454 /** @} */ 455 456 #ifdef VBOX_WITH_TPM 457 /** @name TPM config bits 458 * @{ */ 459 /** The ACPI TPM mode configured. */ 460 ACPITPMMODE enmTpmMode; 461 /** The MMIO register area base address. */ 462 RTGCPHYS GCPhysTpmMmio; 463 /** @} */ 464 #endif 441 465 442 466 /** Number of custom ACPI tables */ … … 900 924 901 925 926 #ifdef VBOX_WITH_TPM 927 /** 928 * TPM: The ACPI table for a TPM 2.0 device 929 * (from: https://trustedcomputinggroup.org/wp-content/uploads/TCG_ACPIGeneralSpec_v1p3_r8_pub.pdf). 930 */ 931 typedef struct ACPITBLTPM20 932 { 933 /** The common ACPI table header. */ 934 ACPITBLHEADER Hdr; 935 /** The platform class. */ 936 uint16_t u16PlatCls; 937 /** Reserved. */ 938 uint16_t u16Rsvd0; 939 /** Address of the CRB control area or FIFO base address. */ 940 uint64_t u64BaseAddrCrbOrFifo; 941 /** The start method selector. */ 942 uint32_t u32StartMethod; 943 /** Following are start method specific parameters and optional LAML and LASA fields we don't implement right now. */ 944 /** @todo */ 945 } ACPITBLTPM20; 946 AssertCompileSize(ACPITBLTPM20, 52); 947 948 /** Revision of the TPM2.0 ACPI table. */ 949 #define ACPI_TPM20_REVISION 4 950 /** The default MMIO base address of the TPM. */ 951 #define ACPI_TPM_MMIO_BASE_DEFAULT 0xfed40000 952 953 954 /** @name Possible values for the ACPITBLTPM20::u16PlatCls member. 955 * @{ */ 956 /** Client platform. */ 957 #define ACPITBL_TPM20_PLAT_CLS_CLIENT UINT16_C(0) 958 /** Server platform. */ 959 #define ACPITBL_TPM20_PLAT_CLS_SERVER UINT16_C(1) 960 /** @} */ 961 962 963 /** @name Possible values for the ACPITBLTPM20::u32StartMethod member. 964 * @{ */ 965 /** MMIO interface (TIS1.2+Cancel). */ 966 #define ACPITBL_TPM20_START_METHOD_TIS12 UINT16_C(6) 967 /** CRB interface. */ 968 #define ACPITBL_TPM20_START_METHOD_CRB UINT16_C(7) 969 /** @} */ 970 #endif 971 972 902 973 #pragma pack() 903 974 … … 2812 2883 acpiR3PhysCopy(pDevIns, addr, pvSrc, uSsdtLen); 2813 2884 } 2885 2886 #ifdef VBOX_WITH_TPM 2887 /** 2888 * Plant the Secondary System Description Table (SSDT). 2889 */ 2890 static void acpiR3SetupTpmSsdt(PPDMDEVINS pDevIns, RTGCPHYS32 addr, void const *pvSrc, size_t uSsdtLen) 2891 { 2892 acpiR3PhysCopy(pDevIns, addr, pvSrc, uSsdtLen); 2893 } 2894 #endif 2814 2895 2815 2896 /** … … 3415 3496 3416 3497 3498 #ifdef VBOX_WITH_TPM 3499 /** 3500 * Plant the TPM 2.0 ACPI descriptor. 3501 */ 3502 static void acpiR3SetupTpm(PPDMDEVINS pDevIns, PACPISTATE pThis, RTGCPHYS32 addr) 3503 { 3504 ACPITBLTPM20 Tpm2Tbl; 3505 RT_ZERO(Tpm2Tbl); 3506 3507 acpiR3PrepareHeader(pThis, &Tpm2Tbl.Hdr, "TPM2", sizeof(ACPITBLTPM20), ACPI_TPM20_REVISION); 3508 3509 switch (pThis->enmTpmMode) 3510 { 3511 case ACPITPMMODE_CRB_2_0: 3512 Tpm2Tbl.u32StartMethod = ACPITBL_TPM20_START_METHOD_CRB; 3513 Tpm2Tbl.u64BaseAddrCrbOrFifo = pThis->GCPhysTpmMmio; 3514 break; 3515 case ACPITPMMODE_TIS_1_2: 3516 case ACPITPMMODE_FIFO_2_0: 3517 Tpm2Tbl.u32StartMethod = ACPITBL_TPM20_START_METHOD_TIS12; 3518 break; 3519 case ACPITPMMODE_DISABLED: /* Should never be called with the TPM disabled. */ 3520 default: 3521 AssertFailed(); 3522 } 3523 3524 Tpm2Tbl.u16PlatCls = ACPITBL_TPM20_PLAT_CLS_CLIENT; 3525 3526 /* Finally, compute checksum. */ 3527 Tpm2Tbl.Hdr.u8Checksum = acpiR3Checksum(&Tpm2Tbl, sizeof(Tpm2Tbl)); 3528 3529 /* Plant the ACPI table. */ 3530 acpiR3PhysCopy(pDevIns, addr, (const uint8_t *)&Tpm2Tbl, sizeof(Tpm2Tbl)); 3531 } 3532 #endif 3533 3534 3417 3535 /** 3418 3536 * Used by acpiR3PlantTables to plant a MMCONFIG PCI config space access (MCFG) … … 3517 3635 RTGCPHYS32 GCPhysIommu = 0; 3518 3636 #endif 3637 #ifdef VBOX_WITH_TPM 3638 RTGCPHYS32 GCPhysTpm = 0; 3639 RTGCPHYS32 GCPhysSsdtTpm = 0; 3640 #endif 3519 3641 RTGCPHYS32 GCPhysApic = 0; 3520 3642 RTGCPHYS32 GCPhysSsdt = 0; … … 3523 3645 uint32_t addend = 0; 3524 3646 #if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL) 3647 # ifdef VBOX_WITH_TPM 3648 RTGCPHYS32 aGCPhysRsdt[10 + MAX_CUST_TABLES]; 3649 RTGCPHYS32 aGCPhysXsdt[10 + MAX_CUST_TABLES]; 3650 # else 3525 3651 RTGCPHYS32 aGCPhysRsdt[8 + MAX_CUST_TABLES]; 3526 3652 RTGCPHYS32 aGCPhysXsdt[8 + MAX_CUST_TABLES]; 3653 # endif 3527 3654 #else 3655 # ifdef VBOX_WITH_TPM 3656 RTGCPHYS32 aGCPhysRsdt[9 + MAX_CUST_TABLES]; 3657 RTGCPHYS32 aGCPhysXsdt[9 + MAX_CUST_TABLES]; 3658 # else 3528 3659 RTGCPHYS32 aGCPhysRsdt[7 + MAX_CUST_TABLES]; 3529 3660 RTGCPHYS32 aGCPhysXsdt[7 + MAX_CUST_TABLES]; 3661 # endif 3530 3662 #endif 3531 3663 uint32_t cAddr; … … 3535 3667 uint32_t iIommu = 0; 3536 3668 #endif 3669 #ifdef VBOX_WITH_TPM 3670 uint32_t iTpm = 0; 3671 uint32_t iSsdtTpm = 0; 3672 #endif 3537 3673 uint32_t iSsdt = 0; 3538 3674 uint32_t iMcfg = 0; … … 3556 3692 if (pThis->fUseIommuIntel) 3557 3693 iIommu = cAddr++; /* IOMMU (Intel) */ 3694 #endif 3695 3696 #ifdef VBOX_WITH_TPM 3697 if (pThis->enmTpmMode != ACPITPMMODE_DISABLED) 3698 { 3699 iTpm = cAddr++; /* TPM device */ 3700 iSsdtTpm = cAddr++; 3701 } 3558 3702 #endif 3559 3703 … … 3644 3788 GCPhysIommu = GCPhysCur; 3645 3789 GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLVTD), 16); 3790 } 3791 #endif 3792 #ifdef VBOX_WITH_TPM 3793 void *pvSsdtTpmCode = NULL; 3794 size_t cbSsdtTpm = 0; 3795 3796 if (pThis->enmTpmMode != ACPITPMMODE_DISABLED) 3797 { 3798 GCPhysTpm = GCPhysCur; 3799 GCPhysCur = RT_ALIGN_32(GCPhysCur + sizeof(ACPITBLTPM20), 16); /** @todo TPM1.2 */ 3800 3801 rc = acpiPrepareTpmSsdt(pDevIns, &pvSsdtTpmCode, &cbSsdtTpm); 3802 if (RT_FAILURE(rc)) 3803 return rc; 3804 3805 GCPhysSsdtTpm = GCPhysCur; 3806 GCPhysCur = RT_ALIGN_32(GCPhysCur + cbSsdtTpm, 16); 3646 3807 } 3647 3808 #endif … … 3735 3896 } 3736 3897 #endif 3898 #ifdef VBOX_WITH_TPM 3899 if (pThis->enmTpmMode != ACPITPMMODE_DISABLED) 3900 { 3901 acpiR3SetupTpm(pDevIns, pThis, GCPhysTpm + addend); 3902 aGCPhysRsdt[iTpm] = GCPhysTpm + addend; 3903 aGCPhysXsdt[iTpm] = GCPhysTpm + addend; 3904 3905 acpiR3SetupTpmSsdt(pDevIns, GCPhysSsdtTpm + addend, pvSsdtTpmCode, cbSsdtTpm); 3906 acpiCleanupTpmSsdt(pDevIns, pvSsdtTpmCode); 3907 aGCPhysRsdt[iSsdtTpm] = GCPhysSsdtTpm + addend; 3908 aGCPhysXsdt[iSsdtTpm] = GCPhysSsdtTpm + addend; 3909 } 3910 #endif 3911 3737 3912 if (pThis->fUseMcfg) 3738 3913 { … … 4095 4270 "|IommuPciAddress" 4096 4271 "|SbIoApicPciAddress" 4272 "|TpmMode" 4273 "|TpmMmioAddress" 4274 "|SsdtTpmFilePath" 4097 4275 , ""); 4098 4276 … … 4317 4495 && pThis->fUseIommuIntel) 4318 4496 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Cannot enable Intel and AMD IOMMU simultaneously!")); 4497 4498 #ifdef VBOX_WITH_TPM 4499 char szTpmMode[64]; RT_ZERO(szTpmMode); 4500 4501 rc = pHlp->pfnCFGMQueryStringDef(pCfg, "TpmMode", &szTpmMode[0], RT_ELEMENTS(szTpmMode) - 1, "disabled"); 4502 if (RT_FAILURE(rc)) 4503 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"TpmMode\"")); 4504 4505 if (!RTStrICmp(szTpmMode, "disabled")) 4506 pThis->enmTpmMode = ACPITPMMODE_DISABLED; 4507 else if (!RTStrICmp(szTpmMode, "tis1.2")) 4508 pThis->enmTpmMode = ACPITPMMODE_TIS_1_2; 4509 else if (!RTStrICmp(szTpmMode, "crb2.0")) 4510 pThis->enmTpmMode = ACPITPMMODE_CRB_2_0; 4511 else if (!RTStrICmp(szTpmMode, "fifo2.0")) 4512 pThis->enmTpmMode = ACPITPMMODE_FIFO_2_0; 4513 else 4514 return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER, N_("Configuration error: Value of \"TpmMode\" is not known")); 4515 4516 rc = pHlp->pfnCFGMQueryU64Def(pCfg, "TpmMmioAddress", (uint64_t *)&pThis->GCPhysTpmMmio, ACPI_TPM_MMIO_BASE_DEFAULT); 4517 if (RT_FAILURE(rc)) 4518 return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"TpmMmioAddress\"")); 4519 #endif 4319 4520 4320 4521 /* Try to attach the other CPUs */ -
trunk/src/VBox/Devices/build/VBoxDD.h
r90530 r90908 214 214 int acpiCleanupSsdt(PPDMDEVINS pDevIns, void *pvPtr); 215 215 216 #ifdef VBOX_WITH_TPM 217 int acpiPrepareTpmSsdt(PPDMDEVINS pDevIns, void **ppvPtr, size_t *pcbSsdt); 218 int acpiCleanupTpmSsdt(PPDMDEVINS pDevIns, void *pvPtr); 219 #endif 220 216 221 RT_C_DECLS_END 217 222
Note:
See TracChangeset
for help on using the changeset viewer.

