logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

sev-guest.h (2526B)


  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 <brijesh.singh@amd.com>
  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. #define SNP_REPORT_USER_DATA_SIZE 64
  15. struct snp_report_req {
  16. /* user data that should be included in the report */
  17. __u8 user_data[SNP_REPORT_USER_DATA_SIZE];
  18. /* The vmpl level to be included in the report */
  19. __u32 vmpl;
  20. /* Must be zero filled */
  21. __u8 rsvd[28];
  22. };
  23. struct snp_report_resp {
  24. /* response data, see SEV-SNP spec for the format */
  25. __u8 data[4000];
  26. };
  27. struct snp_derived_key_req {
  28. __u32 root_key_select;
  29. __u32 rsvd;
  30. __u64 guest_field_select;
  31. __u32 vmpl;
  32. __u32 guest_svn;
  33. __u64 tcb_version;
  34. };
  35. struct snp_derived_key_resp {
  36. /* response data, see SEV-SNP spec for the format */
  37. __u8 data[64];
  38. };
  39. struct snp_guest_request_ioctl {
  40. /* message version number (must be non-zero) */
  41. __u8 msg_version;
  42. /* Request and response structure address */
  43. __u64 req_data;
  44. __u64 resp_data;
  45. /* bits[63:32]: VMM error code, bits[31:0] firmware error code (see psp-sev.h) */
  46. union {
  47. __u64 exitinfo2;
  48. struct {
  49. __u32 fw_error;
  50. __u32 vmm_error;
  51. };
  52. };
  53. };
  54. struct snp_ext_report_req {
  55. struct snp_report_req data;
  56. /* where to copy the certificate blob */
  57. __u64 certs_address;
  58. /* length of the certificate blob */
  59. __u32 certs_len;
  60. };
  61. #define SNP_GUEST_REQ_IOC_TYPE 'S'
  62. /* Get SNP attestation report */
  63. #define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl)
  64. /* Get a derived key from the root */
  65. #define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl)
  66. /* Get SNP extended report as defined in the GHCB specification version 2. */
  67. #define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl)
  68. /* Guest message request EXIT_INFO_2 constants */
  69. #define SNP_GUEST_FW_ERR_MASK GENMASK_ULL(31, 0)
  70. #define SNP_GUEST_VMM_ERR_SHIFT 32
  71. #define SNP_GUEST_VMM_ERR(x) (((u64)x) << SNP_GUEST_VMM_ERR_SHIFT)
  72. #define SNP_GUEST_FW_ERR(x) ((x) & SNP_GUEST_FW_ERR_MASK)
  73. #define SNP_GUEST_ERR(vmm_err, fw_err) (SNP_GUEST_VMM_ERR(vmm_err) | \
  74. SNP_GUEST_FW_ERR(fw_err))
  75. #define SNP_GUEST_VMM_ERR_INVALID_LEN 1
  76. #define SNP_GUEST_VMM_ERR_BUSY 2
  77. #endif /* __UAPI_LINUX_SEV_GUEST_H_ */