<?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: Dynamic Memory Allocation in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495331#M5794</link>
    <description>&lt;P&gt;Indeed, the newer kernel fixed the problem! Using kernel v6.3, I'm now able to dynamically allocate memory in the enclave.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jun 2023 15:44:35 GMT</pubDate>
    <dc:creator>morbitzer</dc:creator>
    <dc:date>2023-06-13T15:44:35Z</dc:date>
    <item>
      <title>Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1491576#M5755</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;I'm trying to create an SGX enclave that makes use of the EMM feature. Unfortunately, I haven't been able to find an example, so I am already struggling with creating the correct configuration file.&lt;/P&gt;&lt;P&gt;To my understand, I need to define a UserRegionSize to be able to allocate memory. According to the developer reference, I therefore added this to my config:&lt;/P&gt;&lt;LI-CODE lang="xml"&gt;&amp;lt;UserRegionSize&amp;gt;0x900000&amp;lt;/UserRegionSize&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Furthermore, the developer reference states that when a UserRegionSize is set, "MiscSelect[0] and MiscMask[0] must be set to 1 and the enclave needs to be loaded on SGX 2.0 platform."&lt;/P&gt;&lt;P&gt;Setting MiscMask[0] should be the standard, as the default value for MiscMask is 0xFFFFFFFF.&lt;/P&gt;&lt;P&gt;However, the default value for MiscSelect is 0, so I need a different value there. I tried 0xFFFFFFFF and 1, but for both,&amp;nbsp;sgx_create_enclave returns SGX_ERROR_INVALID_METADATA. So my random guesses didn't get me much further. The reference says that MiscSelect defines "The desired Extended SSA frame feature.", but I was not able to find any further information on what that is and which values I could use there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please point me to a working config file or maybe even an example enclave that uses EMM features?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm running my tests on a NUC with support for SGX2:&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;cpuid | grep -i sgx
      SGX: Software Guard Extensions supported = true                                                                                  
      SGX_LC: SGX launch config supported      = true                                                                                  
   Software Guard Extensions (SGX) capability (0x12/0):                                                                                
      SGX1 supported                           = true                                                                                  
      SGX2 supported                           = true  
      SGX ENCLV E*VIRTCHILD, ESETCONTEXT       = false
      SGX ENCLS ETRACKC, ERDINFO, ELDBC, ELDUC = false                                                                                 
   SGX attributes: ECREATE SECS.ATTRIBUTES (0x12/1):   
   SGX Enclave Page Cache (EPC) enumeration (0x12/0x2):
   SGX Enclave Page Cache (EPC) enumeration (0x12/0x3):    &lt;/LI-CODE&gt;&lt;P&gt;My current config file is the one from the SGX SampleCode: &lt;A href="https://github.com/intel/linux-sgx/blob/master/SampleCode/SampleEnclave/Enclave/config.05.xml" target="_blank"&gt;https://github.com/intel/linux-sgx/blob/master/SampleCode/SampleEnclave/Enclave/config.05.xml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 15:40:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1491576#M5755</guid>
      <dc:creator>morbitzer</dc:creator>
      <dc:date>2023-05-31T15:40:13Z</dc:date>
    </item>
    <item>
      <title>Re:Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1491833#M5762</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;Hi Morbitzer,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;Thanks for reaching out.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;We are checking this with our developer team and it may take some time. We will update you with the information once available.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;Aznie&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jun 2023 07:42:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1491833#M5762</guid>
      <dc:creator>Aznie_Intel</dc:creator>
      <dc:date>2023-06-01T07:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493487#M5778</link>
      <description>&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;Hi Morbitzer,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;" lang="en-US"&gt;Thanks for your patience.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;" lang="en-US"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;The SGX_ERROR_INVALID_METADATA&amp;nbsp;error is referring to the metadata embedded within the enclave image being corrupt or missing.&amp;nbsp;&lt;SPAN&gt;We are unable to replicate the issue from our end. &lt;/SPAN&gt;&lt;SPAN&gt;Could you share your config file for us to further investigate from our end? Which Linux SGX version you are using?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;&lt;CITE style="margin: 0in; font-family: Calibri; font-size: 12.0pt; color: #595959;"&gt;&amp;nbsp;&lt;/CITE&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;In case you are using the dynamic features on SGX2 platform, we would suggest to set MiscMask[0]=0 and MiscSelect[0]=1 in your use cases.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;Aznie&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 01:17:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493487#M5778</guid>
      <dc:creator>Aznie_Intel</dc:creator>
      <dc:date>2023-06-07T01:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493609#M5785</link>
      <description>&lt;P&gt;Hi Aznie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a minimal example by taking the &lt;A href="https://github.com/intel/linux-sgx/tree/master/SampleCode/SampleEnclave" target="_self"&gt;SampleEnclave&lt;/A&gt; and replacing the &lt;A href="https://github.com/intel/linux-sgx/blob/master/SampleCode/SampleEnclave/Enclave/Enclave.config.xml" target="_self"&gt;Enclave.config.xml&lt;/A&gt; with &lt;A href="https://github.com/intel/linux-sgx/blob/master/SampleCode/SampleEnclave/Enclave/config.05.xml" target="_self"&gt;config.05.xml&amp;nbsp;&lt;/A&gt;According to my understanding, config.05.xml should support EMM. I attached a .zip containing this project, but as said, it's just an example from Intel with a different config provided with the example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The config sets MiscMask and MiscSelect as follows:&lt;/P&gt;&lt;LI-CODE lang="xml"&gt;  &amp;lt;MiscSelect&amp;gt;1&amp;lt;/MiscSelect&amp;gt;
  &amp;lt;MiscMask&amp;gt;0xFFFFFFFF&amp;lt;/MiscMask&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;Is there also a way to specifically set the 0-th bit of each parameter?&lt;/P&gt;&lt;P&gt;When I execute "make" and "./app" in this project, I receive the following output:&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;Error: Invalid enclave metadata.
Enter a character before exit ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Does this work on your systems? If so, at least I would know that this is a problem with the system, not with the project.&lt;/P&gt;&lt;P&gt;On my system, I run ubuntu 22.04 with a 5.15.0-69-generic kernel, so using the in-kernel SGX driver. As SDK, I installed &lt;A href="https://download.01.org/intel-sgx/latest/linux-latest/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.19.100.3.bin" target="_self"&gt;version 2.19.100.3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mathias&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 09:34:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493609#M5785</guid>
      <dc:creator>morbitzer</dc:creator>
      <dc:date>2023-06-07T09:34:24Z</dc:date>
    </item>
    <item>
      <title>Re:Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493875#M5787</link>
      <description>&lt;P&gt;Hi Mathias,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for sharing the file. We are checking on this and will get back to you soon.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aznie&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Jun 2023 02:28:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1493875#M5787</guid>
      <dc:creator>Aznie_Intel</dc:creator>
      <dc:date>2023-06-08T02:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495123#M5792</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hi Morbitzer,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you again for your patience.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Update from our engineering team, SGX EDMM support was not added into the Linux Kernel until v6.0. I would advise you to upgrade to v6.0 kernel and try it again.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here is the reference for EDMM, "SGX EDMM support (v6.0 or later)" at&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-size: 14px;" href="https://github.com/intel/sgx-emm" target="_blank" rel="noopener noreferrer"&gt;https://github.com/intel/sgx-emm&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For EDMM support, you need to&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-size: 14px;" href="https://github.com/intel/sgx-emm/tree/main#build-and-install-kernel-with-edmm-support" target="_blank" rel="noopener noreferrer"&gt;Build and install kernel with EDMM support&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;by following the instruction in&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-size: 14px;" href="https://wiki.ubuntu.com/KernelTeam/GitKernelBuild" target="_blank" rel="noopener noreferrer"&gt;GitKernelBuild&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Aznie&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 06:20:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495123#M5792</guid>
      <dc:creator>Aznie_Intel</dc:creator>
      <dc:date>2023-06-13T06:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495331#M5794</link>
      <description>&lt;P&gt;Indeed, the newer kernel fixed the problem! Using kernel v6.3, I'm now able to dynamically allocate memory in the enclave.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 15:44:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495331#M5794</guid>
      <dc:creator>morbitzer</dc:creator>
      <dc:date>2023-06-13T15:44:35Z</dc:date>
    </item>
    <item>
      <title>Re:Dynamic Memory Allocation</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495562#M5795</link>
      <description>&lt;P&gt;Hi Morbitzer,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This thread will no longer be monitored since this issue has been resolved.&amp;nbsp;If you need any additional information from Intel, please submit a new question.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Aznie&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jun 2023 04:11:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Dynamic-Memory-Allocation/m-p/1495562#M5795</guid>
      <dc:creator>Aznie_Intel</dc:creator>
      <dc:date>2023-06-14T04:11:07Z</dc:date>
    </item>
  </channel>
</rss>

