From d9533c342dd90bb3404ecfba87ad3703e038bb6d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 5 Aug 2024 11:23:06 +0200 Subject: Merging upstream version 7.0.20-dfsg. Signed-off-by: Daniel Baumann --- src/VBox/Devices/EFI/Firmware/Makefile.kmk | 6 +-- .../DxeTcg2PhysicalPresenceLib.c | 46 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) (limited to 'src/VBox/Devices/EFI/Firmware') diff --git a/src/VBox/Devices/EFI/Firmware/Makefile.kmk b/src/VBox/Devices/EFI/Firmware/Makefile.kmk index 02395eb5..7f597026 100644 --- a/src/VBox/Devices/EFI/Firmware/Makefile.kmk +++ b/src/VBox/Devices/EFI/Firmware/Makefile.kmk @@ -198,15 +198,15 @@ if1of ($(KBUILD_HOST), win) VBOX_EFI_REDIRECT_E_EQUAL := $(EQUAL) VBOX_EFI_BUILD_CMD = $(REDIRECT) \ -E 'PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH);' \ - -E 'INCLUDE=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_SEP)$(PATH_TOOL_$(VBOX_VCC_TOOL)_INC)$(INCLUDE);' \ + -E 'INCLUDE=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_PATH_EFI_FIRMWARE)/..$(VBOX_SEP)$(PATH_TOOL_$(VBOX_VCC_TOOL)_INC)$(INCLUDE);' \ -E 'COMSPEC=$(firstword $(windir) $(SystemRoot) C:\windows)\system32\cmd.exe' \ -E 'MAKEFLAGS=' else VBOX_EFI_REDIRECT_E_EQUAL := VBOX_EFI_BUILD_CMD = $(REDIRECT) \ -E "PATH=$(VBOX_PATH_STAGE_EFI_BLDPROGS)$(VBOX_SEP)$(PATH)" \ - -E "C_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)" \ - -E "CPLUS_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(C_INCLUDE_PATH)" + -E "C_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_PATH_EFI_FIRMWARE)/..$(VBOX_SEP)$(C_INCLUDE_PATH)" \ + -E "CPLUS_INCLUDE_PATH=$(PATH_ROOT)/include$(VBOX_SEP)$(PATH_OUT)$(VBOX_SEP)$(VBOX_PATH_EFI_FIRMWARE)/..$(VBOX_SEP)$(CPLUS_INCLUDE_PATH)" endif VBOX_EFI_BUILD_CMD += \ -E 'PYTHONPATH=$(VBOX_PATH_EFI_FIRMWARE)/BaseTools/Source/Python' \ diff --git a/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c b/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c index 226743dc..29e53bc9 100644 --- a/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c +++ b/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c @@ -35,6 +35,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include +#if defined(VBOX) +# define IN_RING0 +# include "../../../../DevEFI.h" +# include "iprt/cdefs.h" /* RT_ARCH_XXX */ + +# if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64) +# include "iprt/asm-amd64-x86.h" + +/* + * Internal Functions + */ +static UINT32 +GetVmVariable(UINT32 Variable, CHAR8 *pbBuf, UINT32 cbBuf) +{ + UINT32 cbVar, offBuf; + + ASMOutU32(EFI_INFO_PORT, Variable); + cbVar = ASMInU32(EFI_INFO_PORT); + + for (offBuf = 0; offBuf < cbVar && offBuf < cbBuf; offBuf++) + pbBuf[offBuf] = ASMInU8(EFI_INFO_PORT); + + return cbVar; +} +# endif +#endif + #define CONFIRM_BUFFER_SIZE 4096 EFI_HII_HANDLE mTcg2PpStringPackHandle; @@ -44,6 +71,8 @@ EFI_HII_HANDLE mTcg2PpStringPackHandle; STATIC volatile QEMU_TPM_PPI *mPpi; +#if !defined(VBOX) \ + || (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) /** Reads QEMU PPI config from fw_cfg. @@ -75,6 +104,7 @@ QemuTpmReadConfig ( QemuFwCfgReadBytes (sizeof (*Config), Config); return EFI_SUCCESS; } +#endif /** @@ -90,7 +120,9 @@ QemuTpmInitPPI ( ) { EFI_STATUS Status; +#ifndef VBOX QEMU_FWCFG_TPM_CONFIG Config; +#endif EFI_PHYSICAL_ADDRESS PpiAddress64; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; UINTN Idx; @@ -99,6 +131,8 @@ QemuTpmInitPPI ( return EFI_SUCCESS; } +#if !defined(VBOX) \ + || (!defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)) Status = QemuTpmReadConfig (&Config); if (EFI_ERROR (Status)) { return Status; @@ -108,6 +142,14 @@ QemuTpmInitPPI ( if (mPpi == NULL) { return EFI_PROTOCOL_ERROR; } +#else + uint64_t u64TpmPpiBase = 0; + if ( GetVmVariable(EFI_INFO_INDEX_TPM_PPI_BASE, (CHAR8 *)&u64TpmPpiBase, sizeof(u64TpmPpiBase)) != sizeof(u64TpmPpiBase) + || u64TpmPpiBase == 0) + return EFI_PROTOCOL_ERROR; + + mPpi = (QEMU_TPM_PPI *)(UINTN)u64TpmPpiBase; +#endif DEBUG ((DEBUG_INFO, "[TPM2PP] mPpi=%p version=%d\n", mPpi, Config.TpmVersion)); @@ -133,7 +175,9 @@ QemuTpmInitPPI ( for (Idx = 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) { mPpi->Func[Idx] = 0; } +#ifndef VBOX if (Config.TpmVersion == QEMU_TPM_VERSION_2) { +#endif mPpi->Func[TCG2_PHYSICAL_PRESENCE_NO_ACTION] = TPM_PPI_FLAGS; mPpi->Func[TCG2_PHYSICAL_PRESENCE_CLEAR] = TPM_PPI_FLAGS; mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_CLEAR] = TPM_PPI_FLAGS; @@ -144,7 +188,9 @@ QemuTpmInitPPI ( mPpi->Func[TCG2_PHYSICAL_PRESENCE_LOG_ALL_DIGESTS] = TPM_PPI_FLAGS; mPpi->Func[TCG2_PHYSICAL_PRESENCE_ENABLE_BLOCK_SID] = TPM_PPI_FLAGS; mPpi->Func[TCG2_PHYSICAL_PRESENCE_DISABLE_BLOCK_SID] = TPM_PPI_FLAGS; +#ifndef VBOX } +#endif if (mPpi->In == 0) { mPpi->In = 1; -- cgit v1.2.3