-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Fixes issue related to enabling TPM for QEMU Q35. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Locally tested with Windows boot. ## Integration Instructions N/A
- Loading branch information
Showing
7 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# TPM Emulation | ||
|
||
For more information on QEMU tpm, see the [QEMU TPM Documentation](https://www.qemu.org/docs/master/specs/tpm.html#the-qemu-tpm-emulator-device). | ||
|
||
The QEMU TPM relies on a seperate program to emulate the TPM. Currently, this is | ||
only supported on Linux using the [swtpm program](https://github.com/stefanberger/swtpm). | ||
Swtpm can be installed from the linux package managers. | ||
|
||
```bash | ||
sudo apt-get install swtpm | ||
``` | ||
|
||
To start the TPM emulator, invoke swtpm with a state file location and character | ||
device. | ||
|
||
```bash | ||
mkdir /tmp/mytpm1 | ||
swtpm socket --tpmstate dir=/tmp/mytpm1 \ | ||
--ctrl type=unixio,path=/tmp/mytpm1/swtpm-sock \ | ||
--tpm2 \ | ||
--log level=20 | ||
``` | ||
|
||
To run Q35 using this TPM, build and run with the following options. `TPM_DEV` should | ||
point to the path of the character device from the above swtpm command. | ||
|
||
```bash | ||
stuart_build -c Platforms/QemuQ35Pkg/PlatformBuild.py --flashrom TOOL_CHAIN_TAG=GCC5 BLD_*_TPM_ENABLE=TRUE TPM_DEV=/tmp/mytpm1/swtpm-sock | ||
``` | ||
|
||
In the window running swtpm, there should be output from the TPM communication. | ||
|
||
```txt | ||
Ctrl Cmd: length 4 | ||
00 00 00 10 | ||
Ctrl Rsp: length 4 | ||
00 00 00 00 | ||
SWTPM_IO_Read: length 10 | ||
80 01 00 00 00 0A 00 00 01 81 | ||
SWTPM_IO_Write: length 10 | ||
80 01 00 00 00 0A 00 00 01 01 | ||
... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
QemuPkg/Library/QemuPreUefiEventLogLibNull/QemuPreUefiEventLogLibNull.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** @file | ||
NULL implementation of PreUefiEventLogLib for QEMU. | ||
Copyright (c) Microsoft Corporation | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Library/DebugLib.h> | ||
|
||
/** | ||
Create the event log entries, Nothing to do for QEMU. | ||
**/ | ||
VOID | ||
CreateTcg2PreUefiEventLogEntries ( | ||
VOID | ||
) | ||
{ | ||
return; | ||
} |
22 changes: 22 additions & 0 deletions
22
QemuPkg/Library/QemuPreUefiEventLogLibNull/QemuPreUefiEventLogLibNull.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## @file | ||
# NULL PreUefiEventLogLibNull library instance for QEMU | ||
# | ||
# Copyright (c) Microsoft Corporation | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = QemuPreUefiEventLogLibNull | ||
FILE_GUID = A3E24CE0-4E7D-4164-9A5B-90DFBE2F5744 | ||
MODULE_TYPE = BASE | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = Tcg2PreUefiEventLogLib | ||
|
||
[Sources] | ||
QemuPreUefiEventLogLibNull.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
SecurityPkg/SecurityPkg.dec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters