xref: /openbmc/linux/arch/x86/include/asm/sgx.h (revision 8ca52cc3)
1*8ca52cc3SSean Christopherson /* SPDX-License-Identifier: GPL-2.0 */
2*8ca52cc3SSean Christopherson /**
3*8ca52cc3SSean Christopherson  * Copyright(c) 2016-20 Intel Corporation.
4*8ca52cc3SSean Christopherson  *
5*8ca52cc3SSean Christopherson  * Intel Software Guard Extensions (SGX) support.
6*8ca52cc3SSean Christopherson  */
7*8ca52cc3SSean Christopherson #ifndef _ASM_X86_SGX_H
8*8ca52cc3SSean Christopherson #define _ASM_X86_SGX_H
9*8ca52cc3SSean Christopherson 
10*8ca52cc3SSean Christopherson #include <linux/bits.h>
11*8ca52cc3SSean Christopherson #include <linux/types.h>
12*8ca52cc3SSean Christopherson 
13*8ca52cc3SSean Christopherson /*
14*8ca52cc3SSean Christopherson  * This file contains both data structures defined by SGX architecture and Linux
15*8ca52cc3SSean Christopherson  * defined software data structures and functions.  The two should not be mixed
16*8ca52cc3SSean Christopherson  * together for better readibility.  The architectural definitions come first.
17*8ca52cc3SSean Christopherson  */
18*8ca52cc3SSean Christopherson 
19*8ca52cc3SSean Christopherson /* The SGX specific CPUID function. */
20*8ca52cc3SSean Christopherson #define SGX_CPUID		0x12
21*8ca52cc3SSean Christopherson /* EPC enumeration. */
22*8ca52cc3SSean Christopherson #define SGX_CPUID_EPC		2
23*8ca52cc3SSean Christopherson /* An invalid EPC section, i.e. the end marker. */
24*8ca52cc3SSean Christopherson #define SGX_CPUID_EPC_INVALID	0x0
25*8ca52cc3SSean Christopherson /* A valid EPC section. */
26*8ca52cc3SSean Christopherson #define SGX_CPUID_EPC_SECTION	0x1
27*8ca52cc3SSean Christopherson /* The bitmask for the EPC section type. */
28*8ca52cc3SSean Christopherson #define SGX_CPUID_EPC_MASK	GENMASK(3, 0)
29*8ca52cc3SSean Christopherson 
30*8ca52cc3SSean Christopherson /**
31*8ca52cc3SSean Christopherson  * enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV
32*8ca52cc3SSean Christopherson  * %SGX_NOT_TRACKED:		Previous ETRACK's shootdown sequence has not
33*8ca52cc3SSean Christopherson  *				been completed yet.
34*8ca52cc3SSean Christopherson  * %SGX_CHILD_PRESENT		SECS has child pages present in the EPC.
35*8ca52cc3SSean Christopherson  * %SGX_INVALID_EINITTOKEN:	EINITTOKEN is invalid and enclave signer's
36*8ca52cc3SSean Christopherson  *				public key does not match IA32_SGXLEPUBKEYHASH.
37*8ca52cc3SSean Christopherson  * %SGX_UNMASKED_EVENT:		An unmasked event, e.g. INTR, was received
38*8ca52cc3SSean Christopherson  */
39*8ca52cc3SSean Christopherson enum sgx_return_code {
40*8ca52cc3SSean Christopherson 	SGX_NOT_TRACKED			= 11,
41*8ca52cc3SSean Christopherson 	SGX_CHILD_PRESENT		= 13,
42*8ca52cc3SSean Christopherson 	SGX_INVALID_EINITTOKEN		= 16,
43*8ca52cc3SSean Christopherson 	SGX_UNMASKED_EVENT		= 128,
44*8ca52cc3SSean Christopherson };
45*8ca52cc3SSean Christopherson 
46*8ca52cc3SSean Christopherson /* The modulus size for 3072-bit RSA keys. */
47*8ca52cc3SSean Christopherson #define SGX_MODULUS_SIZE 384
48*8ca52cc3SSean Christopherson 
49*8ca52cc3SSean Christopherson /**
50*8ca52cc3SSean Christopherson  * enum sgx_miscselect - additional information to an SSA frame
51*8ca52cc3SSean Christopherson  * %SGX_MISC_EXINFO:	Report #PF or #GP to the SSA frame.
52*8ca52cc3SSean Christopherson  *
53*8ca52cc3SSean Christopherson  * Save State Area (SSA) is a stack inside the enclave used to store processor
54*8ca52cc3SSean Christopherson  * state when an exception or interrupt occurs. This enum defines additional
55*8ca52cc3SSean Christopherson  * information stored to an SSA frame.
56*8ca52cc3SSean Christopherson  */
57*8ca52cc3SSean Christopherson enum sgx_miscselect {
58*8ca52cc3SSean Christopherson 	SGX_MISC_EXINFO		= BIT(0),
59*8ca52cc3SSean Christopherson };
60*8ca52cc3SSean Christopherson 
61*8ca52cc3SSean Christopherson #define SGX_MISC_RESERVED_MASK	GENMASK_ULL(63, 1)
62*8ca52cc3SSean Christopherson 
63*8ca52cc3SSean Christopherson #define SGX_SSA_GPRS_SIZE		184
64*8ca52cc3SSean Christopherson #define SGX_SSA_MISC_EXINFO_SIZE	16
65*8ca52cc3SSean Christopherson 
66*8ca52cc3SSean Christopherson /**
67*8ca52cc3SSean Christopherson  * enum sgx_attributes - the attributes field in &struct sgx_secs
68*8ca52cc3SSean Christopherson  * %SGX_ATTR_INIT:		Enclave can be entered (is initialized).
69*8ca52cc3SSean Christopherson  * %SGX_ATTR_DEBUG:		Allow ENCLS(EDBGRD) and ENCLS(EDBGWR).
70*8ca52cc3SSean Christopherson  * %SGX_ATTR_MODE64BIT:		Tell that this a 64-bit enclave.
71*8ca52cc3SSean Christopherson  * %SGX_ATTR_PROVISIONKEY:      Allow to use provisioning keys for remote
72*8ca52cc3SSean Christopherson  *				attestation.
73*8ca52cc3SSean Christopherson  * %SGX_ATTR_KSS:		Allow to use key separation and sharing (KSS).
74*8ca52cc3SSean Christopherson  * %SGX_ATTR_EINITTOKENKEY:	Allow to use token signing key that is used to
75*8ca52cc3SSean Christopherson  *				sign cryptographic tokens that can be passed to
76*8ca52cc3SSean Christopherson  *				EINIT as an authorization to run an enclave.
77*8ca52cc3SSean Christopherson  */
78*8ca52cc3SSean Christopherson enum sgx_attribute {
79*8ca52cc3SSean Christopherson 	SGX_ATTR_INIT		= BIT(0),
80*8ca52cc3SSean Christopherson 	SGX_ATTR_DEBUG		= BIT(1),
81*8ca52cc3SSean Christopherson 	SGX_ATTR_MODE64BIT	= BIT(2),
82*8ca52cc3SSean Christopherson 	SGX_ATTR_PROVISIONKEY	= BIT(4),
83*8ca52cc3SSean Christopherson 	SGX_ATTR_EINITTOKENKEY	= BIT(5),
84*8ca52cc3SSean Christopherson 	SGX_ATTR_KSS		= BIT(7),
85*8ca52cc3SSean Christopherson };
86*8ca52cc3SSean Christopherson 
87*8ca52cc3SSean Christopherson #define SGX_ATTR_RESERVED_MASK	(BIT_ULL(3) | BIT_ULL(6) | GENMASK_ULL(63, 8))
88*8ca52cc3SSean Christopherson 
89*8ca52cc3SSean Christopherson /**
90*8ca52cc3SSean Christopherson  * struct sgx_secs - SGX Enclave Control Structure (SECS)
91*8ca52cc3SSean Christopherson  * @size:		size of the address space
92*8ca52cc3SSean Christopherson  * @base:		base address of the  address space
93*8ca52cc3SSean Christopherson  * @ssa_frame_size:	size of an SSA frame
94*8ca52cc3SSean Christopherson  * @miscselect:		additional information stored to an SSA frame
95*8ca52cc3SSean Christopherson  * @attributes:		attributes for enclave
96*8ca52cc3SSean Christopherson  * @xfrm:		XSave-Feature Request Mask (subset of XCR0)
97*8ca52cc3SSean Christopherson  * @mrenclave:		SHA256-hash of the enclave contents
98*8ca52cc3SSean Christopherson  * @mrsigner:		SHA256-hash of the public key used to sign the SIGSTRUCT
99*8ca52cc3SSean Christopherson  * @config_id:		a user-defined value that is used in key derivation
100*8ca52cc3SSean Christopherson  * @isv_prod_id:	a user-defined value that is used in key derivation
101*8ca52cc3SSean Christopherson  * @isv_svn:		a user-defined value that is used in key derivation
102*8ca52cc3SSean Christopherson  * @config_svn:		a user-defined value that is used in key derivation
103*8ca52cc3SSean Christopherson  *
104*8ca52cc3SSean Christopherson  * SGX Enclave Control Structure (SECS) is a special enclave page that is not
105*8ca52cc3SSean Christopherson  * visible in the address space. In fact, this structure defines the address
106*8ca52cc3SSean Christopherson  * range and other global attributes for the enclave and it is the first EPC
107*8ca52cc3SSean Christopherson  * page created for any enclave. It is moved from a temporary buffer to an EPC
108*8ca52cc3SSean Christopherson  * by the means of ENCLS[ECREATE] function.
109*8ca52cc3SSean Christopherson  */
110*8ca52cc3SSean Christopherson struct sgx_secs {
111*8ca52cc3SSean Christopherson 	u64 size;
112*8ca52cc3SSean Christopherson 	u64 base;
113*8ca52cc3SSean Christopherson 	u32 ssa_frame_size;
114*8ca52cc3SSean Christopherson 	u32 miscselect;
115*8ca52cc3SSean Christopherson 	u8  reserved1[24];
116*8ca52cc3SSean Christopherson 	u64 attributes;
117*8ca52cc3SSean Christopherson 	u64 xfrm;
118*8ca52cc3SSean Christopherson 	u32 mrenclave[8];
119*8ca52cc3SSean Christopherson 	u8  reserved2[32];
120*8ca52cc3SSean Christopherson 	u32 mrsigner[8];
121*8ca52cc3SSean Christopherson 	u8  reserved3[32];
122*8ca52cc3SSean Christopherson 	u32 config_id[16];
123*8ca52cc3SSean Christopherson 	u16 isv_prod_id;
124*8ca52cc3SSean Christopherson 	u16 isv_svn;
125*8ca52cc3SSean Christopherson 	u16 config_svn;
126*8ca52cc3SSean Christopherson 	u8  reserved4[3834];
127*8ca52cc3SSean Christopherson } __packed;
128*8ca52cc3SSean Christopherson 
129*8ca52cc3SSean Christopherson /**
130*8ca52cc3SSean Christopherson  * enum sgx_tcs_flags - execution flags for TCS
131*8ca52cc3SSean Christopherson  * %SGX_TCS_DBGOPTIN:	If enabled allows single-stepping and breakpoints
132*8ca52cc3SSean Christopherson  *			inside an enclave. It is cleared by EADD but can
133*8ca52cc3SSean Christopherson  *			be set later with EDBGWR.
134*8ca52cc3SSean Christopherson  */
135*8ca52cc3SSean Christopherson enum sgx_tcs_flags {
136*8ca52cc3SSean Christopherson 	SGX_TCS_DBGOPTIN	= 0x01,
137*8ca52cc3SSean Christopherson };
138*8ca52cc3SSean Christopherson 
139*8ca52cc3SSean Christopherson #define SGX_TCS_RESERVED_MASK	GENMASK_ULL(63, 1)
140*8ca52cc3SSean Christopherson #define SGX_TCS_RESERVED_SIZE	4024
141*8ca52cc3SSean Christopherson 
142*8ca52cc3SSean Christopherson /**
143*8ca52cc3SSean Christopherson  * struct sgx_tcs - Thread Control Structure (TCS)
144*8ca52cc3SSean Christopherson  * @state:		used to mark an entered TCS
145*8ca52cc3SSean Christopherson  * @flags:		execution flags (cleared by EADD)
146*8ca52cc3SSean Christopherson  * @ssa_offset:		SSA stack offset relative to the enclave base
147*8ca52cc3SSean Christopherson  * @ssa_index:		the current SSA frame index (cleard by EADD)
148*8ca52cc3SSean Christopherson  * @nr_ssa_frames:	the number of frame in the SSA stack
149*8ca52cc3SSean Christopherson  * @entry_offset:	entry point offset relative to the enclave base
150*8ca52cc3SSean Christopherson  * @exit_addr:		address outside the enclave to exit on an exception or
151*8ca52cc3SSean Christopherson  *			interrupt
152*8ca52cc3SSean Christopherson  * @fs_offset:		offset relative to the enclave base to become FS
153*8ca52cc3SSean Christopherson  *			segment inside the enclave
154*8ca52cc3SSean Christopherson  * @gs_offset:		offset relative to the enclave base to become GS
155*8ca52cc3SSean Christopherson  *			segment inside the enclave
156*8ca52cc3SSean Christopherson  * @fs_limit:		size to become a new FS-limit (only 32-bit enclaves)
157*8ca52cc3SSean Christopherson  * @gs_limit:		size to become a new GS-limit (only 32-bit enclaves)
158*8ca52cc3SSean Christopherson  *
159*8ca52cc3SSean Christopherson  * Thread Control Structure (TCS) is an enclave page visible in its address
160*8ca52cc3SSean Christopherson  * space that defines an entry point inside the enclave. A thread enters inside
161*8ca52cc3SSean Christopherson  * an enclave by supplying address of TCS to ENCLU(EENTER). A TCS can be entered
162*8ca52cc3SSean Christopherson  * by only one thread at a time.
163*8ca52cc3SSean Christopherson  */
164*8ca52cc3SSean Christopherson struct sgx_tcs {
165*8ca52cc3SSean Christopherson 	u64 state;
166*8ca52cc3SSean Christopherson 	u64 flags;
167*8ca52cc3SSean Christopherson 	u64 ssa_offset;
168*8ca52cc3SSean Christopherson 	u32 ssa_index;
169*8ca52cc3SSean Christopherson 	u32 nr_ssa_frames;
170*8ca52cc3SSean Christopherson 	u64 entry_offset;
171*8ca52cc3SSean Christopherson 	u64 exit_addr;
172*8ca52cc3SSean Christopherson 	u64 fs_offset;
173*8ca52cc3SSean Christopherson 	u64 gs_offset;
174*8ca52cc3SSean Christopherson 	u32 fs_limit;
175*8ca52cc3SSean Christopherson 	u32 gs_limit;
176*8ca52cc3SSean Christopherson 	u8  reserved[SGX_TCS_RESERVED_SIZE];
177*8ca52cc3SSean Christopherson } __packed;
178*8ca52cc3SSean Christopherson 
179*8ca52cc3SSean Christopherson /**
180*8ca52cc3SSean Christopherson  * struct sgx_pageinfo - an enclave page descriptor
181*8ca52cc3SSean Christopherson  * @addr:	address of the enclave page
182*8ca52cc3SSean Christopherson  * @contents:	pointer to the page contents
183*8ca52cc3SSean Christopherson  * @metadata:	pointer either to a SECINFO or PCMD instance
184*8ca52cc3SSean Christopherson  * @secs:	address of the SECS page
185*8ca52cc3SSean Christopherson  */
186*8ca52cc3SSean Christopherson struct sgx_pageinfo {
187*8ca52cc3SSean Christopherson 	u64 addr;
188*8ca52cc3SSean Christopherson 	u64 contents;
189*8ca52cc3SSean Christopherson 	u64 metadata;
190*8ca52cc3SSean Christopherson 	u64 secs;
191*8ca52cc3SSean Christopherson } __packed __aligned(32);
192*8ca52cc3SSean Christopherson 
193*8ca52cc3SSean Christopherson 
194*8ca52cc3SSean Christopherson /**
195*8ca52cc3SSean Christopherson  * enum sgx_page_type - bits in the SECINFO flags defining the page type
196*8ca52cc3SSean Christopherson  * %SGX_PAGE_TYPE_SECS:	a SECS page
197*8ca52cc3SSean Christopherson  * %SGX_PAGE_TYPE_TCS:	a TCS page
198*8ca52cc3SSean Christopherson  * %SGX_PAGE_TYPE_REG:	a regular page
199*8ca52cc3SSean Christopherson  * %SGX_PAGE_TYPE_VA:	a VA page
200*8ca52cc3SSean Christopherson  * %SGX_PAGE_TYPE_TRIM:	a page in trimmed state
201*8ca52cc3SSean Christopherson  */
202*8ca52cc3SSean Christopherson enum sgx_page_type {
203*8ca52cc3SSean Christopherson 	SGX_PAGE_TYPE_SECS,
204*8ca52cc3SSean Christopherson 	SGX_PAGE_TYPE_TCS,
205*8ca52cc3SSean Christopherson 	SGX_PAGE_TYPE_REG,
206*8ca52cc3SSean Christopherson 	SGX_PAGE_TYPE_VA,
207*8ca52cc3SSean Christopherson 	SGX_PAGE_TYPE_TRIM,
208*8ca52cc3SSean Christopherson };
209*8ca52cc3SSean Christopherson 
210*8ca52cc3SSean Christopherson #define SGX_NR_PAGE_TYPES	5
211*8ca52cc3SSean Christopherson #define SGX_PAGE_TYPE_MASK	GENMASK(7, 0)
212*8ca52cc3SSean Christopherson 
213*8ca52cc3SSean Christopherson /**
214*8ca52cc3SSean Christopherson  * enum sgx_secinfo_flags - the flags field in &struct sgx_secinfo
215*8ca52cc3SSean Christopherson  * %SGX_SECINFO_R:	allow read
216*8ca52cc3SSean Christopherson  * %SGX_SECINFO_W:	allow write
217*8ca52cc3SSean Christopherson  * %SGX_SECINFO_X:	allow execution
218*8ca52cc3SSean Christopherson  * %SGX_SECINFO_SECS:	a SECS page
219*8ca52cc3SSean Christopherson  * %SGX_SECINFO_TCS:	a TCS page
220*8ca52cc3SSean Christopherson  * %SGX_SECINFO_REG:	a regular page
221*8ca52cc3SSean Christopherson  * %SGX_SECINFO_VA:	a VA page
222*8ca52cc3SSean Christopherson  * %SGX_SECINFO_TRIM:	a page in trimmed state
223*8ca52cc3SSean Christopherson  */
224*8ca52cc3SSean Christopherson enum sgx_secinfo_flags {
225*8ca52cc3SSean Christopherson 	SGX_SECINFO_R			= BIT(0),
226*8ca52cc3SSean Christopherson 	SGX_SECINFO_W			= BIT(1),
227*8ca52cc3SSean Christopherson 	SGX_SECINFO_X			= BIT(2),
228*8ca52cc3SSean Christopherson 	SGX_SECINFO_SECS		= (SGX_PAGE_TYPE_SECS << 8),
229*8ca52cc3SSean Christopherson 	SGX_SECINFO_TCS			= (SGX_PAGE_TYPE_TCS << 8),
230*8ca52cc3SSean Christopherson 	SGX_SECINFO_REG			= (SGX_PAGE_TYPE_REG << 8),
231*8ca52cc3SSean Christopherson 	SGX_SECINFO_VA			= (SGX_PAGE_TYPE_VA << 8),
232*8ca52cc3SSean Christopherson 	SGX_SECINFO_TRIM		= (SGX_PAGE_TYPE_TRIM << 8),
233*8ca52cc3SSean Christopherson };
234*8ca52cc3SSean Christopherson 
235*8ca52cc3SSean Christopherson #define SGX_SECINFO_PERMISSION_MASK	GENMASK_ULL(2, 0)
236*8ca52cc3SSean Christopherson #define SGX_SECINFO_PAGE_TYPE_MASK	(SGX_PAGE_TYPE_MASK << 8)
237*8ca52cc3SSean Christopherson #define SGX_SECINFO_RESERVED_MASK	~(SGX_SECINFO_PERMISSION_MASK | \
238*8ca52cc3SSean Christopherson 					  SGX_SECINFO_PAGE_TYPE_MASK)
239*8ca52cc3SSean Christopherson 
240*8ca52cc3SSean Christopherson /**
241*8ca52cc3SSean Christopherson  * struct sgx_secinfo - describes attributes of an EPC page
242*8ca52cc3SSean Christopherson  * @flags:	permissions and type
243*8ca52cc3SSean Christopherson  *
244*8ca52cc3SSean Christopherson  * Used together with ENCLS leaves that add or modify an EPC page to an
245*8ca52cc3SSean Christopherson  * enclave to define page permissions and type.
246*8ca52cc3SSean Christopherson  */
247*8ca52cc3SSean Christopherson struct sgx_secinfo {
248*8ca52cc3SSean Christopherson 	u64 flags;
249*8ca52cc3SSean Christopherson 	u8  reserved[56];
250*8ca52cc3SSean Christopherson } __packed __aligned(64);
251*8ca52cc3SSean Christopherson 
252*8ca52cc3SSean Christopherson #define SGX_PCMD_RESERVED_SIZE 40
253*8ca52cc3SSean Christopherson 
254*8ca52cc3SSean Christopherson /**
255*8ca52cc3SSean Christopherson  * struct sgx_pcmd - Paging Crypto Metadata (PCMD)
256*8ca52cc3SSean Christopherson  * @enclave_id:	enclave identifier
257*8ca52cc3SSean Christopherson  * @mac:	MAC over PCMD, page contents and isvsvn
258*8ca52cc3SSean Christopherson  *
259*8ca52cc3SSean Christopherson  * PCMD is stored for every swapped page to the regular memory. When ELDU loads
260*8ca52cc3SSean Christopherson  * the page back it recalculates the MAC by using a isvsvn number stored in a
261*8ca52cc3SSean Christopherson  * VA page. Together these two structures bring integrity and rollback
262*8ca52cc3SSean Christopherson  * protection.
263*8ca52cc3SSean Christopherson  */
264*8ca52cc3SSean Christopherson struct sgx_pcmd {
265*8ca52cc3SSean Christopherson 	struct sgx_secinfo secinfo;
266*8ca52cc3SSean Christopherson 	u64 enclave_id;
267*8ca52cc3SSean Christopherson 	u8  reserved[SGX_PCMD_RESERVED_SIZE];
268*8ca52cc3SSean Christopherson 	u8  mac[16];
269*8ca52cc3SSean Christopherson } __packed __aligned(128);
270*8ca52cc3SSean Christopherson 
271*8ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED1_SIZE 84
272*8ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED2_SIZE 20
273*8ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED3_SIZE 32
274*8ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED4_SIZE 12
275*8ca52cc3SSean Christopherson 
276*8ca52cc3SSean Christopherson /**
277*8ca52cc3SSean Christopherson  * struct sgx_sigstruct_header -  defines author of the enclave
278*8ca52cc3SSean Christopherson  * @header1:		constant byte string
279*8ca52cc3SSean Christopherson  * @vendor:		must be either 0x0000 or 0x8086
280*8ca52cc3SSean Christopherson  * @date:		YYYYMMDD in BCD
281*8ca52cc3SSean Christopherson  * @header2:		costant byte string
282*8ca52cc3SSean Christopherson  * @swdefined:		software defined value
283*8ca52cc3SSean Christopherson  */
284*8ca52cc3SSean Christopherson struct sgx_sigstruct_header {
285*8ca52cc3SSean Christopherson 	u64 header1[2];
286*8ca52cc3SSean Christopherson 	u32 vendor;
287*8ca52cc3SSean Christopherson 	u32 date;
288*8ca52cc3SSean Christopherson 	u64 header2[2];
289*8ca52cc3SSean Christopherson 	u32 swdefined;
290*8ca52cc3SSean Christopherson 	u8  reserved1[84];
291*8ca52cc3SSean Christopherson } __packed;
292*8ca52cc3SSean Christopherson 
293*8ca52cc3SSean Christopherson /**
294*8ca52cc3SSean Christopherson  * struct sgx_sigstruct_body - defines contents of the enclave
295*8ca52cc3SSean Christopherson  * @miscselect:		additional information stored to an SSA frame
296*8ca52cc3SSean Christopherson  * @misc_mask:		required miscselect in SECS
297*8ca52cc3SSean Christopherson  * @attributes:		attributes for enclave
298*8ca52cc3SSean Christopherson  * @xfrm:		XSave-Feature Request Mask (subset of XCR0)
299*8ca52cc3SSean Christopherson  * @attributes_mask:	required attributes in SECS
300*8ca52cc3SSean Christopherson  * @xfrm_mask:		required XFRM in SECS
301*8ca52cc3SSean Christopherson  * @mrenclave:		SHA256-hash of the enclave contents
302*8ca52cc3SSean Christopherson  * @isvprodid:		a user-defined value that is used in key derivation
303*8ca52cc3SSean Christopherson  * @isvsvn:		a user-defined value that is used in key derivation
304*8ca52cc3SSean Christopherson  */
305*8ca52cc3SSean Christopherson struct sgx_sigstruct_body {
306*8ca52cc3SSean Christopherson 	u32 miscselect;
307*8ca52cc3SSean Christopherson 	u32 misc_mask;
308*8ca52cc3SSean Christopherson 	u8  reserved2[20];
309*8ca52cc3SSean Christopherson 	u64 attributes;
310*8ca52cc3SSean Christopherson 	u64 xfrm;
311*8ca52cc3SSean Christopherson 	u64 attributes_mask;
312*8ca52cc3SSean Christopherson 	u64 xfrm_mask;
313*8ca52cc3SSean Christopherson 	u8  mrenclave[32];
314*8ca52cc3SSean Christopherson 	u8  reserved3[32];
315*8ca52cc3SSean Christopherson 	u16 isvprodid;
316*8ca52cc3SSean Christopherson 	u16 isvsvn;
317*8ca52cc3SSean Christopherson } __packed;
318*8ca52cc3SSean Christopherson 
319*8ca52cc3SSean Christopherson /**
320*8ca52cc3SSean Christopherson  * struct sgx_sigstruct - an enclave signature
321*8ca52cc3SSean Christopherson  * @header:		defines author of the enclave
322*8ca52cc3SSean Christopherson  * @modulus:		the modulus of the public key
323*8ca52cc3SSean Christopherson  * @exponent:		the exponent of the public key
324*8ca52cc3SSean Christopherson  * @signature:		the signature calculated over the fields except modulus,
325*8ca52cc3SSean Christopherson  * @body:		defines contents of the enclave
326*8ca52cc3SSean Christopherson  * @q1:			a value used in RSA signature verification
327*8ca52cc3SSean Christopherson  * @q2:			a value used in RSA signature verification
328*8ca52cc3SSean Christopherson  *
329*8ca52cc3SSean Christopherson  * Header and body are the parts that are actual signed. The remaining fields
330*8ca52cc3SSean Christopherson  * define the signature of the enclave.
331*8ca52cc3SSean Christopherson  */
332*8ca52cc3SSean Christopherson struct sgx_sigstruct {
333*8ca52cc3SSean Christopherson 	struct sgx_sigstruct_header header;
334*8ca52cc3SSean Christopherson 	u8  modulus[SGX_MODULUS_SIZE];
335*8ca52cc3SSean Christopherson 	u32 exponent;
336*8ca52cc3SSean Christopherson 	u8  signature[SGX_MODULUS_SIZE];
337*8ca52cc3SSean Christopherson 	struct sgx_sigstruct_body body;
338*8ca52cc3SSean Christopherson 	u8  reserved4[12];
339*8ca52cc3SSean Christopherson 	u8  q1[SGX_MODULUS_SIZE];
340*8ca52cc3SSean Christopherson 	u8  q2[SGX_MODULUS_SIZE];
341*8ca52cc3SSean Christopherson } __packed;
342*8ca52cc3SSean Christopherson 
343*8ca52cc3SSean Christopherson #define SGX_LAUNCH_TOKEN_SIZE 304
344*8ca52cc3SSean Christopherson 
345*8ca52cc3SSean Christopherson /*
346*8ca52cc3SSean Christopherson  * Do not put any hardware-defined SGX structure representations below this
347*8ca52cc3SSean Christopherson  * comment!
348*8ca52cc3SSean Christopherson  */
349*8ca52cc3SSean Christopherson 
350*8ca52cc3SSean Christopherson #endif /* _ASM_X86_SGX_H */
351