-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vTPM: swtich from MS TPM to TCG TPM #514
Open
stefano-garzarella
wants to merge
7
commits into
coconut-svsm:main
Choose a base branch
from
stefano-garzarella:tpm-tcg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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 change is in preparation for the transition from MS TPM to TCG TPM. The feature is used to enable or disable the vTPM emulation in SVSM, so let's be generic. Signed-off-by: Stefano Garzarella <[email protected]>
stefano-garzarella
force-pushed
the
tpm-tcg
branch
from
November 12, 2024 15:50
d7a97ed
to
a34621a
Compare
cclaudio
reviewed
Nov 12, 2024
This change is in preparation for the transition from MS TPM to TCG TPM. No code changes in this commit, just the library name, some folders, some comments, and some modules to be more consistent. Also let's refer to it as "TPM 2.0 Reference Implementation" instead of "MS TPM". Signed-off-by: Stefano Garzarella <[email protected]>
The pthread library is only required for the simulator, but we don't build it, so let's use this workaround to make the `cofigure` happy and avoid checks that the pthread is available. When the TrustedComputingGroup/TPM#7 will be merged we can revert this commit and call `./configure --disable-pthread`. With this patch we can then avoid using our fork in Coconut and switch to using the upstream version directly (in the next commit). Signed-off-by: Stefano Garzarella <[email protected]>
Now we can switch to the upstream repository. No change in functionality, since the MS TPM commit is e9fc7b8 ("Fix conflicting types for `ReadVarBytes`. (coconut-svsm#102)"). The same in our fork except for the patch to disable pthread library check. Signed-off-by: Stefano Garzarella <[email protected]>
Let's speed up the compilation of the TPM libraries a bit. We already do that for openssl. Signed-off-by: Stefano Garzarella <[email protected]>
The next commit switches to TCG TPM, but there is a problem when the `FILE_BACKED_NV` macro is set to `NO`. It produces the following compile error because a variable is not used: Platform/src/NVMem.c: In function ‘_plat__NVDisable’: Platform/src/NVMem.c:185:9: error: unused variable ‘delete’ [-Werror=unused-variable] 185 | int delete = ((intptr_t)platParameter != 0) | ^~~~~~ cc1: all warnings being treated as errors make[2]: *** [Makefile:2674: Platform/src/libplatform_a-NVMem.o] Error 1 This commit can be reverted when the following PR will be merged: TrustedComputingGroup/TPM#7 Signed-off-by: Stefano Garzarella <[email protected]>
Let's switch to the official TPM 2.0 Reference Implementation hosted in https://github.com/TrustedComputingGroup/TPM. We now use the 1.83 version, commit 97c2783 ("Trusted Computing Group (TCG) TPM Specification 1.83 Release reference code. (coconut-svsm#262)"). The main difference with the previous version is that `-DSIMULATION=NO` is no longer supported to disable the simulation code, but the use of `TpmConfiguration` is strongly recommended. This allows us to better configure our TPM. For now let's copy the upstream version of TpmConfiguration and disable some features to remove the simulation behaviour: $ diff -ru libtcgtpm/deps/tpm-20-ref/TPMCmd/TpmConfiguration libtcgtpm/deps/TpmConfiguration --- libtcgtpm/deps/tpm-20-ref/TPMCmd/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h 2024-11-12 15:16:57.087949276 +0100 +++ libtcgtpm/deps/TpmConfiguration/TpmConfiguration/TpmBuildSwitches.h 2024-11-12 16:09:35.144106758 +0100 @@ -49,12 +49,12 @@ // macros will make sure that it is set correctly. A simulated TPM would include a // Virtual TPM. The interfaces for a Virtual TPM should be modified from the standard // ones in the Simulator project. -#define SIMULATION YES +#define SIMULATION NO // The CRYPTO_LIB_REPORTING switch allows the TPM to report its // crypto library implementation, e.g., at simulation startup. -#define CRYPTO_LIB_REPORTING YES +#define CRYPTO_LIB_REPORTING NO // If doing debug, can set the DRBG to print out the intermediate test values. // Before enabling this, make sure that the dbgDumpMemBlock() function @@ -92,7 +92,7 @@ // g_forceFailureMode flag in the TPM library while leaving the rest of the TPM // behavior alone. Useful for testing when the full set of options controlled by // SIMULATION may not be desired. -#define ALLOW_FORCE_FAILURE_MODE YES +#define ALLOW_FORCE_FAILURE_MODE NO //////////////////////////////////////////////////////////////// // Internal checks Fixes: coconut-svsm#440 Suggested-by: James E.J. Bottomley <[email protected]> Signed-off-by: Stefano Garzarella <[email protected]>
stefano-garzarella
force-pushed
the
tpm-tcg
branch
from
November 13, 2024 08:01
a34621a
to
49b6c26
Compare
v2:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let's switch to the official TPM 2.0 Reference Implementation hosted in https://github.com/TrustedComputingGroup/TPM.
We now use the 1.83 version, commit 97c2783 ("Trusted Computing Group (TCG) TPM Specification 1.83 Release reference code. (#262)").
Patches 1 and 2 are in prep and just do a renaming of the library and feature.
Patch 3 is a hack to avoid our TPM fork to disable pthread checking. I also opened an upstream PR (TrustedComputingGroup/TPM#6) to better support this use case.
Patch 4 switched from our fork to Microsoft's upstream repo (same code except for the patch to disable pthread check).
Patch 5 is just a speed-up for the build.
Patch 6 is a workaround for an issue in the TCG TPM (see TrustedComputingGroup/TPM#7).
Patch 7 is the real switch to the TCG TPM.
To try this PR on an already cloned repo, I suggest the following steps:
Thanks to @cclaudio for some suggestions!
Fixes: #440
Suggested-by: James E.J. Bottomley [email protected]