sev-guest.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Userspace interface for AMD SEV and SNP guest driver.
  4. *
  5. * Copyright (C) 2021 Advanced Micro Devices, Inc.
  6. *
  7. * Author: Brijesh Singh <[email protected]>
  8. *
  9. * SEV API specification is available at: https://developer.amd.com/sev/
  10. */
  11. #ifndef __UAPI_LINUX_SEV_GUEST_H_
  12. #define __UAPI_LINUX_SEV_GUEST_H_
  13. #include <linux/types.h>
  14. struct snp_report_req {
  15. /* user data that should be included in the report */
  16. __u8 user_data[64];
  17. /* The vmpl level to be included in the report */
  18. __u32 vmpl;
  19. /* Must be zero filled */
  20. __u8 rsvd[28];
  21. };
  22. struct snp_report_resp {
  23. /* response data, see SEV-SNP spec for the format */
  24. __u8 data[4000];
  25. };
  26. struct snp_derived_key_req {
  27. __u32 root_key_select;
  28. __u32 rsvd;
  29. __u64 guest_field_select;
  30. __u32 vmpl;
  31. __u32 guest_svn;
  32. __u64 tcb_version;
  33. };
  34. struct snp_derived_key_resp {
  35. /* response data, see SEV-SNP spec for the format */
  36. __u8 data[64];
  37. };
  38. struct snp_guest_request_ioctl {
  39. /* message version number (must be non-zero) */
  40. __u8 msg_version;
  41. /* Request and response structure address */
  42. __u64 req_data;
  43. __u64 resp_data;
  44. /* bits[63:32]: VMM error code, bits[31:0] firmware error code (see psp-sev.h) */
  45. union {
  46. __u64 exitinfo2;
  47. struct {
  48. __u32 fw_error;
  49. __u32 vmm_error;
  50. };
  51. };
  52. };
  53. struct snp_ext_report_req {
  54. struct snp_report_req data;
  55. /* where to copy the certificate blob */
  56. __u64 certs_address;
  57. /* length of the certificate blob */
  58. __u32 certs_len;
  59. };
  60. #define SNP_GUEST_REQ_IOC_TYPE 'S'
  61. /* Get SNP attestation report */
  62. #define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl)
  63. /* Get a derived key from the root */
  64. #define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl)
  65. /* Get SNP extended report as defined in the GHCB specification version 2. */
  66. #define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl)
  67. /* Guest message request EXIT_INFO_2 constants */
  68. #define SNP_GUEST_FW_ERR_MASK GENMASK_ULL(31, 0)
  69. #define SNP_GUEST_VMM_ERR_SHIFT 32
  70. #define SNP_GUEST_VMM_ERR(x) (((u64)x) << SNP_GUEST_VMM_ERR_SHIFT)
  71. #define SNP_GUEST_VMM_ERR_INVALID_LEN 1
  72. #define SNP_GUEST_VMM_ERR_BUSY 2
  73. #endif /* __UAPI_LINUX_SEV_GUEST_H_ */