18ca52cc3SSean Christopherson /* SPDX-License-Identifier: GPL-2.0 */ 28ca52cc3SSean Christopherson /** 38ca52cc3SSean Christopherson * Copyright(c) 2016-20 Intel Corporation. 48ca52cc3SSean Christopherson * 58ca52cc3SSean Christopherson * Intel Software Guard Extensions (SGX) support. 68ca52cc3SSean Christopherson */ 78ca52cc3SSean Christopherson #ifndef _ASM_X86_SGX_H 88ca52cc3SSean Christopherson #define _ASM_X86_SGX_H 98ca52cc3SSean Christopherson 108ca52cc3SSean Christopherson #include <linux/bits.h> 118ca52cc3SSean Christopherson #include <linux/types.h> 128ca52cc3SSean Christopherson 138ca52cc3SSean Christopherson /* 148ca52cc3SSean Christopherson * This file contains both data structures defined by SGX architecture and Linux 158ca52cc3SSean Christopherson * defined software data structures and functions. The two should not be mixed 168ca52cc3SSean Christopherson * together for better readibility. The architectural definitions come first. 178ca52cc3SSean Christopherson */ 188ca52cc3SSean Christopherson 198ca52cc3SSean Christopherson /* The SGX specific CPUID function. */ 208ca52cc3SSean Christopherson #define SGX_CPUID 0x12 218ca52cc3SSean Christopherson /* EPC enumeration. */ 228ca52cc3SSean Christopherson #define SGX_CPUID_EPC 2 238ca52cc3SSean Christopherson /* An invalid EPC section, i.e. the end marker. */ 248ca52cc3SSean Christopherson #define SGX_CPUID_EPC_INVALID 0x0 258ca52cc3SSean Christopherson /* A valid EPC section. */ 268ca52cc3SSean Christopherson #define SGX_CPUID_EPC_SECTION 0x1 278ca52cc3SSean Christopherson /* The bitmask for the EPC section type. */ 288ca52cc3SSean Christopherson #define SGX_CPUID_EPC_MASK GENMASK(3, 0) 298ca52cc3SSean Christopherson 309c55c78aSSean Christopherson enum sgx_encls_function { 319c55c78aSSean Christopherson ECREATE = 0x00, 329c55c78aSSean Christopherson EADD = 0x01, 339c55c78aSSean Christopherson EINIT = 0x02, 349c55c78aSSean Christopherson EREMOVE = 0x03, 359c55c78aSSean Christopherson EDGBRD = 0x04, 369c55c78aSSean Christopherson EDGBWR = 0x05, 379c55c78aSSean Christopherson EEXTEND = 0x06, 389c55c78aSSean Christopherson ELDU = 0x08, 399c55c78aSSean Christopherson EBLOCK = 0x09, 409c55c78aSSean Christopherson EPA = 0x0A, 419c55c78aSSean Christopherson EWB = 0x0B, 429c55c78aSSean Christopherson ETRACK = 0x0C, 4332ddda8eSSean Christopherson EAUG = 0x0D, 4432ddda8eSSean Christopherson EMODPR = 0x0E, 4532ddda8eSSean Christopherson EMODT = 0x0F, 469c55c78aSSean Christopherson }; 479c55c78aSSean Christopherson 488ca52cc3SSean Christopherson /** 498ca52cc3SSean Christopherson * enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV 508ca52cc3SSean Christopherson * %SGX_NOT_TRACKED: Previous ETRACK's shootdown sequence has not 518ca52cc3SSean Christopherson * been completed yet. 528ca52cc3SSean Christopherson * %SGX_CHILD_PRESENT SECS has child pages present in the EPC. 538ca52cc3SSean Christopherson * %SGX_INVALID_EINITTOKEN: EINITTOKEN is invalid and enclave signer's 548ca52cc3SSean Christopherson * public key does not match IA32_SGXLEPUBKEYHASH. 558ca52cc3SSean Christopherson * %SGX_UNMASKED_EVENT: An unmasked event, e.g. INTR, was received 568ca52cc3SSean Christopherson */ 578ca52cc3SSean Christopherson enum sgx_return_code { 588ca52cc3SSean Christopherson SGX_NOT_TRACKED = 11, 598ca52cc3SSean Christopherson SGX_CHILD_PRESENT = 13, 608ca52cc3SSean Christopherson SGX_INVALID_EINITTOKEN = 16, 618ca52cc3SSean Christopherson SGX_UNMASKED_EVENT = 128, 628ca52cc3SSean Christopherson }; 638ca52cc3SSean Christopherson 648ca52cc3SSean Christopherson /* The modulus size for 3072-bit RSA keys. */ 658ca52cc3SSean Christopherson #define SGX_MODULUS_SIZE 384 668ca52cc3SSean Christopherson 678ca52cc3SSean Christopherson /** 688ca52cc3SSean Christopherson * enum sgx_miscselect - additional information to an SSA frame 698ca52cc3SSean Christopherson * %SGX_MISC_EXINFO: Report #PF or #GP to the SSA frame. 708ca52cc3SSean Christopherson * 718ca52cc3SSean Christopherson * Save State Area (SSA) is a stack inside the enclave used to store processor 728ca52cc3SSean Christopherson * state when an exception or interrupt occurs. This enum defines additional 738ca52cc3SSean Christopherson * information stored to an SSA frame. 748ca52cc3SSean Christopherson */ 758ca52cc3SSean Christopherson enum sgx_miscselect { 768ca52cc3SSean Christopherson SGX_MISC_EXINFO = BIT(0), 778ca52cc3SSean Christopherson }; 788ca52cc3SSean Christopherson 798ca52cc3SSean Christopherson #define SGX_MISC_RESERVED_MASK GENMASK_ULL(63, 1) 808ca52cc3SSean Christopherson 818ca52cc3SSean Christopherson #define SGX_SSA_GPRS_SIZE 184 828ca52cc3SSean Christopherson #define SGX_SSA_MISC_EXINFO_SIZE 16 838ca52cc3SSean Christopherson 848ca52cc3SSean Christopherson /** 858ca52cc3SSean Christopherson * enum sgx_attributes - the attributes field in &struct sgx_secs 868ca52cc3SSean Christopherson * %SGX_ATTR_INIT: Enclave can be entered (is initialized). 878ca52cc3SSean Christopherson * %SGX_ATTR_DEBUG: Allow ENCLS(EDBGRD) and ENCLS(EDBGWR). 888ca52cc3SSean Christopherson * %SGX_ATTR_MODE64BIT: Tell that this a 64-bit enclave. 898ca52cc3SSean Christopherson * %SGX_ATTR_PROVISIONKEY: Allow to use provisioning keys for remote 908ca52cc3SSean Christopherson * attestation. 918ca52cc3SSean Christopherson * %SGX_ATTR_KSS: Allow to use key separation and sharing (KSS). 928ca52cc3SSean Christopherson * %SGX_ATTR_EINITTOKENKEY: Allow to use token signing key that is used to 938ca52cc3SSean Christopherson * sign cryptographic tokens that can be passed to 948ca52cc3SSean Christopherson * EINIT as an authorization to run an enclave. 958ca52cc3SSean Christopherson */ 968ca52cc3SSean Christopherson enum sgx_attribute { 978ca52cc3SSean Christopherson SGX_ATTR_INIT = BIT(0), 988ca52cc3SSean Christopherson SGX_ATTR_DEBUG = BIT(1), 998ca52cc3SSean Christopherson SGX_ATTR_MODE64BIT = BIT(2), 1008ca52cc3SSean Christopherson SGX_ATTR_PROVISIONKEY = BIT(4), 1018ca52cc3SSean Christopherson SGX_ATTR_EINITTOKENKEY = BIT(5), 1028ca52cc3SSean Christopherson SGX_ATTR_KSS = BIT(7), 1038ca52cc3SSean Christopherson }; 1048ca52cc3SSean Christopherson 1058ca52cc3SSean Christopherson #define SGX_ATTR_RESERVED_MASK (BIT_ULL(3) | BIT_ULL(6) | GENMASK_ULL(63, 8)) 1068ca52cc3SSean Christopherson 1078ca52cc3SSean Christopherson /** 1088ca52cc3SSean Christopherson * struct sgx_secs - SGX Enclave Control Structure (SECS) 1098ca52cc3SSean Christopherson * @size: size of the address space 1108ca52cc3SSean Christopherson * @base: base address of the address space 1118ca52cc3SSean Christopherson * @ssa_frame_size: size of an SSA frame 1128ca52cc3SSean Christopherson * @miscselect: additional information stored to an SSA frame 1138ca52cc3SSean Christopherson * @attributes: attributes for enclave 1148ca52cc3SSean Christopherson * @xfrm: XSave-Feature Request Mask (subset of XCR0) 1158ca52cc3SSean Christopherson * @mrenclave: SHA256-hash of the enclave contents 1168ca52cc3SSean Christopherson * @mrsigner: SHA256-hash of the public key used to sign the SIGSTRUCT 1178ca52cc3SSean Christopherson * @config_id: a user-defined value that is used in key derivation 1188ca52cc3SSean Christopherson * @isv_prod_id: a user-defined value that is used in key derivation 1198ca52cc3SSean Christopherson * @isv_svn: a user-defined value that is used in key derivation 1208ca52cc3SSean Christopherson * @config_svn: a user-defined value that is used in key derivation 1218ca52cc3SSean Christopherson * 1228ca52cc3SSean Christopherson * SGX Enclave Control Structure (SECS) is a special enclave page that is not 1238ca52cc3SSean Christopherson * visible in the address space. In fact, this structure defines the address 1248ca52cc3SSean Christopherson * range and other global attributes for the enclave and it is the first EPC 1258ca52cc3SSean Christopherson * page created for any enclave. It is moved from a temporary buffer to an EPC 1268ca52cc3SSean Christopherson * by the means of ENCLS[ECREATE] function. 1278ca52cc3SSean Christopherson */ 1288ca52cc3SSean Christopherson struct sgx_secs { 1298ca52cc3SSean Christopherson u64 size; 1308ca52cc3SSean Christopherson u64 base; 1318ca52cc3SSean Christopherson u32 ssa_frame_size; 1328ca52cc3SSean Christopherson u32 miscselect; 1338ca52cc3SSean Christopherson u8 reserved1[24]; 1348ca52cc3SSean Christopherson u64 attributes; 1358ca52cc3SSean Christopherson u64 xfrm; 1368ca52cc3SSean Christopherson u32 mrenclave[8]; 1378ca52cc3SSean Christopherson u8 reserved2[32]; 1388ca52cc3SSean Christopherson u32 mrsigner[8]; 1398ca52cc3SSean Christopherson u8 reserved3[32]; 1408ca52cc3SSean Christopherson u32 config_id[16]; 1418ca52cc3SSean Christopherson u16 isv_prod_id; 1428ca52cc3SSean Christopherson u16 isv_svn; 1438ca52cc3SSean Christopherson u16 config_svn; 1448ca52cc3SSean Christopherson u8 reserved4[3834]; 1458ca52cc3SSean Christopherson } __packed; 1468ca52cc3SSean Christopherson 1478ca52cc3SSean Christopherson /** 1488ca52cc3SSean Christopherson * enum sgx_tcs_flags - execution flags for TCS 1498ca52cc3SSean Christopherson * %SGX_TCS_DBGOPTIN: If enabled allows single-stepping and breakpoints 1508ca52cc3SSean Christopherson * inside an enclave. It is cleared by EADD but can 1518ca52cc3SSean Christopherson * be set later with EDBGWR. 1528ca52cc3SSean Christopherson */ 1538ca52cc3SSean Christopherson enum sgx_tcs_flags { 1548ca52cc3SSean Christopherson SGX_TCS_DBGOPTIN = 0x01, 1558ca52cc3SSean Christopherson }; 1568ca52cc3SSean Christopherson 1578ca52cc3SSean Christopherson #define SGX_TCS_RESERVED_MASK GENMASK_ULL(63, 1) 1588ca52cc3SSean Christopherson #define SGX_TCS_RESERVED_SIZE 4024 1598ca52cc3SSean Christopherson 1608ca52cc3SSean Christopherson /** 1618ca52cc3SSean Christopherson * struct sgx_tcs - Thread Control Structure (TCS) 1628ca52cc3SSean Christopherson * @state: used to mark an entered TCS 1638ca52cc3SSean Christopherson * @flags: execution flags (cleared by EADD) 1648ca52cc3SSean Christopherson * @ssa_offset: SSA stack offset relative to the enclave base 1658ca52cc3SSean Christopherson * @ssa_index: the current SSA frame index (cleard by EADD) 1668ca52cc3SSean Christopherson * @nr_ssa_frames: the number of frame in the SSA stack 1678ca52cc3SSean Christopherson * @entry_offset: entry point offset relative to the enclave base 1688ca52cc3SSean Christopherson * @exit_addr: address outside the enclave to exit on an exception or 1698ca52cc3SSean Christopherson * interrupt 1708ca52cc3SSean Christopherson * @fs_offset: offset relative to the enclave base to become FS 1718ca52cc3SSean Christopherson * segment inside the enclave 1728ca52cc3SSean Christopherson * @gs_offset: offset relative to the enclave base to become GS 1738ca52cc3SSean Christopherson * segment inside the enclave 1748ca52cc3SSean Christopherson * @fs_limit: size to become a new FS-limit (only 32-bit enclaves) 1758ca52cc3SSean Christopherson * @gs_limit: size to become a new GS-limit (only 32-bit enclaves) 1768ca52cc3SSean Christopherson * 1778ca52cc3SSean Christopherson * Thread Control Structure (TCS) is an enclave page visible in its address 1788ca52cc3SSean Christopherson * space that defines an entry point inside the enclave. A thread enters inside 1798ca52cc3SSean Christopherson * an enclave by supplying address of TCS to ENCLU(EENTER). A TCS can be entered 1808ca52cc3SSean Christopherson * by only one thread at a time. 1818ca52cc3SSean Christopherson */ 1828ca52cc3SSean Christopherson struct sgx_tcs { 1838ca52cc3SSean Christopherson u64 state; 1848ca52cc3SSean Christopherson u64 flags; 1858ca52cc3SSean Christopherson u64 ssa_offset; 1868ca52cc3SSean Christopherson u32 ssa_index; 1878ca52cc3SSean Christopherson u32 nr_ssa_frames; 1888ca52cc3SSean Christopherson u64 entry_offset; 1898ca52cc3SSean Christopherson u64 exit_addr; 1908ca52cc3SSean Christopherson u64 fs_offset; 1918ca52cc3SSean Christopherson u64 gs_offset; 1928ca52cc3SSean Christopherson u32 fs_limit; 1938ca52cc3SSean Christopherson u32 gs_limit; 1948ca52cc3SSean Christopherson u8 reserved[SGX_TCS_RESERVED_SIZE]; 1958ca52cc3SSean Christopherson } __packed; 1968ca52cc3SSean Christopherson 1978ca52cc3SSean Christopherson /** 1988ca52cc3SSean Christopherson * struct sgx_pageinfo - an enclave page descriptor 1998ca52cc3SSean Christopherson * @addr: address of the enclave page 2008ca52cc3SSean Christopherson * @contents: pointer to the page contents 2018ca52cc3SSean Christopherson * @metadata: pointer either to a SECINFO or PCMD instance 2028ca52cc3SSean Christopherson * @secs: address of the SECS page 2038ca52cc3SSean Christopherson */ 2048ca52cc3SSean Christopherson struct sgx_pageinfo { 2058ca52cc3SSean Christopherson u64 addr; 2068ca52cc3SSean Christopherson u64 contents; 2078ca52cc3SSean Christopherson u64 metadata; 2088ca52cc3SSean Christopherson u64 secs; 2098ca52cc3SSean Christopherson } __packed __aligned(32); 2108ca52cc3SSean Christopherson 2118ca52cc3SSean Christopherson 2128ca52cc3SSean Christopherson /** 2138ca52cc3SSean Christopherson * enum sgx_page_type - bits in the SECINFO flags defining the page type 2148ca52cc3SSean Christopherson * %SGX_PAGE_TYPE_SECS: a SECS page 2158ca52cc3SSean Christopherson * %SGX_PAGE_TYPE_TCS: a TCS page 2168ca52cc3SSean Christopherson * %SGX_PAGE_TYPE_REG: a regular page 2178ca52cc3SSean Christopherson * %SGX_PAGE_TYPE_VA: a VA page 2188ca52cc3SSean Christopherson * %SGX_PAGE_TYPE_TRIM: a page in trimmed state 2198ca52cc3SSean Christopherson */ 2208ca52cc3SSean Christopherson enum sgx_page_type { 2218ca52cc3SSean Christopherson SGX_PAGE_TYPE_SECS, 2228ca52cc3SSean Christopherson SGX_PAGE_TYPE_TCS, 2238ca52cc3SSean Christopherson SGX_PAGE_TYPE_REG, 2248ca52cc3SSean Christopherson SGX_PAGE_TYPE_VA, 2258ca52cc3SSean Christopherson SGX_PAGE_TYPE_TRIM, 2268ca52cc3SSean Christopherson }; 2278ca52cc3SSean Christopherson 2288ca52cc3SSean Christopherson #define SGX_NR_PAGE_TYPES 5 2298ca52cc3SSean Christopherson #define SGX_PAGE_TYPE_MASK GENMASK(7, 0) 2308ca52cc3SSean Christopherson 2318ca52cc3SSean Christopherson /** 2328ca52cc3SSean Christopherson * enum sgx_secinfo_flags - the flags field in &struct sgx_secinfo 2338ca52cc3SSean Christopherson * %SGX_SECINFO_R: allow read 2348ca52cc3SSean Christopherson * %SGX_SECINFO_W: allow write 2358ca52cc3SSean Christopherson * %SGX_SECINFO_X: allow execution 2368ca52cc3SSean Christopherson * %SGX_SECINFO_SECS: a SECS page 2378ca52cc3SSean Christopherson * %SGX_SECINFO_TCS: a TCS page 2388ca52cc3SSean Christopherson * %SGX_SECINFO_REG: a regular page 2398ca52cc3SSean Christopherson * %SGX_SECINFO_VA: a VA page 2408ca52cc3SSean Christopherson * %SGX_SECINFO_TRIM: a page in trimmed state 2418ca52cc3SSean Christopherson */ 2428ca52cc3SSean Christopherson enum sgx_secinfo_flags { 2438ca52cc3SSean Christopherson SGX_SECINFO_R = BIT(0), 2448ca52cc3SSean Christopherson SGX_SECINFO_W = BIT(1), 2458ca52cc3SSean Christopherson SGX_SECINFO_X = BIT(2), 2468ca52cc3SSean Christopherson SGX_SECINFO_SECS = (SGX_PAGE_TYPE_SECS << 8), 2478ca52cc3SSean Christopherson SGX_SECINFO_TCS = (SGX_PAGE_TYPE_TCS << 8), 2488ca52cc3SSean Christopherson SGX_SECINFO_REG = (SGX_PAGE_TYPE_REG << 8), 2498ca52cc3SSean Christopherson SGX_SECINFO_VA = (SGX_PAGE_TYPE_VA << 8), 2508ca52cc3SSean Christopherson SGX_SECINFO_TRIM = (SGX_PAGE_TYPE_TRIM << 8), 2518ca52cc3SSean Christopherson }; 2528ca52cc3SSean Christopherson 2538ca52cc3SSean Christopherson #define SGX_SECINFO_PERMISSION_MASK GENMASK_ULL(2, 0) 2548ca52cc3SSean Christopherson #define SGX_SECINFO_PAGE_TYPE_MASK (SGX_PAGE_TYPE_MASK << 8) 2558ca52cc3SSean Christopherson #define SGX_SECINFO_RESERVED_MASK ~(SGX_SECINFO_PERMISSION_MASK | \ 2568ca52cc3SSean Christopherson SGX_SECINFO_PAGE_TYPE_MASK) 2578ca52cc3SSean Christopherson 2588ca52cc3SSean Christopherson /** 2598ca52cc3SSean Christopherson * struct sgx_secinfo - describes attributes of an EPC page 2608ca52cc3SSean Christopherson * @flags: permissions and type 2618ca52cc3SSean Christopherson * 2628ca52cc3SSean Christopherson * Used together with ENCLS leaves that add or modify an EPC page to an 2638ca52cc3SSean Christopherson * enclave to define page permissions and type. 2648ca52cc3SSean Christopherson */ 2658ca52cc3SSean Christopherson struct sgx_secinfo { 2668ca52cc3SSean Christopherson u64 flags; 2678ca52cc3SSean Christopherson u8 reserved[56]; 2688ca52cc3SSean Christopherson } __packed __aligned(64); 2698ca52cc3SSean Christopherson 2708ca52cc3SSean Christopherson #define SGX_PCMD_RESERVED_SIZE 40 2718ca52cc3SSean Christopherson 2728ca52cc3SSean Christopherson /** 2738ca52cc3SSean Christopherson * struct sgx_pcmd - Paging Crypto Metadata (PCMD) 2748ca52cc3SSean Christopherson * @enclave_id: enclave identifier 2758ca52cc3SSean Christopherson * @mac: MAC over PCMD, page contents and isvsvn 2768ca52cc3SSean Christopherson * 2778ca52cc3SSean Christopherson * PCMD is stored for every swapped page to the regular memory. When ELDU loads 2788ca52cc3SSean Christopherson * the page back it recalculates the MAC by using a isvsvn number stored in a 2798ca52cc3SSean Christopherson * VA page. Together these two structures bring integrity and rollback 2808ca52cc3SSean Christopherson * protection. 2818ca52cc3SSean Christopherson */ 2828ca52cc3SSean Christopherson struct sgx_pcmd { 2838ca52cc3SSean Christopherson struct sgx_secinfo secinfo; 2848ca52cc3SSean Christopherson u64 enclave_id; 2858ca52cc3SSean Christopherson u8 reserved[SGX_PCMD_RESERVED_SIZE]; 2868ca52cc3SSean Christopherson u8 mac[16]; 2878ca52cc3SSean Christopherson } __packed __aligned(128); 2888ca52cc3SSean Christopherson 2898ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED1_SIZE 84 2908ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED2_SIZE 20 2918ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED3_SIZE 32 2928ca52cc3SSean Christopherson #define SGX_SIGSTRUCT_RESERVED4_SIZE 12 2938ca52cc3SSean Christopherson 2948ca52cc3SSean Christopherson /** 2958ca52cc3SSean Christopherson * struct sgx_sigstruct_header - defines author of the enclave 2968ca52cc3SSean Christopherson * @header1: constant byte string 2978ca52cc3SSean Christopherson * @vendor: must be either 0x0000 or 0x8086 2988ca52cc3SSean Christopherson * @date: YYYYMMDD in BCD 2998ca52cc3SSean Christopherson * @header2: costant byte string 3008ca52cc3SSean Christopherson * @swdefined: software defined value 3018ca52cc3SSean Christopherson */ 3028ca52cc3SSean Christopherson struct sgx_sigstruct_header { 3038ca52cc3SSean Christopherson u64 header1[2]; 3048ca52cc3SSean Christopherson u32 vendor; 3058ca52cc3SSean Christopherson u32 date; 3068ca52cc3SSean Christopherson u64 header2[2]; 3078ca52cc3SSean Christopherson u32 swdefined; 3088ca52cc3SSean Christopherson u8 reserved1[84]; 3098ca52cc3SSean Christopherson } __packed; 3108ca52cc3SSean Christopherson 3118ca52cc3SSean Christopherson /** 3128ca52cc3SSean Christopherson * struct sgx_sigstruct_body - defines contents of the enclave 3138ca52cc3SSean Christopherson * @miscselect: additional information stored to an SSA frame 3148ca52cc3SSean Christopherson * @misc_mask: required miscselect in SECS 3158ca52cc3SSean Christopherson * @attributes: attributes for enclave 3168ca52cc3SSean Christopherson * @xfrm: XSave-Feature Request Mask (subset of XCR0) 3178ca52cc3SSean Christopherson * @attributes_mask: required attributes in SECS 3188ca52cc3SSean Christopherson * @xfrm_mask: required XFRM in SECS 3198ca52cc3SSean Christopherson * @mrenclave: SHA256-hash of the enclave contents 3208ca52cc3SSean Christopherson * @isvprodid: a user-defined value that is used in key derivation 3218ca52cc3SSean Christopherson * @isvsvn: a user-defined value that is used in key derivation 3228ca52cc3SSean Christopherson */ 3238ca52cc3SSean Christopherson struct sgx_sigstruct_body { 3248ca52cc3SSean Christopherson u32 miscselect; 3258ca52cc3SSean Christopherson u32 misc_mask; 3268ca52cc3SSean Christopherson u8 reserved2[20]; 3278ca52cc3SSean Christopherson u64 attributes; 3288ca52cc3SSean Christopherson u64 xfrm; 3298ca52cc3SSean Christopherson u64 attributes_mask; 3308ca52cc3SSean Christopherson u64 xfrm_mask; 3318ca52cc3SSean Christopherson u8 mrenclave[32]; 3328ca52cc3SSean Christopherson u8 reserved3[32]; 3338ca52cc3SSean Christopherson u16 isvprodid; 3348ca52cc3SSean Christopherson u16 isvsvn; 3358ca52cc3SSean Christopherson } __packed; 3368ca52cc3SSean Christopherson 3378ca52cc3SSean Christopherson /** 3388ca52cc3SSean Christopherson * struct sgx_sigstruct - an enclave signature 3398ca52cc3SSean Christopherson * @header: defines author of the enclave 3408ca52cc3SSean Christopherson * @modulus: the modulus of the public key 3418ca52cc3SSean Christopherson * @exponent: the exponent of the public key 3428ca52cc3SSean Christopherson * @signature: the signature calculated over the fields except modulus, 3438ca52cc3SSean Christopherson * @body: defines contents of the enclave 3448ca52cc3SSean Christopherson * @q1: a value used in RSA signature verification 3458ca52cc3SSean Christopherson * @q2: a value used in RSA signature verification 3468ca52cc3SSean Christopherson * 3478ca52cc3SSean Christopherson * Header and body are the parts that are actual signed. The remaining fields 3488ca52cc3SSean Christopherson * define the signature of the enclave. 3498ca52cc3SSean Christopherson */ 3508ca52cc3SSean Christopherson struct sgx_sigstruct { 3518ca52cc3SSean Christopherson struct sgx_sigstruct_header header; 3528ca52cc3SSean Christopherson u8 modulus[SGX_MODULUS_SIZE]; 3538ca52cc3SSean Christopherson u32 exponent; 3548ca52cc3SSean Christopherson u8 signature[SGX_MODULUS_SIZE]; 3558ca52cc3SSean Christopherson struct sgx_sigstruct_body body; 3568ca52cc3SSean Christopherson u8 reserved4[12]; 3578ca52cc3SSean Christopherson u8 q1[SGX_MODULUS_SIZE]; 3588ca52cc3SSean Christopherson u8 q2[SGX_MODULUS_SIZE]; 3598ca52cc3SSean Christopherson } __packed; 3608ca52cc3SSean Christopherson 3618ca52cc3SSean Christopherson #define SGX_LAUNCH_TOKEN_SIZE 304 3628ca52cc3SSean Christopherson 3638ca52cc3SSean Christopherson /* 3648ca52cc3SSean Christopherson * Do not put any hardware-defined SGX structure representations below this 3658ca52cc3SSean Christopherson * comment! 3668ca52cc3SSean Christopherson */ 3678ca52cc3SSean Christopherson 368*d155030bSSean Christopherson #ifdef CONFIG_X86_SGX_KVM 369*d155030bSSean Christopherson int sgx_virt_ecreate(struct sgx_pageinfo *pageinfo, void __user *secs, 370*d155030bSSean Christopherson int *trapnr); 371*d155030bSSean Christopherson int sgx_virt_einit(void __user *sigstruct, void __user *token, 372*d155030bSSean Christopherson void __user *secs, u64 *lepubkeyhash, int *trapnr); 373*d155030bSSean Christopherson #endif 374*d155030bSSean Christopherson 3758ca52cc3SSean Christopherson #endif /* _ASM_X86_SGX_H */ 376