<?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 How to set/unset TCS.FLAGS.DBGOPTIN in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119660#M1508</link>
    <description>&lt;P&gt;In debug enclaves the TCS.FLAGS.DBGOPTIN flag can be either set to 0 or 1, referred to as Opt-in and Opt-out enclaves. My questions are:&lt;/P&gt;

&lt;P&gt;1. How can I check the state of this flag? For instance, is there a way to see from the binary whether it is an Opt-in or Opt-out enclave?&lt;/P&gt;

&lt;P&gt;2. How can I set this flag before the enclave is entered? Can I set this flag at compile time?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2017 14:03:54 GMT</pubDate>
    <dc:creator>Urs_M_</dc:creator>
    <dc:date>2017-03-15T14:03:54Z</dc:date>
    <item>
      <title>How to set/unset TCS.FLAGS.DBGOPTIN</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119660#M1508</link>
      <description>&lt;P&gt;In debug enclaves the TCS.FLAGS.DBGOPTIN flag can be either set to 0 or 1, referred to as Opt-in and Opt-out enclaves. My questions are:&lt;/P&gt;

&lt;P&gt;1. How can I check the state of this flag? For instance, is there a way to see from the binary whether it is an Opt-in or Opt-out enclave?&lt;/P&gt;

&lt;P&gt;2. How can I set this flag before the enclave is entered? Can I set this flag at compile time?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 14:03:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119660#M1508</guid>
      <dc:creator>Urs_M_</dc:creator>
      <dc:date>2017-03-15T14:03:54Z</dc:date>
    </item>
    <item>
      <title>Here's a reply relevant for</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119661#M1509</link>
      <description>&lt;P&gt;Here's a reply relevant for Linux:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://software.intel.com/en-us/forums/intel-software-guard-extensions-intel-sgx/topic/705410#comment-1893286"&gt;https://software.intel.com/en-us/forums/intel-software-guard-extensions-intel-sgx/topic/705410#comment-1893286&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;For Windows you can use VTune. I think that attaching a debugger to the application process may also work, not sure though.&lt;/P&gt;

&lt;P&gt;That's the how to enable part. The specific questions you asked:&lt;/P&gt;

&lt;P&gt;1) The binary itself will tell you if it is allowed to be debugged. The binary (on disk) won't tell you the current state of whether&amp;nbsp;each TCS&amp;nbsp;is being debugged. You'll need to read the enclave and extract that information.&lt;/P&gt;

&lt;P&gt;2) I think the easiest way is to profile it using VTune. I don't think you can set it to always be enabled at build-time.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 16:52:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119661#M1509</guid>
      <dc:creator>Francisco_C_Intel</dc:creator>
      <dc:date>2017-03-15T16:52:00Z</dc:date>
    </item>
    <item>
      <title>Hi Francisco,</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119662#M1510</link>
      <description>&lt;P&gt;Hi Francisco,&lt;/P&gt;

&lt;P&gt;thank you very much for your quick response, this helps.&lt;/P&gt;

&lt;P&gt;I understand that TCS.FLAGS.DBGOPTIN defaults to 0 (i.e. it is disabled). More specifically, if I simply launch a debug enclave the flag is set to 0. Is this true?&lt;/P&gt;

&lt;P&gt;*Edit: I think I have found the answer myself in the SDM Vol3, Section 43.1.2.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;The TCS.FLAGS.DBGOPTIN bit controls interactions of certain debug and profiling features with enclaves, including&lt;BR /&gt;
		code/data breakpoints, TF, RF, monitor trap flag, BTF, LBRs, BTM, BTS, Intel Processor Trace, and performance&lt;BR /&gt;
		monitoring. This bit is forced to zero when EPC pages are added via EADD. A debugger can set this bit via EDBGWR&lt;BR /&gt;
		to the TCS of a debug enclave.&lt;BR /&gt;
		An enclave entry through a TCS with the TCS.FLAGS.DBGOPTIN set to 0 is called an opt-out entry. Conversely, an&lt;BR /&gt;
		enclave entry through a TCS with TCS.FLAGS.DBGOPTIN set to 1 is called an opt-in entry.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I understand that the TCS.FLAGS.DBGOPTIN is 0 when a debug enclave is launched without any debugging software attached.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 09:42:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/How-to-set-unset-TCS-FLAGS-DBGOPTIN/m-p/1119662#M1510</guid>
      <dc:creator>Urs_M_</dc:creator>
      <dc:date>2017-03-16T09:42:06Z</dc:date>
    </item>
  </channel>
</rss>

