summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Devices/EFI')
-rw-r--r--src/VBox/Devices/EFI/DevEFI.cpp12
-rw-r--r--src/VBox/Devices/EFI/DevEFI.h1
-rw-r--r--src/VBox/Devices/EFI/Firmware/Makefile.kmk6
-rw-r--r--src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.c46
-rw-r--r--src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fdbin4194304 -> 4194304 bytes
-rw-r--r--src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fdbin4194304 -> 4194304 bytes
6 files changed, 61 insertions, 4 deletions
diff --git a/src/VBox/Devices/EFI/DevEFI.cpp b/src/VBox/Devices/EFI/DevEFI.cpp
index e14f6858..35b6cca7 100644
--- a/src/VBox/Devices/EFI/DevEFI.cpp
+++ b/src/VBox/Devices/EFI/DevEFI.cpp
@@ -201,6 +201,8 @@ typedef struct DEVEFIR3
uint64_t u64McfgBase;
/** Length of PCI config space MMIO region */
uint64_t cbMcfgLength;
+ /** Physical address of the TPM PPI area. */
+ uint64_t u64TpmPpiBase;
/** Size of the configured NVRAM device. */
uint32_t cbNvram;
/** Start address of the NVRAM flash. */
@@ -331,6 +333,7 @@ static uint32_t efiInfoSize(PDEVEFIR3 pThisCC)
case EFI_INFO_INDEX_TSC_FREQUENCY:
case EFI_INFO_INDEX_MCFG_BASE:
case EFI_INFO_INDEX_MCFG_SIZE:
+ case EFI_INFO_INDEX_TPM_PPI_BASE:
return 8;
case EFI_INFO_INDEX_APIC_MODE:
return 1;
@@ -433,6 +436,7 @@ static uint8_t efiInfoNextByte(PDEVEFIR3 pThisCC)
case EFI_INFO_INDEX_MCFG_BASE: return efiInfoNextByteU64(pThisCC, pThisCC->u64McfgBase);
case EFI_INFO_INDEX_MCFG_SIZE: return efiInfoNextByteU64(pThisCC, pThisCC->cbMcfgLength);
case EFI_INFO_INDEX_APIC_MODE: return efiInfoNextByteU8(pThisCC, pThisCC->u8APIC);
+ case EFI_INFO_INDEX_TPM_PPI_BASE: return efiInfoNextByteU64(pThisCC, pThisCC->u64TpmPpiBase);
default:
PDMDevHlpDBGFStop(pThisCC->pDevIns, RT_SRC_POS, "%#x", pThisCC->iInfoSelector);
@@ -1567,7 +1571,8 @@ static DECLCALLBACK(int) efiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
"UgaHorizontalResolution|" // legacy
"UgaVerticalResolution|" // legacy
"GraphicsResolution|"
- "NvramFile", "");
+ "NvramFile|"
+ "TpmPpiBase", "");
/* CPU count (optional). */
rc = pHlp->pfnCFGMQueryU32Def(pCfg, "NumCPUs", &pThisCC->cCpus, 1);
@@ -1765,6 +1770,11 @@ static DECLCALLBACK(int) efiConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMN
return PDMDEV_SET_ERROR(pDevIns, rc,
N_("Configuration error: Querying \"NvramFile\" as a string failed"));
+ rc = pHlp->pfnCFGMQueryU64Def(pCfg, "TpmPpiBase", &pThisCC->u64TpmPpiBase, 0);
+ if (RT_FAILURE(rc))
+ return PDMDEV_SET_ERROR(pDevIns, rc,
+ N_("Configuration error: Querying \"TpmPpiBase\" as integer failed"));
+
/*
* Load firmware volume and thunk ROM.
*/
diff --git a/src/VBox/Devices/EFI/DevEFI.h b/src/VBox/Devices/EFI/DevEFI.h
index 400f537a..704035d4 100644
--- a/src/VBox/Devices/EFI/DevEFI.h
+++ b/src/VBox/Devices/EFI/DevEFI.h
@@ -84,6 +84,7 @@ typedef enum
EFI_INFO_INDEX_APIC_MODE,
EFI_INFO_INDEX_CPU_COUNT_CURRENT,
EFI_INFO_INDEX_CPU_COUNT_MAX,
+ EFI_INFO_INDEX_TPM_PPI_BASE,
EFI_INFO_INDEX_END
} EfiInfoIndex;
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 <Library/Tcg2PhysicalPresenceLib.h>
+#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;
diff --git a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd
index 16789a3b..e63fbd06 100644
--- a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd
+++ b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI32.fd
Binary files differ
diff --git a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd
index a11bbd1b..5711cfdb 100644
--- a/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd
+++ b/src/VBox/Devices/EFI/FirmwareBin/VBoxEFI64.fd
Binary files differ