File Index
Files and directories
Sign in
FILE

sev-dev-tio.h

File preview with syntax highlighting.

linux-6.19.14/drivers/crypto/ccp/sev-dev-tio.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2#ifndef __PSP_SEV_TIO_H__
  3#define __PSP_SEV_TIO_H__
  4
  5#include <linux/pci-tsm.h>
  6#include <linux/pci-ide.h>
  7#include <linux/tsm.h>
  8#include <uapi/linux/psp-sev.h>
  9
 10struct sla_addr_t {
 11	union {
 12		u64 sla;
 13		struct {
 14			u64 page_type	:1,
 15			    page_size	:1,
 16			    reserved1	:10,
 17			    pfn		:40,
 18			    reserved2	:12;
 19		};
 20	};
 21} __packed;
 22
 23#define SEV_TIO_MAX_COMMAND_LENGTH	128
 24
 25/* SPDM control structure for DOE */
 26struct tsm_spdm {
 27	unsigned long req_len;
 28	void *req;
 29	unsigned long rsp_len;
 30	void *rsp;
 31};
 32
 33/* Describes TIO device */
 34struct tsm_dsm_tio {
 35	u8 cert_slot;
 36	struct sla_addr_t dev_ctx;
 37	struct sla_addr_t req;
 38	struct sla_addr_t resp;
 39	struct sla_addr_t scratch;
 40	struct sla_addr_t output;
 41	size_t output_len;
 42	size_t scratch_len;
 43	struct tsm_spdm spdm;
 44	struct sla_buffer_hdr *reqbuf; /* vmap'ed @req for DOE */
 45	struct sla_buffer_hdr *respbuf; /* vmap'ed @resp for DOE */
 46
 47	int cmd;
 48	int psp_ret;
 49	u8 cmd_data[SEV_TIO_MAX_COMMAND_LENGTH];
 50	void *data_pg; /* Data page for DEV_STATUS/TDI_STATUS/TDI_INFO/ASID_FENCE */
 51
 52#define TIO_IDE_MAX_TC	8
 53	struct pci_ide *ide[TIO_IDE_MAX_TC];
 54};
 55
 56/* Describes TSM structure for PF0 pointed by pci_dev->tsm */
 57struct tio_dsm {
 58	struct pci_tsm_pf0 tsm;
 59	struct tsm_dsm_tio data;
 60	struct sev_device *sev;
 61};
 62
 63/* Data object IDs */
 64#define SPDM_DOBJ_ID_NONE		0
 65#define SPDM_DOBJ_ID_REQ		1
 66#define SPDM_DOBJ_ID_RESP		2
 67
 68struct spdm_dobj_hdr {
 69	u32 id;     /* Data object type identifier */
 70	u32 length; /* Length of the data object, INCLUDING THIS HEADER */
 71	struct { /* Version of the data object structure */
 72		u8 minor;
 73		u8 major;
 74	} version;
 75} __packed;
 76
 77/**
 78 * struct sev_tio_status - TIO_STATUS command's info_paddr buffer
 79 *
 80 * @length: Length of this structure in bytes
 81 * @tio_en: Indicates that SNP_INIT_EX initialized the RMP for SEV-TIO
 82 * @tio_init_done: Indicates TIO_INIT has been invoked
 83 * @spdm_req_size_min: Minimum SPDM request buffer size in bytes
 84 * @spdm_req_size_max: Maximum SPDM request buffer size in bytes
 85 * @spdm_scratch_size_min: Minimum SPDM scratch buffer size in bytes
 86 * @spdm_scratch_size_max: Maximum SPDM scratch buffer size in bytes
 87 * @spdm_out_size_min: Minimum SPDM output buffer size in bytes
 88 * @spdm_out_size_max: Maximum for the SPDM output buffer size in bytes
 89 * @spdm_rsp_size_min: Minimum SPDM response buffer size in bytes
 90 * @spdm_rsp_size_max: Maximum SPDM response buffer size in bytes
 91 * @devctx_size: Size of a device context buffer in bytes
 92 * @tdictx_size: Size of a TDI context buffer in bytes
 93 * @tio_crypto_alg: TIO crypto algorithms supported
 94 */
 95struct sev_tio_status {
 96	u32 length;
 97	u32 tio_en	  :1,
 98	    tio_init_done :1,
 99	    reserved	  :30;
100	u32 spdm_req_size_min;
101	u32 spdm_req_size_max;
102	u32 spdm_scratch_size_min;
103	u32 spdm_scratch_size_max;
104	u32 spdm_out_size_min;
105	u32 spdm_out_size_max;
106	u32 spdm_rsp_size_min;
107	u32 spdm_rsp_size_max;
108	u32 devctx_size;
109	u32 tdictx_size;
110	u32 tio_crypto_alg;
111	u8 reserved2[12];
112} __packed;
113
114int sev_tio_init_locked(void *tio_status_page);
115int sev_tio_continue(struct tsm_dsm_tio *dev_data);
116
117int sev_tio_dev_create(struct tsm_dsm_tio *dev_data, u16 device_id, u16 root_port_id,
118		       u8 segment_id);
119int sev_tio_dev_connect(struct tsm_dsm_tio *dev_data, u8 tc_mask, u8 ids[8], u8 cert_slot);
120int sev_tio_dev_disconnect(struct tsm_dsm_tio *dev_data, bool force);
121int sev_tio_dev_reclaim(struct tsm_dsm_tio *dev_data);
122
123#endif	/* __PSP_SEV_TIO_H__ */
~/ Read-only file preview.