|
| 1 | +.. SPDX-License-Identifier: GPL-2.0 |
| 2 | +
|
| 3 | +=================================================================== |
| 4 | +The Definitive SEV Guest API Documentation |
| 5 | +=================================================================== |
| 6 | + |
| 7 | +1. General description |
| 8 | +====================== |
| 9 | + |
| 10 | +The SEV API is a set of ioctls that are used by the guest or hypervisor |
| 11 | +to get or set a certain aspect of the SEV virtual machine. The ioctls belong |
| 12 | +to the following classes: |
| 13 | + |
| 14 | + - Hypervisor ioctls: These query and set global attributes which affect the |
| 15 | + whole SEV firmware. These ioctl are used by platform provisioning tools. |
| 16 | + |
| 17 | + - Guest ioctls: These query and set attributes of the SEV virtual machine. |
| 18 | + |
| 19 | +2. API description |
| 20 | +================== |
| 21 | + |
| 22 | +This section describes ioctls that is used for querying the SEV guest report |
| 23 | +from the SEV firmware. For each ioctl, the following information is provided |
| 24 | +along with a description: |
| 25 | + |
| 26 | + Technology: |
| 27 | + which SEV technology provides this ioctl. SEV, SEV-ES, SEV-SNP or all. |
| 28 | + |
| 29 | + Type: |
| 30 | + hypervisor or guest. The ioctl can be used inside the guest or the |
| 31 | + hypervisor. |
| 32 | + |
| 33 | + Parameters: |
| 34 | + what parameters are accepted by the ioctl. |
| 35 | + |
| 36 | + Returns: |
| 37 | + the return value. General error numbers (-ENOMEM, -EINVAL) |
| 38 | + are not detailed, but errors with specific meanings are. |
| 39 | + |
| 40 | +The guest ioctl should be issued on a file descriptor of the /dev/sev-guest device. |
| 41 | +The ioctl accepts struct snp_user_guest_request. The input and output structure is |
| 42 | +specified through the req_data and resp_data field respectively. If the ioctl fails |
| 43 | +to execute due to a firmware error, then fw_err code will be set otherwise the |
| 44 | +fw_err will be set to 0x00000000000000ff. |
| 45 | + |
| 46 | +The firmware checks that the message sequence counter is one greater than |
| 47 | +the guests message sequence counter. If guest driver fails to increment message |
| 48 | +counter (e.g. counter overflow), then -EIO will be returned. |
| 49 | + |
| 50 | +:: |
| 51 | + |
| 52 | + struct snp_guest_request_ioctl { |
| 53 | + /* Message version number */ |
| 54 | + __u32 msg_version; |
| 55 | + |
| 56 | + /* Request and response structure address */ |
| 57 | + __u64 req_data; |
| 58 | + __u64 resp_data; |
| 59 | + |
| 60 | + /* firmware error code on failure (see psp-sev.h) */ |
| 61 | + __u64 fw_err; |
| 62 | + }; |
| 63 | + |
| 64 | +2.1 SNP_GET_REPORT |
| 65 | +------------------ |
| 66 | + |
| 67 | +:Technology: sev-snp |
| 68 | +:Type: guest ioctl |
| 69 | +:Parameters (in): struct snp_report_req |
| 70 | +:Returns (out): struct snp_report_resp on success, -negative on error |
| 71 | + |
| 72 | +The SNP_GET_REPORT ioctl can be used to query the attestation report from the |
| 73 | +SEV-SNP firmware. The ioctl uses the SNP_GUEST_REQUEST (MSG_REPORT_REQ) command |
| 74 | +provided by the SEV-SNP firmware to query the attestation report. |
| 75 | + |
| 76 | +On success, the snp_report_resp.data will contains the report. The report |
| 77 | +contain the format described in the SEV-SNP specification. See the SEV-SNP |
| 78 | +specification for further details. |
| 79 | + |
| 80 | + |
| 81 | +Reference |
| 82 | +--------- |
| 83 | + |
| 84 | +SEV-SNP and GHCB specification: developer.amd.com/sev |
| 85 | + |
| 86 | +The driver is based on SEV-SNP firmware spec 0.9 and GHCB spec version 2.0. |
0 commit comments