Intel(R) SGX is a set of CPU instructions that can be used by applications toset aside private regions of code and data. The code outside the enclave isdisallowed to access the memory inside the enclave by the CPU access control.In a way you can think that SGX provides inverted sandbox. It protects theapplication from a malicious host.

There is a new hardware unit in the processor called Memory Encryption Engine(MEE) starting from the Skylake microacrhitecture. BIOS can define one or manyMEE regions that can hold enclave data by configuring them with PRMRRregisters.

The MEE automatically encrypts the data leaving the processor package to theMEE regions. The data is encrypted using a random key whose life-time isexactly one power cycle.

'master' branch contains the same patches with the following differences:

* top-level patch modifies the ioctl API to be SDK compatible* does not use flexible launch control but instead relies on SDK provided Intel launch enclave.

v5:* Described IPC between the Launch Enclave and kernel in the commit messages.* Fixed all relevant checkpatch.pl issues that I have forgot fix in earlier versions except those that exist in the imported TinyCrypt code.* Fixed spelling mistakes in the documentation.* Forgot to check the return value of sgx_drv_subsys_init().* Encapsulated properly page cache init and teardown.* Collect epc pages to a temp list in sgx_add_epc_bank* Removed SGX_ENCLAVE_INIT_ARCH constant.

v4:* Tied life-cycle of the sgx_le_proxy process to /dev/sgx.* Removed __exit annotation from sgx_drv_subsys_exit().* Fixed a leak of a backing page in sgx_process_add_page_req() in the case when vm_insert_pfn() fails.* Removed unused symbol exports for sgx_page_cache.c.* Updated sgx_alloc_page() to require encl parameter and documented the behavior (Sean Christopherson).* Refactored a more lean API for sgx_encl_find() and documented the behavior.* Moved #PF handler to sgx_fault.c.* Replaced subsys_system_register() with plain bus_register().* Retry EINIT 2nd time only if MSRs are not locked.

v3:* Check that FEATURE_CONTROL_LOCKED and FEATURE_CONTROL_SGX_ENABLE are set.* Return -ERESTARTSYS in __sgx_encl_add_page() when sgx_alloc_page() fails.* Use unused bits in epc_page->pa to store the bank number.* Removed #ifdef for WQ_NONREENTRANT.* If mmu_notifier_register() fails with -EINTR, return -ERESTARTSYS.* Added --remove-section=.got.plt to objcopy flags in order to prevent a dummy .got.plt, which will cause an inconsistent size for the LE.* Documented sgx_encl_* functions.* Added remark about AES implementation used inside the LE.* Removed redundant sgx_sys_exit() from le/main.c.* Fixed struct sgx_secinfo alignment from 128 to 64 bytes.* Validate miscselect in sgx_encl_create().* Fixed SSA frame size calculation to take the misc region into account.* Implemented consistent exception handling to __encls() and __encls_ret().* Implemented a proper device model in order to allow sysfs attributes and in-kernel API.* Cleaned up various "find enclave" implementations to the unified sgx_encl_find().* Validate that vm_pgoff is zero.* Discard backing pages with shmem_truncate_range() after EADD.* Added missing EEXTEND operations to LE signing and launch.* Fixed SSA size for GPRS region from 168 to 184 bytes.* Fixed the checks for TCS flags. Now DBGOPTIN is allowed.* Check that TCS addresses are in ELRANGE and not just page aligned.* Require kernel to be compiled with X64_64 and CPU_SUP_INTEL.* Fixed an incorrect value for SGX_ATTR_DEBUG from 0x01 to 0x02.

v2:* get_rand_uint32() changed the value of the pointer instead of value where it is pointing at.* Launch enclave incorrectly used sigstruct attributes-field instead of enclave attributes-field.* Removed unused struct sgx_add_page_req from sgx_ioctl.c* Removed unused sgx_has_sgx2.* Updated arch/x86/include/asm/sgx.h so that it provides stub implementations when sgx in not enabled.* Removed cruft rdmsr-calls from sgx_set_pubkeyhash_msrs().* return -ENOMEM in sgx_alloc_page() when VA pages consume too much space* removed unused global sgx_nr_pids* moved sgx_encl_release to sgx_encl.c* return -ERESTARTSYS instead of -EINTR in sgx_encl_init()