Commit 6a7d636
committed
psp/guest_request_cmd: Add send_request()
As described in the SNP Firmware ABI specification, SNP_GUEST_REQUEST
commands are protected using AES_GCM 256 and a VMPCK key to
encrypt/decrypt the message. The firmware generates and provides the
VMPCK keys to the guest in a especial secrets page that only the guest
and firmware have access to, so the hypervisor cannot alter messages
without detection nor read the plaintext of the message.
We are limiting the send_request() implementation to encrypt/decrypt
messages using the VMPCK0 key only. From guest userspace we can send
SNP_GUEST_REQUEST commands using other VMPCK keys.
The send_request() also supports sending extended SNP_GUEST_REQUEST
commands, where the extended part of it is provided by the hypervisor.
For example, in an extended attestation report the PSP firmware provides
the attestation report and the hypervisor provides the certificate chain
needed to verify the attestation report.
If a SNP_GUEST_REQUEST fails, we disable the VMPCK0 to prevent it from
being used again to send SNP_GUEST_REQUEST commands to the PSP firmware.
The only two exceptions are when the hypervisor returns the error codes
below:
- BUSY: in this case we re-send the message and if it resturns any error
code, we disable the VMPCK0.
- INVALID_DATA_BUFFER_LEN: the data buffer provided in the extended
SNP_GUEST_REQUEST command is too small. So, we re-send the command, but
as non-extended SNP_GUEST_REQUEST in order to protect the IV (sequence
number) from replay attacks. If it returns any error code, we disable
the VMPCK0.
The two cases above could be improved later when, for example, timer
support is added to the SVSM.
Signed-off-by: Claudio Carvalho <cclaudio@linux.ibm.com>1 parent 46fc912 commit 6a7d636
2 files changed
Lines changed: 487 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
| |||
58 | 56 | | |
59 | 57 | | |
60 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments