-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add support for a SVSM vTPM #5770
Conversation
As described in the SVSM specification, guest components can call to the SVSM vTPM through the vTPM protocol (protocol-id 2). The SVSM vTPM protocol follows the Microsoft TPM Simulator interface (MSSIM) and supports two services: - SVSM_VTPM_QUERY (call-id 0): query MSSIM commands and vTPM features supported. - SVSM_VTPM_CMD (call-id 1): send a MSSIM command to be run by the vTPM and get the result. This patch adds support for SVSM_VTPM_QUERY and SVSM_VTPM_CMD to invoke a SVSM when the guest is running at VMPL0. Cc: Ard Biesheuvel <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Gerd Hoffmann <[email protected]> Co-authored-by: James Bottomley <[email protected]> Signed-off-by: Claudio Carvalho <[email protected]>
We need to stub the SVSM vTPM protocol in the UefiCpuPkg in order to support a SEV-SNP guest running under a SVSM at VMPL1 or lower. Cc: Ray Ni <[email protected]> Cc: Rahul Kumar <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Jiaxin Wu <[email protected]> Co-authored-by: James Bottomley <[email protected]> Signed-off-by: Claudio Carvalho <[email protected]>
SEV-SNP provides a feature known as VM Privilege Level (VMPL), which allows for services to be run in the guest at different privilege levels. By running at VMPL0 (most priviledged VM level), the SVSM can be used to provide privileged services, e.g. virtual TPM, for the guest rather than trust such services from the hypervisor. This patch adds a DTpm driver to communicate with a virtual TPM running in the SVSM. The driver follows the vTPM protocol documented in the SVSM specification. Cc: Jiewen Yao <[email protected]> Co-authored-by: James Bottomley <[email protected]> Signed-off-by: Claudio Carvalho <[email protected]>
@@ -443,6 +443,11 @@ Tpm2GetPtpInterface ( | |||
return Tpm2PtpInterfaceMax; | |||
} | |||
|
|||
if (Tpm2SvsmQueryTpmSendCmd ()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using NULL class registration for SVSM TPM.
Please don't touch the current PTP for the real platform BIOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jyao1. Thanks for your feedback and I apologize for the delay.
The API used to communicate with the SVSM vTPM is already under a NULL class. Could you elaborate a little bit more on what other NULL classes could be created?
- UefiCpuPkg/Library/AmdSvsmLibNull/AmdSvsmLibNull.c
- OvmfPkg/Library/AmdSvsmLib/AmdSvsmLib.c
Right, this patch series is failing the CI mostly because it is hooking into the PTP which is used by multiple platforms. The idea behind that was to register the SVSM vTPM as a platform driver, similar to what we are doing in the Linux kernel. If not the PTP, would you have any suggestion for places where we could add it? And could that also be enabled via "-D TPM2_ENABLE"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I expect is something like the DTpm NULL class, https://github.com/tianocore/edk2/blob/master/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.inf
For example, you can have, something like: Tpm2InstallLibSvsmVTpm.
Then you can register it in the OVMF DSC file, without impacting other platform, where they can still use existing DTpm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
I will create the new SecurityPkg/Library/Tpm2InstanceLibSvsmVTpm and have it implement https://github.com/tianocore/edk2/blob/master/SecurityPkg/Include/Library/Tpm2DeviceLib.h similar to how Tpm2InstanceLibDTpm does.
It is not super clear though how I should register it in the Ovmf DSC file. I think I could do something similar to AmdSvsmLib.inf or TdxLib.inf. Would you have any suggestion/preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using NULL class registration for SVSM TPM. Please don't touch the current PTP for the real platform BIOS.
Care to explain why adding the svsm vtpm as new PTP variant is a problem?
I like the approach because it allows for runtime detection of the (v)TPM, whereas a svsm-specific Tpm2DeviceLib implementation must be selected at compile time.
If you want be able to exclude the svsm support for physical platforms we can have a Tpm2Svsm.c
and a Tpm2SvsmNull.c
and two variants of the Tpm2InstanceLibDTpm.inf
file, one using the NULL implementation (for physical platforms) and one using the real svsm implementation (for OVMF).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @jyao1 ^^^
This PR has been automatically marked as stale because it has not had activity in 60 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions. |
This pull request has been automatically been closed because it did not have any activity in 60 days and no follow up within 7 days after being marked stale. Thank you for your contributions. |
We can close this PR. Work will continue at #6527 |
Description
This series adds a DTpm driver to communicate with a virtual TPM running in the Secure VM Service Module (SVSM), enabling OVMF to do measured boot in SEV-SNP confidential VMs.
SEV-SNP provides a feature known as VM Privilege Level (VMPL), which allows for services to be run in the guest at different privilege levels. By running at VMPL0 (most priviledged VM level), the SVSM can be used to provide privileged services, e.g. virtual TPM, for the guest rather than trust such services from the hypervisor.
As described in the SVSM specification, guest components can call to the SVSM vTPM through the vTPM protocol (protocol-id 2).
The vTPM protocol follows the Microsoft TPM Simulator interface (MSSIM) and it supports two services:
The SVSM vTPM protocol is also added in this series.
How This Was Tested
This was tested with the latest COCONUT-SVSM upstream code (commit 75b83b3e1a5c860a84ccfe0e4b503e7efee5834f), which provides vTPM service. The instructions to build and run a guest under a SVSM can be found in the INSTALL.md.
The OVMF boot message log below shows that it was able to find the SVSM vTPM and also use it for measured boot.
Integration Instructions
N/A