cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

psp-sev.h (5917B)


      1/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
      2/*
      3 * Userspace interface for AMD Secure Encrypted Virtualization (SEV)
      4 * platform management commands.
      5 *
      6 * Copyright (C) 2016-2017 Advanced Micro Devices, Inc.
      7 *
      8 * Author: Brijesh Singh <brijesh.singh@amd.com>
      9 *
     10 * SEV API specification is available at: https://developer.amd.com/sev/
     11 */
     12
     13#ifndef __PSP_SEV_USER_H__
     14#define __PSP_SEV_USER_H__
     15
     16#include <linux/types.h>
     17
     18/**
     19 * SEV platform commands
     20 */
     21enum {
     22	SEV_FACTORY_RESET = 0,
     23	SEV_PLATFORM_STATUS,
     24	SEV_PEK_GEN,
     25	SEV_PEK_CSR,
     26	SEV_PDH_GEN,
     27	SEV_PDH_CERT_EXPORT,
     28	SEV_PEK_CERT_IMPORT,
     29	SEV_GET_ID,	/* This command is deprecated, use SEV_GET_ID2 */
     30	SEV_GET_ID2,
     31	SNP_PLATFORM_STATUS,
     32	SNP_SET_EXT_CONFIG,
     33	SNP_GET_EXT_CONFIG,
     34
     35	SEV_MAX,
     36};
     37
     38/**
     39 * SEV Firmware status code
     40 */
     41typedef enum {
     42	SEV_RET_SUCCESS = 0,
     43	SEV_RET_INVALID_PLATFORM_STATE,
     44	SEV_RET_INVALID_GUEST_STATE,
     45	SEV_RET_INAVLID_CONFIG,
     46	SEV_RET_INVALID_LEN,
     47	SEV_RET_ALREADY_OWNED,
     48	SEV_RET_INVALID_CERTIFICATE,
     49	SEV_RET_POLICY_FAILURE,
     50	SEV_RET_INACTIVE,
     51	SEV_RET_INVALID_ADDRESS,
     52	SEV_RET_BAD_SIGNATURE,
     53	SEV_RET_BAD_MEASUREMENT,
     54	SEV_RET_ASID_OWNED,
     55	SEV_RET_INVALID_ASID,
     56	SEV_RET_WBINVD_REQUIRED,
     57	SEV_RET_DFFLUSH_REQUIRED,
     58	SEV_RET_INVALID_GUEST,
     59	SEV_RET_INVALID_COMMAND,
     60	SEV_RET_ACTIVE,
     61	SEV_RET_HWSEV_RET_PLATFORM,
     62	SEV_RET_HWSEV_RET_UNSAFE,
     63	SEV_RET_UNSUPPORTED,
     64	SEV_RET_INVALID_PARAM,
     65	SEV_RET_RESOURCE_LIMIT,
     66	SEV_RET_SECURE_DATA_INVALID,
     67	SEV_RET_INVALID_PAGE_SIZE,
     68	SEV_RET_INVALID_PAGE_STATE,
     69	SEV_RET_INVALID_MDATA_ENTRY,
     70	SEV_RET_INVALID_PAGE_OWNER,
     71	SEV_RET_AEAD_OFLOW,
     72	SEV_RET_RMP_INIT_REQUIRED,
     73	SEV_RET_MAX,
     74} sev_ret_code;
     75
     76/**
     77 * struct sev_user_data_status - PLATFORM_STATUS command parameters
     78 *
     79 * @major: major API version
     80 * @minor: minor API version
     81 * @state: platform state
     82 * @flags: platform config flags
     83 * @build: firmware build id for API version
     84 * @guest_count: number of active guests
     85 */
     86struct sev_user_data_status {
     87	__u8 api_major;				/* Out */
     88	__u8 api_minor;				/* Out */
     89	__u8 state;				/* Out */
     90	__u32 flags;				/* Out */
     91	__u8 build;				/* Out */
     92	__u32 guest_count;			/* Out */
     93} __attribute__((packed));
     94
     95#define SEV_STATUS_FLAGS_CONFIG_ES	0x0100
     96
     97/**
     98 * struct sev_user_data_pek_csr - PEK_CSR command parameters
     99 *
    100 * @address: PEK certificate chain
    101 * @length: length of certificate
    102 */
    103struct sev_user_data_pek_csr {
    104	__u64 address;				/* In */
    105	__u32 length;				/* In/Out */
    106} __attribute__((packed));
    107
    108/**
    109 * struct sev_user_data_cert_import - PEK_CERT_IMPORT command parameters
    110 *
    111 * @pek_address: PEK certificate chain
    112 * @pek_len: length of PEK certificate
    113 * @oca_address: OCA certificate chain
    114 * @oca_len: length of OCA certificate
    115 */
    116struct sev_user_data_pek_cert_import {
    117	__u64 pek_cert_address;			/* In */
    118	__u32 pek_cert_len;			/* In */
    119	__u64 oca_cert_address;			/* In */
    120	__u32 oca_cert_len;			/* In */
    121} __attribute__((packed));
    122
    123/**
    124 * struct sev_user_data_pdh_cert_export - PDH_CERT_EXPORT command parameters
    125 *
    126 * @pdh_address: PDH certificate address
    127 * @pdh_len: length of PDH certificate
    128 * @cert_chain_address: PDH certificate chain
    129 * @cert_chain_len: length of PDH certificate chain
    130 */
    131struct sev_user_data_pdh_cert_export {
    132	__u64 pdh_cert_address;			/* In */
    133	__u32 pdh_cert_len;			/* In/Out */
    134	__u64 cert_chain_address;		/* In */
    135	__u32 cert_chain_len;			/* In/Out */
    136} __attribute__((packed));
    137
    138/**
    139 * struct sev_user_data_get_id - GET_ID command parameters (deprecated)
    140 *
    141 * @socket1: Buffer to pass unique ID of first socket
    142 * @socket2: Buffer to pass unique ID of second socket
    143 */
    144struct sev_user_data_get_id {
    145	__u8 socket1[64];			/* Out */
    146	__u8 socket2[64];			/* Out */
    147} __attribute__((packed));
    148
    149/**
    150 * struct sev_user_data_get_id2 - GET_ID command parameters
    151 * @address: Buffer to store unique ID
    152 * @length: length of the unique ID
    153 */
    154struct sev_user_data_get_id2 {
    155	__u64 address;				/* In */
    156	__u32 length;				/* In/Out */
    157} __attribute__((packed));
    158
    159/**
    160 * struct sev_user_data_snp_status - SNP status
    161 *
    162 * @major: API major version
    163 * @minor: API minor version
    164 * @state: current platform state
    165 * @build: firmware build id for the API version
    166 * @guest_count: the number of guest currently managed by the firmware
    167 * @tcb_version: current TCB version
    168 */
    169struct sev_user_data_snp_status {
    170	__u8 api_major;		/* Out */
    171	__u8 api_minor;		/* Out */
    172	__u8 state;		/* Out */
    173	__u8 rsvd;
    174	__u32 build_id;		/* Out */
    175	__u32 rsvd1;
    176	__u32 guest_count;	/* Out */
    177	__u64 tcb_version;	/* Out */
    178	__u64 rsvd2;
    179} __attribute__((packed));
    180
    181/*
    182 * struct sev_user_data_snp_config - system wide configuration value for SNP.
    183 *
    184 * @reported_tcb: The TCB version to report in the guest attestation report.
    185 * @mask_chip_id: Indicates that the CHID_ID field in the attestation report
    186 * will always be zero.
    187 */
    188struct sev_user_data_snp_config {
    189	__u64 reported_tcb;     /* In */
    190	__u32 mask_chip_id;     /* In */
    191	__u8 rsvd[52];
    192} __attribute__((packed));
    193
    194/**
    195 * struct sev_data_snp_ext_config - system wide configuration value for SNP.
    196 *
    197 * @config_address: address of the struct sev_user_data_snp_config or 0 when
    198 *		reported_tcb does not need to be updated.
    199 * @certs_address: address of extended guest request certificate chain or
    200 *              0 when previous certificate should be removed on SNP_SET_EXT_CONFIG.
    201 * @certs_len: length of the certs
    202 */
    203struct sev_user_data_ext_snp_config {
    204	__u64 config_address;		/* In */
    205	__u64 certs_address;		/* In */
    206	__u32 certs_len;		/* In */
    207};
    208
    209/**
    210 * struct sev_issue_cmd - SEV ioctl parameters
    211 *
    212 * @cmd: SEV commands to execute
    213 * @opaque: pointer to the command structure
    214 * @error: SEV FW return code on failure
    215 */
    216struct sev_issue_cmd {
    217	__u32 cmd;				/* In */
    218	__u64 data;				/* In */
    219	__u32 error;				/* Out */
    220} __attribute__((packed));
    221
    222#define SEV_IOC_TYPE		'S'
    223#define SEV_ISSUE_CMD	_IOWR(SEV_IOC_TYPE, 0x0, struct sev_issue_cmd)
    224
    225#endif /* __PSP_USER_SEV_H */