Skip to content
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 current vTPM driver #5

Merged
merged 8 commits into from
Dec 18, 2024
Merged

Conversation

osteffenrh
Copy link

Pull in the current state of the upstream PR for the vTPM support in EDK2.

This is still WIP since there are open comments, but it should work fine with the regular OVMF build as described in the Coconut documentation.

osteffenrh and others added 8 commits December 18, 2024 12:24
Add protocol and call numbers as defined in the "Secure VM Service
Module for SEV-SNP Guests" Publication # 58019 Revision: 1.00

https://www.amd.com/content/dam/amd/en/documents/epyc-technical-docs/specifications/58019.pdf

Signed-off-by: Oliver Steffen <[email protected]>
Make use of the named protocol and call constants for SVSM
communication.

Signed-off-by: Oliver Steffen <[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]>
Signed-off-by: Oliver Steffen <[email protected]>
Add call numbers for the SVSM vTPM protocol, as defined in the "Secure
VM Service Module for SEV-SNP Guests" Publication # 58019 Revision: 1.00

Signed-off-by: Oliver Steffen <[email protected]>
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]>
Signed-off-by: Oliver Steffen <[email protected]>
A some of functions implemented in Tpm2Ptp.c are forward declared in a
couple of places. To clean this up, introduce a header that contains
these declarations in a central place and use it instead.

Signed-off-by: Oliver Steffen <[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 privileged VM level), the SVSM can be
used to provide privileged services, e.g. a 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.

SVSM vTPM functionality is available as new device and instance
libraries, which can be consumed optionally, keeping changes to the
regular TPM implementation minimal.

Cc: Jiewen Yao <[email protected]>
Co-authored-by: James Bottomley <[email protected]>
Signed-off-by: Claudio Carvalho <[email protected]>
Signed-off-by: Oliver Steffen <[email protected]>
Switch over to Tpm2InstanceLibDTpmSvsm as the Tpm2 implementation to
support vTPMs provided by an SVSM.

Signed-off-by: Oliver Steffen <[email protected]>
Copy link
Member

@stefano-garzarella stefano-garzarella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osteffenrh great, thanks!

Just tested with all other components and vTPM is working as expected now!

@joergroedel joergroedel merged commit 69d7c82 into coconut-svsm:svsm Dec 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants