linux-headers (unknown)

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