Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/asm
File: sgx.h
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
[0] Fix | Delete
/*
[1] Fix | Delete
* Copyright(c) 2016-20 Intel Corporation.
[2] Fix | Delete
*/
[3] Fix | Delete
#ifndef _ASM_X86_SGX_H
[4] Fix | Delete
#define _ASM_X86_SGX_H
[5] Fix | Delete
[6] Fix | Delete
#include <linux/types.h>
[7] Fix | Delete
#include <linux/ioctl.h>
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* enum sgx_page_flags - page control flags
[11] Fix | Delete
* %SGX_PAGE_MEASURE: Measure the page contents with a sequence of
[12] Fix | Delete
* ENCLS[EEXTEND] operations.
[13] Fix | Delete
*/
[14] Fix | Delete
enum sgx_page_flags {
[15] Fix | Delete
SGX_PAGE_MEASURE = 0x01,
[16] Fix | Delete
};
[17] Fix | Delete
[18] Fix | Delete
#define SGX_MAGIC 0xA4
[19] Fix | Delete
[20] Fix | Delete
#define SGX_IOC_ENCLAVE_CREATE \
[21] Fix | Delete
_IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create)
[22] Fix | Delete
#define SGX_IOC_ENCLAVE_ADD_PAGES \
[23] Fix | Delete
_IOWR(SGX_MAGIC, 0x01, struct sgx_enclave_add_pages)
[24] Fix | Delete
#define SGX_IOC_ENCLAVE_INIT \
[25] Fix | Delete
_IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
[26] Fix | Delete
#define SGX_IOC_ENCLAVE_PROVISION \
[27] Fix | Delete
_IOW(SGX_MAGIC, 0x03, struct sgx_enclave_provision)
[28] Fix | Delete
#define SGX_IOC_VEPC_REMOVE_ALL \
[29] Fix | Delete
_IO(SGX_MAGIC, 0x04)
[30] Fix | Delete
#define SGX_IOC_ENCLAVE_RESTRICT_PERMISSIONS \
[31] Fix | Delete
_IOWR(SGX_MAGIC, 0x05, struct sgx_enclave_restrict_permissions)
[32] Fix | Delete
#define SGX_IOC_ENCLAVE_MODIFY_TYPES \
[33] Fix | Delete
_IOWR(SGX_MAGIC, 0x06, struct sgx_enclave_modify_types)
[34] Fix | Delete
#define SGX_IOC_ENCLAVE_REMOVE_PAGES \
[35] Fix | Delete
_IOWR(SGX_MAGIC, 0x07, struct sgx_enclave_remove_pages)
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* struct sgx_enclave_create - parameter structure for the
[39] Fix | Delete
* %SGX_IOC_ENCLAVE_CREATE ioctl
[40] Fix | Delete
* @src: address for the SECS page data
[41] Fix | Delete
*/
[42] Fix | Delete
struct sgx_enclave_create {
[43] Fix | Delete
__u64 src;
[44] Fix | Delete
};
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* struct sgx_enclave_add_pages - parameter structure for the
[48] Fix | Delete
* %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
[49] Fix | Delete
* @src: start address for the page data
[50] Fix | Delete
* @offset: starting page offset
[51] Fix | Delete
* @length: length of the data (multiple of the page size)
[52] Fix | Delete
* @secinfo: address for the SECINFO data
[53] Fix | Delete
* @flags: page control flags
[54] Fix | Delete
* @count: number of bytes added (multiple of the page size)
[55] Fix | Delete
*/
[56] Fix | Delete
struct sgx_enclave_add_pages {
[57] Fix | Delete
__u64 src;
[58] Fix | Delete
__u64 offset;
[59] Fix | Delete
__u64 length;
[60] Fix | Delete
__u64 secinfo;
[61] Fix | Delete
__u64 flags;
[62] Fix | Delete
__u64 count;
[63] Fix | Delete
};
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* struct sgx_enclave_init - parameter structure for the
[67] Fix | Delete
* %SGX_IOC_ENCLAVE_INIT ioctl
[68] Fix | Delete
* @sigstruct: address for the SIGSTRUCT data
[69] Fix | Delete
*/
[70] Fix | Delete
struct sgx_enclave_init {
[71] Fix | Delete
__u64 sigstruct;
[72] Fix | Delete
};
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* struct sgx_enclave_provision - parameter structure for the
[76] Fix | Delete
* %SGX_IOC_ENCLAVE_PROVISION ioctl
[77] Fix | Delete
* @fd: file handle of /dev/sgx_provision
[78] Fix | Delete
*/
[79] Fix | Delete
struct sgx_enclave_provision {
[80] Fix | Delete
__u64 fd;
[81] Fix | Delete
};
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* struct sgx_enclave_restrict_permissions - parameters for ioctl
[85] Fix | Delete
* %SGX_IOC_ENCLAVE_RESTRICT_PERMISSIONS
[86] Fix | Delete
* @offset: starting page offset (page aligned relative to enclave base
[87] Fix | Delete
* address defined in SECS)
[88] Fix | Delete
* @length: length of memory (multiple of the page size)
[89] Fix | Delete
* @permissions:new permission bits for pages in range described by @offset
[90] Fix | Delete
* and @length
[91] Fix | Delete
* @result: (output) SGX result code of ENCLS[EMODPR] function
[92] Fix | Delete
* @count: (output) bytes successfully changed (multiple of page size)
[93] Fix | Delete
*/
[94] Fix | Delete
struct sgx_enclave_restrict_permissions {
[95] Fix | Delete
__u64 offset;
[96] Fix | Delete
__u64 length;
[97] Fix | Delete
__u64 permissions;
[98] Fix | Delete
__u64 result;
[99] Fix | Delete
__u64 count;
[100] Fix | Delete
};
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* struct sgx_enclave_modify_types - parameters for ioctl
[104] Fix | Delete
* %SGX_IOC_ENCLAVE_MODIFY_TYPES
[105] Fix | Delete
* @offset: starting page offset (page aligned relative to enclave base
[106] Fix | Delete
* address defined in SECS)
[107] Fix | Delete
* @length: length of memory (multiple of the page size)
[108] Fix | Delete
* @page_type: new type for pages in range described by @offset and @length
[109] Fix | Delete
* @result: (output) SGX result code of ENCLS[EMODT] function
[110] Fix | Delete
* @count: (output) bytes successfully changed (multiple of page size)
[111] Fix | Delete
*/
[112] Fix | Delete
struct sgx_enclave_modify_types {
[113] Fix | Delete
__u64 offset;
[114] Fix | Delete
__u64 length;
[115] Fix | Delete
__u64 page_type;
[116] Fix | Delete
__u64 result;
[117] Fix | Delete
__u64 count;
[118] Fix | Delete
};
[119] Fix | Delete
[120] Fix | Delete
/**
[121] Fix | Delete
* struct sgx_enclave_remove_pages - %SGX_IOC_ENCLAVE_REMOVE_PAGES parameters
[122] Fix | Delete
* @offset: starting page offset (page aligned relative to enclave base
[123] Fix | Delete
* address defined in SECS)
[124] Fix | Delete
* @length: length of memory (multiple of the page size)
[125] Fix | Delete
* @count: (output) bytes successfully changed (multiple of page size)
[126] Fix | Delete
*
[127] Fix | Delete
* Regular (PT_REG) or TCS (PT_TCS) can be removed from an initialized
[128] Fix | Delete
* enclave if the system supports SGX2. First, the %SGX_IOC_ENCLAVE_MODIFY_TYPES
[129] Fix | Delete
* ioctl() should be used to change the page type to PT_TRIM. After that
[130] Fix | Delete
* succeeds ENCLU[EACCEPT] should be run from within the enclave and then
[131] Fix | Delete
* %SGX_IOC_ENCLAVE_REMOVE_PAGES can be used to complete the page removal.
[132] Fix | Delete
*/
[133] Fix | Delete
struct sgx_enclave_remove_pages {
[134] Fix | Delete
__u64 offset;
[135] Fix | Delete
__u64 length;
[136] Fix | Delete
__u64 count;
[137] Fix | Delete
};
[138] Fix | Delete
[139] Fix | Delete
struct sgx_enclave_run;
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* typedef sgx_enclave_user_handler_t - Exit handler function accepted by
[143] Fix | Delete
* __vdso_sgx_enter_enclave()
[144] Fix | Delete
* @run: The run instance given by the caller
[145] Fix | Delete
*
[146] Fix | Delete
* The register parameters contain the snapshot of their values at enclave
[147] Fix | Delete
* exit. An invalid ENCLU function number will cause -EINVAL to be returned
[148] Fix | Delete
* to the caller.
[149] Fix | Delete
*
[150] Fix | Delete
* Return:
[151] Fix | Delete
* - <= 0: The given value is returned back to the caller.
[152] Fix | Delete
* - > 0: ENCLU function to invoke, either EENTER or ERESUME.
[153] Fix | Delete
*/
[154] Fix | Delete
typedef int (*sgx_enclave_user_handler_t)(long rdi, long rsi, long rdx,
[155] Fix | Delete
long rsp, long r8, long r9,
[156] Fix | Delete
struct sgx_enclave_run *run);
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* struct sgx_enclave_run - the execution context of __vdso_sgx_enter_enclave()
[160] Fix | Delete
* @tcs: TCS used to enter the enclave
[161] Fix | Delete
* @function: The last seen ENCLU function (EENTER, ERESUME or EEXIT)
[162] Fix | Delete
* @exception_vector: The interrupt vector of the exception
[163] Fix | Delete
* @exception_error_code: The exception error code pulled out of the stack
[164] Fix | Delete
* @exception_addr: The address that triggered the exception
[165] Fix | Delete
* @user_handler: User provided callback run on exception
[166] Fix | Delete
* @user_data: Data passed to the user handler
[167] Fix | Delete
* @reserved Reserved for future extensions
[168] Fix | Delete
*
[169] Fix | Delete
* If @user_handler is provided, the handler will be invoked on all return paths
[170] Fix | Delete
* of the normal flow. The user handler may transfer control, e.g. via a
[171] Fix | Delete
* longjmp() call or a C++ exception, without returning to
[172] Fix | Delete
* __vdso_sgx_enter_enclave().
[173] Fix | Delete
*/
[174] Fix | Delete
struct sgx_enclave_run {
[175] Fix | Delete
__u64 tcs;
[176] Fix | Delete
__u32 function;
[177] Fix | Delete
__u16 exception_vector;
[178] Fix | Delete
__u16 exception_error_code;
[179] Fix | Delete
__u64 exception_addr;
[180] Fix | Delete
__u64 user_handler;
[181] Fix | Delete
__u64 user_data;
[182] Fix | Delete
__u8 reserved[216];
[183] Fix | Delete
};
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* typedef vdso_sgx_enter_enclave_t - Prototype for __vdso_sgx_enter_enclave(),
[187] Fix | Delete
* a vDSO function to enter an SGX enclave.
[188] Fix | Delete
* @rdi: Pass-through value for RDI
[189] Fix | Delete
* @rsi: Pass-through value for RSI
[190] Fix | Delete
* @rdx: Pass-through value for RDX
[191] Fix | Delete
* @function: ENCLU function, must be EENTER or ERESUME
[192] Fix | Delete
* @r8: Pass-through value for R8
[193] Fix | Delete
* @r9: Pass-through value for R9
[194] Fix | Delete
* @run: struct sgx_enclave_run, must be non-NULL
[195] Fix | Delete
*
[196] Fix | Delete
* NOTE: __vdso_sgx_enter_enclave() does not ensure full compliance with the
[197] Fix | Delete
* x86-64 ABI, e.g. doesn't handle XSAVE state. Except for non-volatile
[198] Fix | Delete
* general purpose registers, EFLAGS.DF, and RSP alignment, preserving/setting
[199] Fix | Delete
* state in accordance with the x86-64 ABI is the responsibility of the enclave
[200] Fix | Delete
* and its runtime, i.e. __vdso_sgx_enter_enclave() cannot be called from C
[201] Fix | Delete
* code without careful consideration by both the enclave and its runtime.
[202] Fix | Delete
*
[203] Fix | Delete
* All general purpose registers except RAX, RBX and RCX are passed as-is to the
[204] Fix | Delete
* enclave. RAX, RBX and RCX are consumed by EENTER and ERESUME and are loaded
[205] Fix | Delete
* with @function, asynchronous exit pointer, and @run.tcs respectively.
[206] Fix | Delete
*
[207] Fix | Delete
* RBP and the stack are used to anchor __vdso_sgx_enter_enclave() to the
[208] Fix | Delete
* pre-enclave state, e.g. to retrieve @run.exception and @run.user_handler
[209] Fix | Delete
* after an enclave exit. All other registers are available for use by the
[210] Fix | Delete
* enclave and its runtime, e.g. an enclave can push additional data onto the
[211] Fix | Delete
* stack (and modify RSP) to pass information to the optional user handler (see
[212] Fix | Delete
* below).
[213] Fix | Delete
*
[214] Fix | Delete
* Most exceptions reported on ENCLU, including those that occur within the
[215] Fix | Delete
* enclave, are fixed up and reported synchronously instead of being delivered
[216] Fix | Delete
* via a standard signal. Debug Exceptions (#DB) and Breakpoints (#BP) are
[217] Fix | Delete
* never fixed up and are always delivered via standard signals. On synchrously
[218] Fix | Delete
* reported exceptions, -EFAULT is returned and details about the exception are
[219] Fix | Delete
* recorded in @run.exception, the optional sgx_enclave_exception struct.
[220] Fix | Delete
*
[221] Fix | Delete
* Return:
[222] Fix | Delete
* - 0: ENCLU function was successfully executed.
[223] Fix | Delete
* - -EINVAL: Invalid ENCL number (neither EENTER nor ERESUME).
[224] Fix | Delete
*/
[225] Fix | Delete
typedef int (*vdso_sgx_enter_enclave_t)(unsigned long rdi, unsigned long rsi,
[226] Fix | Delete
unsigned long rdx, unsigned int function,
[227] Fix | Delete
unsigned long r8, unsigned long r9,
[228] Fix | Delete
struct sgx_enclave_run *run);
[229] Fix | Delete
[230] Fix | Delete
#endif /* _ASM_X86_SGX_H */
[231] Fix | Delete
[232] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function