<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re:malloc(4096) failed in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382940#M5271</link>
    <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It seems that you have installed the DCAP driver so are not taking advantage of SGX 2 features.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you were running the OOT driver you would see output:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;/dev/isgx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;$ lsmod | grep -i sgx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;isgx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;53248&amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you want to take advantage of SGX 2 EDMM features then you must uninstall the current driver and install the OOT driver.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;U&gt;First uninstall the current driver&lt;/U&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo /opt/intel/sgxdriver/uninstall.sh&amp;nbsp;# The path to&amp;nbsp;uninstall.sh&amp;nbsp;may differ for your system.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If the uninstall.sh script is missing, uninstall as follows:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo service aesmd stop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo rm -f $(find /lib/modules -name intel_sgx.ko)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo /sbin/depmod&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo sed -i '/^intel_sgx$/d' /etc/modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo rm -f /etc/sysconfig/modules/intel_sgx.modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo rm -f /etc/modules-load.d/intel_sgx.conf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;2. Install the OOT driver&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Install the binary:&amp;nbsp;&lt;A href="https://download.01.org/intel-sgx/sgx-linux/2.16/distro/ubuntu18.04-server/sgx_linux_x64_driver_2.11.054c9c4c.bin" rel="noopener noreferrer" target="_blank" style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;chmod 777 sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;sudo ./sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;build from source:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/intel/linux-sgx-driver" rel="noopener noreferrer" target="_blank"&gt;https://github.com/intel/linux-sgx-driver&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Jesus G.&lt;/P&gt;&lt;P&gt;Intel Customer Support&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 09 May 2022 18:31:06 GMT</pubDate>
    <dc:creator>JesusG_Intel</dc:creator>
    <dc:date>2022-05-09T18:31:06Z</dc:date>
    <item>
      <title>malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380372#M5224</link>
      <description>&lt;P&gt;enclave configuration:&lt;/P&gt;
&lt;P&gt;&amp;lt;HeapMinSize&amp;gt;0x8000&amp;lt;/HeapMinSize&amp;gt;&lt;BR /&gt;&amp;lt;HeapInitSize&amp;gt;0x8000&amp;lt;/HeapInitSize&amp;gt;&lt;BR /&gt;&amp;lt;HeapMaxSize&amp;gt;0x50000000&amp;lt;/HeapMaxSize&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;after I ran malloc(4096) several times, it failed to allocate a new memory location (returned a nullptr).&lt;/P&gt;
&lt;P&gt;I'm using an SGX2-enabled cloud server (Alibaba cloud ECS g7t) which provides up to 4 GiB for&amp;nbsp; enclave. Based on my understanding, this malloc will trigger the Enclave Dynamic Memory Management (EDMM) mechanism and assign a new page to the enclave after which this operation can be redone successfully.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone can help me out? A code example of how to do SGX2-only EDMM would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2022 11:01:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380372#M5224</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-04-28T11:01:43Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380484#M5226</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What OS are you running on? Can you please send over your code including the enclave configuration file and the edl file.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Sahira&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2022 17:33:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380484#M5226</guid>
      <dc:creator>Sahira_Intel</dc:creator>
      <dc:date>2022-04-28T17:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380591#M5228</link>
      <description>&lt;P&gt;Hi Sahira,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm running on ubuntu 18.04 kernel version 4.15.0-175.&lt;/P&gt;
&lt;P&gt;Here's my enclave config file:&lt;/P&gt;
&lt;LI-CODE lang="none"&gt;&amp;lt;EnclaveConfiguration&amp;gt;
    &amp;lt;ProdID&amp;gt;0&amp;lt;/ProdID&amp;gt;
    &amp;lt;ISVSVN&amp;gt;0&amp;lt;/ISVSVN&amp;gt;
    &amp;lt;StackMinSize&amp;gt;0x2000&amp;lt;/StackMinSize&amp;gt;
    &amp;lt;StackMaxSize&amp;gt;0x4000&amp;lt;/StackMaxSize&amp;gt;
    &amp;lt;HeapMinSize&amp;gt;0x8000&amp;lt;/HeapMinSize&amp;gt;
    &amp;lt;HeapInitSize&amp;gt;0x8000&amp;lt;/HeapInitSize&amp;gt;
    &amp;lt;HeapMaxSize&amp;gt;0x50000000&amp;lt;/HeapMaxSize&amp;gt;
    &amp;lt;TCSNum&amp;gt;1&amp;lt;/TCSNum&amp;gt;
    &amp;lt;TCSMaxNum&amp;gt;10&amp;lt;/TCSMaxNum&amp;gt;
    &amp;lt;TCSMinPool&amp;gt;1&amp;lt;/TCSMinPool&amp;gt;
    &amp;lt;TCSPolicy&amp;gt;1&amp;lt;/TCSPolicy&amp;gt;
    &amp;lt;DisableDebug&amp;gt;0&amp;lt;/DisableDebug&amp;gt;
    &amp;lt;MiscSelect&amp;gt;0&amp;lt;/MiscSelect&amp;gt;
    &amp;lt;MiscMask&amp;gt;0xFFFFFFFF&amp;lt;/MiscMask&amp;gt;
    &amp;lt;ReservedMemInitSize&amp;gt;0x800000&amp;lt;/ReservedMemInitSize&amp;gt;
    &amp;lt;ReservedMemMinSize&amp;gt;0x4000&amp;lt;/ReservedMemMinSize&amp;gt;
    &amp;lt;ReservedMemMaxSize&amp;gt;0x50000000&amp;lt;/ReservedMemMaxSize&amp;gt;
&amp;lt;/EnclaveConfiguration&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;and here's my edl file:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;enclave {

    trusted {
        public void ecall_hello_from_enclave([out, size=len] char* buf, size_t len, [in, size=8] int *allocBytes);
    };

};&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;in which&amp;nbsp;&lt;EM&gt;buf&amp;nbsp;&lt;/EM&gt;is the output buffer for messages from the enclave and &lt;EM&gt;allocBytes&lt;/EM&gt; is the number of bytes to be allocated (currently not used).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my application code, &lt;I&gt;ecall_hello_from_enclave &lt;/I&gt;function is called inside a loop &amp;amp; timed along side with ecall overhead&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;    int cnt = 1;
    allocNum = 4096;
    while (cnt &amp;lt;= 200) {
        auto beginT = std::chrono::high_resolution_clock::now();
        ecall_hello_from_enclave(global_eid, buffer, max_buf_len, &amp;amp;allocNum);
        auto endT = std::chrono::high_resolution_clock::now();
        auto duration = std::chrono::duration_cast&amp;lt;std::chrono::microseconds&amp;gt;(endT - beginT);
        ++cnt;
        printf("\n\n\n Current Iteration: %d, Current Time: %s Enclave Output: %s\n Time Used: %.3f microseconds\n",
               cnt,
               asctime(get_time()), buffer,
               ((float) duration.count()));
        fflush(stdout);
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;enclave code:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;void ecall_hello_from_enclave(char *buf, size_t len, int *heapSize) {
    size_t size = len;
    char *tmpPtr = (char *) malloc(4096);
    char strBuf[100];
    if (tmpPtr == nullptr) {
        size = snprintf(strBuf, 100, "Malloc failed!");
    }
    else {
        size = snprintf(strBuf, 100, "Executed 4kBytes malloc operations");
    }
    memcpy(buf, strBuf, size - 1);
    buf[size - 1] = '\0';
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this clarifies my problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards,&lt;/P&gt;
&lt;P&gt;Decoy&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 01:37:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380591#M5228</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-04-29T01:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380601#M5229</link>
      <description>&lt;P&gt;Just changed my configuration of HeapMinSize, it comes to my attention that the initialized heap size after enclave initialization is the amount of memory set by&amp;nbsp;&lt;EM&gt;HeapInitSize&lt;/EM&gt; instead of &lt;EM&gt;HeapMinSize&lt;/EM&gt;, which indicates that I am actually using SGX1 instead of SGX2 based on the developer's reference:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;When an enclave created with the Linux* 2.0 SDK is executing on an Intel®&lt;BR /&gt;SGX 2.0 platform that is running the Intel® SGX 2.0 PSW, HeapMinSize is the&lt;BR /&gt;amount of heap available once the enclave completes initialization.&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;When an enclave created with the Linux* 2.0 SDK is executing on an older&lt;BR /&gt;Intel SGX platform or a platform running a previous version of PSW, the values&lt;BR /&gt;are interpreted differently. In this case HeapInitSize is the only relevant&lt;BR /&gt;field and it indicates the total amount of heap available to an enclave.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Am I using the wrong version of SGX? If so, how to install SGX 2.0 properly?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2022 02:54:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1380601#M5229</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-04-29T02:54:41Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381210#M5238</link>
      <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We have a couple of articles that will help you. If your system supports SGX 2, then you just need to configure the enclave configuration file correctly and use malloc/free as you normally would.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://www.intel.com/content/www/us/en/support/articles/000058764/software/intel-security-products.html" rel="noopener noreferrer" target="_blank"&gt;Which Platforms Support Intel® Software Guard Extensions (Intel® SGX) SGX2?&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;B style="font-size: 10pt;"&gt;Open&lt;/B&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;a terminal and&amp;nbsp;run:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;$ cpuid | grep -i sgx&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;B style="font-size: 10pt;"&gt;Look&lt;/B&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;for output:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;;"&gt;SGX2 supported = True&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://www.intel.com/content/www/us/en/support/articles/000088648/software/intel-security-products.html" rel="noopener noreferrer" target="_blank"&gt;How Do I Create an Enclave with Intel® Software Guard Extensions 2 (Intel®&amp;nbsp;SGX 2) Features to Allocate Memory Dynamically?&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Jesus G.&lt;/P&gt;&lt;P&gt;Intel Customer Support&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 May 2022 16:16:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381210#M5238</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-02T16:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381213#M5240</link>
      <description>&lt;P&gt;I'm pretty sure about the fact that my system supports SGX2 and I have double-checked with your prementioned method. Also, the enclave config file should be correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My concern is, is there any restriction on sgx-driver &amp;amp; sgx-sdk to make use of SGX2 features? Any specific branch to use when trying to build from source?&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2022 16:25:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381213#M5240</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-05-02T16:25:52Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381224#M5241</link>
      <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;There is no restriction on the SGX driver or SDK for SGX2. If your processor supports SGX2, then the SGX software will automatically detect it and benefit from the dynamic memory management functions.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Jesus G.&lt;/P&gt;&lt;P&gt;Intel Customer Support&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 May 2022 16:51:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381224#M5241</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-02T16:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381428#M5248</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I verify whether it's using dynamic management functions or not?&lt;/P&gt;
&lt;P&gt;I've tried to compare the enclave initialize time given different HeapMinSize but it showed no difference in loading time between the enclave with only 4kb HeapMinSize and the enclave with 3GB HeapMinSize (HeapMaxSize both set to 4GB).&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 10:38:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381428#M5248</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-05-03T10:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381590#M5253</link>
      <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was able to run your code successfully after I removed the &lt;SPAN&gt;HeapInitSize&lt;/SPAN&gt; from the enclave config file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you set HeapInitSize, then you can only use that amount of memory, which is 0x8000 in your case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, to use SGX 2 dynamic memory allocation, set only &lt;SPAN&gt;HeapMinSize&lt;/SPAN&gt; and &lt;SPAN&gt;HeapMaxSize&lt;/SPAN&gt;, and remove &lt;SPAN&gt;HeapInitSize&lt;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JesusG_Intel_0-1651618453875.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/29073i858A87ABF8EA818B/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="JesusG_Intel_0-1651618453875.png" alt="JesusG_Intel_0-1651618453875.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sincerely,&lt;/P&gt;
&lt;P&gt;Jesus G.&lt;/P&gt;
&lt;P&gt;Intel Customer Support&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2022 22:54:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381590#M5253</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-03T22:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381616#M5255</link>
      <description>&lt;P&gt;Hi Jesus&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for being so helpful! It indeed solved the question.&lt;/P&gt;
&lt;P&gt;But there's one thing still not clear to me:&amp;nbsp; how can I check whether the memory allocation is dynamic or static, i.e. is the enclave initialized with HeapMaxSize or HeapMinSize? As I don't know how to check the size of heap memory available right after enclave initialization (sgx_emmt only shows peak memory usage), I'm thinking about verifying it by measuring the enclave initialization time.&lt;/P&gt;
&lt;P&gt;Based on my understanding,&amp;nbsp; in SGX2, the enclave heap should be initialized with HeapMinSize memory at first and then the memory manager will dynamically allocate pages into this enclave as heap as requested during runtime, which implies that an enclave with EDMM should spend less time on enclave initialization since only HeapMinSize is required to be allocated.&lt;/P&gt;
&lt;P&gt;However, I tried several settings with only HeapMinSize being different, but the time cost for sgx_create_enclave is roughly the same.&amp;nbsp; To be more specific, with the HeapMaxSize setting at 3GB all the time, the enclave initialization time for HeapMinSize at 4kb is ~6.1 seconds, and the one for HeapMinSize at 2GB or 64MB or 500MB is roughly around that also. Is this a desirable behavior of an enclave with EDMM?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking forward to hearing from you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Decoy&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 01:55:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1381616#M5255</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-05-04T01:55:33Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382364#M5261</link>
      <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I apologize that I gave you wrong information earlier. There is a restriction on the SGX driver SGX 2 support. Only the old out-of-tree driver supports SGX 2. You can get this driver 2 ways:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Install the binary: &lt;A href="https://download.01.org/intel-sgx/sgx-linux/2.16/distro/ubuntu18.04-server/sgx_linux_x64_driver_2.11.054c9c4c.bin" rel="noopener noreferrer" target="_blank" style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;chmod 777 sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;sudo ./sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;build from source: &lt;/SPAN&gt;&lt;A href="https://github.com/intel/linux-sgx-driver" target="_blank"&gt;https://github.com/intel/linux-sgx-driver&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please send us the output from &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;$ ls /dev/*sgx*&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Jesus G.&lt;/P&gt;&lt;P&gt;Intel Customer Support&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 06 May 2022 16:54:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382364#M5261</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-06T16:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382499#M5265</link>
      <description>&lt;P&gt;&lt;BR /&gt;[root@Server ~]# ls /dev/*sgx*&lt;BR /&gt;/dev/sgx_enclave /dev/sgx_provision&lt;/P&gt;
&lt;P&gt;/dev/sgx:&lt;BR /&gt;enclave provision&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2022 02:19:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382499#M5265</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-05-07T02:19:28Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382940#M5271</link>
      <description>&lt;P&gt;Hello 0MagicDecoy0,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;It seems that you have installed the DCAP driver so are not taking advantage of SGX 2 features.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you were running the OOT driver you would see output:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;/dev/isgx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;and &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;$ lsmod | grep -i sgx&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;isgx&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;53248&amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;If you want to take advantage of SGX 2 EDMM features then you must uninstall the current driver and install the OOT driver.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;U&gt;First uninstall the current driver&lt;/U&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo /opt/intel/sgxdriver/uninstall.sh&amp;nbsp;# The path to&amp;nbsp;uninstall.sh&amp;nbsp;may differ for your system.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If the uninstall.sh script is missing, uninstall as follows:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo service aesmd stop&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo rm -f $(find /lib/modules -name intel_sgx.ko)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt;sudo /sbin/depmod&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo sed -i '/^intel_sgx$/d' /etc/modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo rm -f /etc/sysconfig/modules/intel_sgx.modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier;"&gt; sudo rm -f /etc/modules-load.d/intel_sgx.conf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;2. Install the OOT driver&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Install the binary:&amp;nbsp;&lt;A href="https://download.01.org/intel-sgx/sgx-linux/2.16/distro/ubuntu18.04-server/sgx_linux_x64_driver_2.11.054c9c4c.bin" rel="noopener noreferrer" target="_blank" style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;chmod 777 sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="ql-indent-1"&gt;&lt;SPAN style="font-family: courier;"&gt;sudo ./sgx_linux_x64_driver_2.11.054c9c4c.bin&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="font-family: IntelClear-Light, tahoma, Helvetica, helvetica, Arial, sans-serif;"&gt;build from source:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/intel/linux-sgx-driver" rel="noopener noreferrer" target="_blank"&gt;https://github.com/intel/linux-sgx-driver&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;Jesus G.&lt;/P&gt;&lt;P&gt;Intel Customer Support&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 May 2022 18:31:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1382940#M5271</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-09T18:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1383018#M5277</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;It is working perfectly now!&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 00:13:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1383018#M5277</guid>
      <dc:creator>0MagicDecoy0</dc:creator>
      <dc:date>2022-05-10T00:13:53Z</dc:date>
    </item>
    <item>
      <title>Re:malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1383274#M5280</link>
      <description>&lt;P&gt;&lt;B&gt;This thread has been marked as answered and Intel will no longer monitor this thread. If you want a response from Intel in a follow-up question, please open a new thread.&lt;/B&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 10 May 2022 20:05:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1383274#M5280</guid>
      <dc:creator>JesusG_Intel</dc:creator>
      <dc:date>2022-05-10T20:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1403076#M5405</link>
      <description>&lt;P&gt;I meet the similar questions.&lt;/P&gt;
&lt;P&gt;According to the solutions, I reinstalled sgx driver but &lt;SPAN&gt;the enclave initialization time is still detetmined by HeapMaxSize.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The sgx driver is "isgx"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;lsmod | grep -i sgx&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;isgx 57344 0&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;Encalve configuration:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;HeapMinSize&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;0x10000&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;/HeapMinSize&amp;gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;HeapMaxSize&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;0x40000000&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;/HeapMaxSize&amp;gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;The output of make:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;BR /&gt;tcs_num 10, tcs_max_num 10, tcs_min_pool 1&lt;BR /&gt;The required memory is 1076772864B.&lt;BR /&gt;The required memory is 0x402e4000, 1051536 KB.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Succeed.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;I'm using an SGX2-enabled machine "Intel(R) Xeon(R) Platinum 8380 CPU @ 2.30GHz".&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;cpuid | grep -i sgx&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; SGX: Software Guard Extensions supported = true&lt;BR /&gt;SGX_LC: SGX launch config supported = true&lt;BR /&gt;Software Guard Extensions (SGX) capability (0x12/0):&lt;BR /&gt;SGX1 supported = true&lt;BR /&gt;SGX2 supported = true&lt;BR /&gt;SGX ENCLV E*VIRTCHILD, ESETCONTEXT = false&lt;BR /&gt;SGX ENCLS ETRACKC, ERDINFO, ELDBC, ELDUC = false&lt;BR /&gt;SGX attributes (0x12/1):&lt;BR /&gt;SGX EPC enumeration (0x12/n):&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Anyone can help me out?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 12:17:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1403076#M5405</guid>
      <dc:creator>yunkaibai</dc:creator>
      <dc:date>2022-07-25T12:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: malloc(4096) failed</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1403184#M5407</link>
      <description>&lt;P&gt;Besides, the kernel headers is 5.15.0-43-generic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;uname -r&lt;/P&gt;
&lt;P&gt;5.15.0-43-generic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed that there are three different drives:&amp;nbsp;In-kernel Driver, DCAP driver, OOT driver.&lt;/P&gt;
&lt;P&gt;But The platform must be configured with only one of these drivers.&lt;/P&gt;
&lt;P&gt;From kernel 5.11, the kernel supports in-kernel SGX driver.&lt;/P&gt;
&lt;P&gt;So, I uninstalled the&amp;nbsp;OOT driver(/dev/isgx).&lt;/P&gt;
&lt;P&gt;Do I need to reinstall the in-kernel driver and how to reinstall it?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jul 2022 16:48:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/malloc-4096-failed/m-p/1403184#M5407</guid>
      <dc:creator>yunkaibai</dc:creator>
      <dc:date>2022-07-25T16:48:23Z</dc:date>
    </item>
  </channel>
</rss>

