<?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 Relation between TCSNUM and Switchless num_tworkers in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Relation-between-TCSNUM-and-Switchless-num-tworkers/m-p/1559793#M6084</link>
    <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm asking this for clarification because I couldn't find any explicit mentions of the relations between the&amp;nbsp;num_tworkers (Trusted worker threads) and the TCSNUM configurations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is configured during Enclave compilation time, which is the number of threads created during the enclave initialization. Exceeding the parallel request to the Enclave than the TCSNUM will result in Error code: 0x1003 (The enclave is out of TCS).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;is passed to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sgx_create_enclave_ex&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;to create the enclave to support the switchless calls.&amp;nbsp;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;is the number of threads in the trusted worker pool. The number of parallel switchless calls to the Enclave exceeding the&amp;nbsp;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will result in switchless ECALL fallback to regular ECall with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Enclave switch.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So from my understanding, the Trusted Pool contains a portion of Trusted threads that are created/initialized during the Enclave init by using the TCSNUM from the `enclave.config` and the&amp;nbsp;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should be the max limit for the&amp;nbsp;&lt;STRONG&gt;num_tworkers.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Case 1: The&amp;nbsp;num_tworkers amount of Trusted threads will be assigned to the Trusted Pool to handle the switchless calls. The remaining Trusted threads will be available for the normal ECall and the fallback Ecall from the failed to serve switchless Ecall request.&lt;/P&gt;&lt;P&gt;Case 2: If the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;num_tworkers&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;equal&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;then there won't be any available Trusted threads to handle normal ECalls and fallback ECalls.&lt;/P&gt;&lt;P&gt;Case 3: Also, if the&amp;nbsp;&lt;STRONG&gt;num_tworkers&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;greater than&amp;nbsp;&lt;/STRONG&gt;the&amp;nbsp;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;, then enclave initialization should fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I try case 3, enclave initialization is successful with&amp;nbsp;&lt;STRONG&gt;num_tworkers &amp;gt; TCSNUM&lt;/STRONG&gt;&amp;nbsp;and no issues in the runtime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhere I'm missing the context. So, please explain the relation between TCSNUM and num_tworkers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Thanks,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Anand&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 09:13:30 GMT</pubDate>
    <dc:creator>Anandakumar</dc:creator>
    <dc:date>2024-01-04T09:13:30Z</dc:date>
    <item>
      <title>Relation between TCSNUM and Switchless num_tworkers</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Relation-between-TCSNUM-and-Switchless-num-tworkers/m-p/1559793#M6084</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm asking this for clarification because I couldn't find any explicit mentions of the relations between the&amp;nbsp;num_tworkers (Trusted worker threads) and the TCSNUM configurations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is configured during Enclave compilation time, which is the number of threads created during the enclave initialization. Exceeding the parallel request to the Enclave than the TCSNUM will result in Error code: 0x1003 (The enclave is out of TCS).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;is passed to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;sgx_create_enclave_ex&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;to create the enclave to support the switchless calls.&amp;nbsp;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;is the number of threads in the trusted worker pool. The number of parallel switchless calls to the Enclave exceeding the&amp;nbsp;&lt;STRONG&gt;num_tworkers&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will result in switchless ECALL fallback to regular ECall with the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Enclave switch.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So from my understanding, the Trusted Pool contains a portion of Trusted threads that are created/initialized during the Enclave init by using the TCSNUM from the `enclave.config` and the&amp;nbsp;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;should be the max limit for the&amp;nbsp;&lt;STRONG&gt;num_tworkers.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Case 1: The&amp;nbsp;num_tworkers amount of Trusted threads will be assigned to the Trusted Pool to handle the switchless calls. The remaining Trusted threads will be available for the normal ECall and the fallback Ecall from the failed to serve switchless Ecall request.&lt;/P&gt;&lt;P&gt;Case 2: If the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;num_tworkers&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;equal&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;then there won't be any available Trusted threads to handle normal ECalls and fallback ECalls.&lt;/P&gt;&lt;P&gt;Case 3: Also, if the&amp;nbsp;&lt;STRONG&gt;num_tworkers&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;greater than&amp;nbsp;&lt;/STRONG&gt;the&amp;nbsp;&lt;STRONG&gt;TCSNUM&lt;/STRONG&gt;, then enclave initialization should fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I try case 3, enclave initialization is successful with&amp;nbsp;&lt;STRONG&gt;num_tworkers &amp;gt; TCSNUM&lt;/STRONG&gt;&amp;nbsp;and no issues in the runtime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somewhere I'm missing the context. So, please explain the relation between TCSNUM and num_tworkers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Thanks,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Anand&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 09:13:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Relation-between-TCSNUM-and-Switchless-num-tworkers/m-p/1559793#M6084</guid>
      <dc:creator>Anandakumar</dc:creator>
      <dc:date>2024-01-04T09:13:30Z</dc:date>
    </item>
  </channel>
</rss>

