ia32-64/x86/eincvirtchild.html

251 lines
8.9 KiB
HTML
Raw Permalink Normal View History

2025-07-08 02:23:29 -03:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:x86="http://www.felixcloutier.com/x86"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><link rel="stylesheet" type="text/css" href="style.css"></link><title>EINCVIRTCHILD
— Increment VIRTCHILDCNT in SECS</title></head><body><header><nav><ul><li><a href='index.html'>Index</a></li><li>December 2023</li></ul></nav></header><h1>EINCVIRTCHILD
— Increment VIRTCHILDCNT in SECS</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32 bit Mode Support</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>EAX = 01H ENCLV[EINCVIRTCHILD]</td>
<td>IR</td>
<td>V/V</td>
<td>EAX[5]</td>
<td>This leaf function increments the SECS VIRTCHILDCNT field.</td></tr></table>
<h2 id="instruction-operand-encoding">Instruction Operand Encoding<a class="anchor" href="#instruction-operand-encoding">
</a></h2>
<table>
<tr>
<td>Op/En</td>
<td colspan="2">EAX</td>
<td>RBX</td>
<td>RCX</td></tr>
<tr>
<td>IR</td>
<td>EINCVIRTCHILD (In)</td>
<td>Return error code (Out)</td>
<td>Address of an enclave page (In)</td>
<td>Address of an SECS page (In)</td></tr></table>
<h3 id="description">Description<a class="anchor" href="#description">
</a></h3>
<p>This instruction increments the SECS VIRTCHILDCNT field. This instruction can only be executed when the current privilege level is 0.</p>
<p>The content of RCX is an effective address of an EPC page. The DS segment is used to create a linear address. Segment override is not supported.</p>
<h2 id="eincvirtchild-memory-parameter-semantics">EINCVIRTCHILD Memory Parameter Semantics<a class="anchor" href="#eincvirtchild-memory-parameter-semantics">
</a></h2>
<table>
<tr>
<td>EPCPAGE</td>
<td>SECS</td></tr>
<tr>
<td>Read/Write access permitted by Non Enclave</td>
<td>Read access permitted by Enclave</td></tr></table>
<p>The instruction faults if any of the following:</p>
<h2 id="eincvirtchild-faulting-conditions">EINCVIRTCHILD Faulting Conditions<a class="anchor" href="#eincvirtchild-faulting-conditions">
</a></h2>
<table>
<tr>
<td>A memory operand effective address is outside the DS segment limit (32b mode).</td>
<td>A page fault occurs in accessing memory operands.</td></tr>
<tr>
<td>DS segment is unusable (32b mode).</td>
<td>RBX does not refer to an enclave page (REG, TCS, TRIM, SECS).</td></tr>
<tr>
<td>A memory address is in a non-canonical form (64b mode).</td>
<td>RCX does not refer to an SECS page.</td></tr>
<tr>
<td>A memory operand is not properly aligned.</td>
<td>RBX does not refer to an enclave page associated with SECS referenced in RCX.</td></tr></table>
<h3 id="concurrency-restrictions">Concurrency Restrictions<a class="anchor" href="#concurrency-restrictions">
</a></h3>
<figure id="tbl-38-78">
<table>
<tr>
<th rowspan="2">Leaf</th>
<th rowspan="2">Parameter</th>
<th colspan="3">Base Concurrency Restrictions</th></tr>
<tr>
<th>Access</th>
<th>On Conflict</th>
<th>SGX_CONFLICT VM Exit Qualification</th></tr>
<tr>
<td rowspan="2">EINCVIRTCHILD</td>
<td>Target [DS:RBX]</td>
<td>Shared</td>
<td>SGX_EPC_PAGE_ CONFLICT</td>
<td></td></tr>
<tr>
<td>SECS [DS:RCX]</td>
<td>Concurrent</td>
<td></td>
<td></td></tr></table>
<figcaption><span class="not-imported">Table 38-78</span>. Base Concurrency Restrictions of EINCVIRTCHILD</figcaption></figure>
<figure id="tbl-38-79">
<table>
<tr>
<th rowspan="3">Leaf</th>
<th rowspan="3">Parameter</th>
<th colspan="6">Additional Concurrency Restrictions</th></tr>
<tr>
<th colspan="2">vs. EACCEPT, EACCEPTCOPY, EMODPE, EMODPR, EMODT</th>
<th colspan="2">vs. EADD, EEXTEND, EINIT</th>
<th colspan="2">vs. ETRACK, ETRACKC</th></tr>
<tr>
<th>Access</th>
<th>On Conflict</th>
<th>Access</th>
<th>On Conflict</th>
<th>Access</th>
<th>On Conflict</th></tr>
<tr>
<td rowspan="2">EINCVIRTCHILD</td>
<td>Target [DS:RBX]</td>
<td>Concurrent</td>
<td></td>
<td>Concurrent</td>
<td></td>
<td>Concurrent</td>
<td></td></tr>
<tr>
<td>SECS [DS:RCX]</td>
<td>Concurrent</td>
<td></td>
<td>Concurrent</td>
<td></td>
<td>Concurrent</td>
<td></td></tr></table>
<figcaption><span class="not-imported">Table 38-79</span>. Additional Concurrency Restrictions of EINCVIRTCHILD</figcaption></figure>
<h3 id="operation">Operation<a class="anchor" href="#operation">
</a></h3>
<h2 id="temp-variables-in-eincvirtchild-operational-flow">Temp Variables in EINCVIRTCHILD Operational Flow<a class="anchor" href="#temp-variables-in-eincvirtchild-operational-flow">
</a></h2>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Size (bits)</th>
<th>Description</th></tr>
<tr>
<td>TMP_SECS</td>
<td>Physical Address</td>
<td>64</td>
<td>Physical address of the SECS of the page being modified.</td></tr></table>
<h2 id="eincvirtchild-return-value-in-rax">EINCVIRTCHILD Return Value in RAX<a class="anchor" href="#eincvirtchild-return-value-in-rax">
</a></h2>
<table>
<tr>
<th>Error</th>
<th>Value</th>
<th>Description</th></tr>
<tr>
<td>No Error</td>
<td>0</td>
<td>EINCVIRTCHILD Successful.</td></tr>
<tr>
<td>SGX_EPC_PAGE_CONFLICT</td>
<td></td>
<td>Failure due to concurrent operation of another SGX instruction.</td></tr></table>
<p>(* check alignment of DS:RBX *)</p>
<p>IF (DS:RBX is not 4K aligned) THEN</p>
<p>#GP(0); FI;</p>
<p>(* check DS:RBX is an linear address of an EPC page *)</p>
<p>IF (DS:RBX does not resolve within an EPC) THEN</p>
<p>#PF(DS:RBX, PFEC.SGX); FI;</p>
<p>(* check DS:RCX is an linear address of an EPC page *)</p>
<p>IF (DS:RCX does not resolve within an EPC) THEN</p>
<p>#PF(DS:RCX, PFEC.SGX); FI;</p>
<p>(* Check the EPCPAGE for concurrency *)</p>
<p>IF (EPCPAGE is being modified) THEN</p>
<p>RFLAGS.ZF = 1;</p>
<p>RAX = SGX_EPC_PAGE_CONFLICT;</p>
<p>goto DONE;</p>
<p>FI;</p>
<p>(* check that the EPC page is valid *)</p>
<p>IF (EPCM(DS:RBX).VALID = 0) THEN</p>
<p>#PF(DS:RBX, PFEC.SGX); FI;</p>
<p>(* check that the EPC page has the correct type and that the back pointer matches the pointer passed as the pointer to parent *)</p>
<p>IF ((EPCM(DS:RBX).PAGE_TYPE = PT_REG) or</p>
<p>(EPCM(DS:RBX).PAGE_TYPE = PT_TCS) or</p>
<p>(EPCM(DS:RBX).PAGE_TYPE = PT_TRIM) or</p>
<p>(EPCM(DS:RBX).PAGE_TYPE = PT_SS_FIRST) or</p>
<p>(EPCM(DS:RBX).PAGE_TYPE = PT_SS_REST))</p>
<p>THEN</p>
<p>(* get the SECS of DS:RBX *)</p>
<p>TMP_SECS := Address of SECS for (DS:RBX);</p>
<p>ELSE IF (EPCM(DS:RBX).PAGE_TYPE = PT_SECS) THEN</p>
<p>(* get the physical address of DS:RBX *)</p>
<p>TMP_SECS := Physical_Address(DS:RBX);</p>
<p>ELSE</p>
<p>(* EINCVIRTCHILD called on page of incorrect type *)</p>
<p>#PF(DS:RBX, PFEC.SGX); FI;</p>
<p>IF (TMP_SECS ≠ Physical_Address(DS:RCX)) THEN</p>
<p>#GP(0); FI;</p>
<p>(* Atomically increment virtchild counter *)</p>
<p>Locked_Increment(SECS(TMP_SECS).VIRTCHILDCNT);</p>
<p>RFLAGS.ZF := 0;</p>
<p>RAX := 0;</p>
<p>DONE:</p>
<p>(* clear flags *)</p>
<p>RFLAGS.CF := 0;</p>
<p>RFLAGS.PF := 0;</p>
<p>RFLAGS.AF := 0;</p>
<p>RFLAGS.OF := 0;</p>
<p>RFLAGS.SF := 0;</p>
<h3 id="flags-affected">Flags Affected<a class="anchor" href="#flags-affected">
</a></h3>
<p>ZF is set if EINCVIRTCHILD fails due to concurrent operation with another SGX instruction; otherwise cleared.</p>
<h3 class="exceptions" id="protected-mode-exceptions">Protected Mode Exceptions<a class="anchor" href="#protected-mode-exceptions">
</a></h3>
<table>
<tr>
<td rowspan="4">#GP(0)</td>
<td>If a memory operand effective address is outside the DS segment limit.</td></tr>
<tr>
<td>If DS segment is unusable.</td></tr>
<tr>
<td>If a memory operand is not properly aligned.</td></tr>
<tr>
<td>RBX does not refer to an enclave page associated with SECS referenced in RCX.</td></tr>
<tr>
<td rowspan="3">#PF(error</td>
<td>code) If a page fault occurs in accessing memory operands.</td></tr>
<tr>
<td>If RBX does not refer to an enclave page (REG, TCS, TRIM, SECS).</td></tr>
<tr>
<td>If RCX does not refer to an SECS page.</td></tr></table>
<h3 class="exceptions" id="64-bit-mode-exceptions">64-Bit Mode Exceptions<a class="anchor" href="#64-bit-mode-exceptions">
</a></h3>
<table>
<tr>
<td rowspan="3">#GP(0)</td>
<td>If a memory address is in a non-canonical form.</td></tr>
<tr>
<td>If a memory operand is not properly aligned.</td></tr>
<tr>
<td>RBX does not refer to an enclave page associated with SECS referenced in RCX.</td></tr>
<tr>
<td rowspan="3">#PF(error</td>
<td>code) If a page fault occurs in accessing memory operands.</td></tr>
<tr>
<td>If RBX does not refer to an enclave page (REG, TCS, TRIM, SECS).</td></tr>
<tr>
<td>If RCX does not refer to an SECS page.</td></tr></table><footer><p>
This UNOFFICIAL, mechanically-separated, non-verified reference is provided for convenience, but it may be
inc<span style="opacity: 0.2">omp</span>lete or b<sub>r</sub>oke<sub>n</sub> in various obvious or non-obvious
ways. Refer to <a href="https://software.intel.com/en-us/download/intel-64-and-ia-32-architectures-sdm-combined-volumes-1-2a-2b-2c-2d-3a-3b-3c-3d-and-4">Intel® 64 and IA-32 Architectures Software Developers Manual</a> for anything serious.
</p></footer></body></html>