Article ID: 000090747 Content Type: Install & Setup Last Reviewed: 05/11/2022

Unable to Dynamically Allocate Memory Using a Processor That Supports Intel® Software Guard Extensions (Intel® SGX) SGX2

Environment

Linux*

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Summary

Install the legacy out-of-tree Intel® SGX Linux* driver to benefit from (Intel® SGX) SGX2 instructions.

Description
  1. Created an Intel® SGX application and used malloc to allocate memory
  2. Configured the HeapMinSize and HeapMaxSize in the enclave configuration file
  3. malloc returns nullptr after several allocations, before the memory allocation reaches HeapMaxSize
  4. Memory is not being allocated dynamically
Resolution

Only the legacy out-of-tree (OOT) Intel® SGX Linux* driver supports (Intel® SGX) SGX2.

 

Execute these commands to check which Intel® SGX driver is installed:

ls /dev/*sgx* #Should return /dev/isgx

lsmod | grep -i sgx #Should return: isgx

 

If the return values are not as above then the OOT driver is not installed and you probably have the Data Center Attestation Primitives (DCAP). Uninstall the DCAP driver before installing the OOT driver.

  1. Uninstall the current driver
    sudo /opt/intel/sgxdriver/uninstall.sh # The path to uninstall.sh may differ for your system.

    If the uninstall.sh script is missing, uninstall as follows:

    sudo service aesmd stop

    sudo rm -f $(find /lib/modules -name intel_sgx.ko)

    sudo /sbin/depmod

    sudo sed -i '/^intel_sgx$/d' /etc/modules

    sudo rm -f /etc/sysconfig/modules/intel_sgx.modules

    sudo rm -f /etc/modules-load.d/intel_sgx.conf

  2. Install the OOT driver using one of two methods
    • Download and install the latest driver binary, similar to sgx_linux_x64_driver_2.11.054c9c4c.bin, from the Linux distribution folder

      chmod 777 sgx_linux_x64_driver_2.11.054c9c4c.bin

      sudo ./sgx_linux_x64_driver_2.11.054c9c4c.bin

    • Build from source