<?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: Ring Architecture in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901496#M11110</link>
    <description>&lt;FONT color="navy" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Another of our engineers asked us to relay the following to you:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;As far as I see, you confusion is about where the Descriptor Table is stored ('in which privilege level') and what the chances are for your application to modify it. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;If so, I will try to give a simple answer, which is related to memory management in protected mode, which was introduced in x386 and has in principle remained the same up to EM64T - 64-bit processor in fact. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;The term 'Ring Architecture' is a logical concept, and is implemented by Intel micro-architecture in the following way: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Any code has a given privilege level (Intel calls it ring 0-3, and now -1 for VT server - to remain the same ring 0 for host OS highest privilege). Physically, this ring number is a property of a code segment and is stored in Segment Descriptor in that descriptor table.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Thus, the processor always knows the ring level while running the piece of the code, and the privilege level of data it accesses, and can preserve different violations with generating an exception (interruption) - and call some OS callbacks (see details in chapter 4).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;'Call Gate' is, as you mentioned, the mechanism to call procedures with a higher privilege level in some safe way.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Descriptors' tables are stored in 'Main Memory'. The processor has registers where it stores the LINEAR address of those tables: GDTR and LDTR (if not paging - linear address equal to physical address, with paging - its address in virtual memory space).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;At system boot - and this is the responsibility of the OS (on x386 this stuff was executed in real mode before switching to protected mode, now I am not sure what it's called, but I would say in real addressing-mode), OS code at first does all initialization/resets of hardware, including to create descriptor's tables and set the linear addresses into GDTR and LDTR. Before this, any addressing in protected mode is not possible.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;As already replied, the set of instructions which are limited to ring 0, includes but the instructions to load those registers - you cannot call them from lower privilege level code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Thus, you cannot reload these registers, you can call 'kernel' code which sets them, and you cannot directly access that memory where descriptor tables are - just because there is no such descriptor which will point you in protected (segmented address) mode to those tables, but the processor already has access to them via linear address in registers&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Does it make sense? &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;If this is unclear, all details are in the manual in already-mentioned chapters. The only thing to note is that finally, the OS is responsible for right use of the processor's technology. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;==&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;Lexi S.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="F
ONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;IntelSoftware NetworkSupport&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/software"&gt;http://www.intel.com/software&lt;/A&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/58987.htm"&gt;Contact us&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2006 03:45:36 GMT</pubDate>
    <dc:creator>Intel_Software_Netw1</dc:creator>
    <dc:date>2006-11-10T03:45:36Z</dc:date>
    <item>
      <title>Ring Architecture</title>
      <link>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901493#M11107</link>
      <description>&lt;FONT face="Courier New" size="3"&gt;I've been recently exploring the x86 security mechanism(ring architecture). Unfortunately
I've hit a few roadblocks to further progress, and I'm having a hard
time finding any of the answers. I apologize if this isn't the place to
field such questions.&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;





&lt;PRE&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size="3"&gt;The only mechanism to access a higher privilege level code from a&lt;BR /&gt;lower privilege level is through Call Gate. When we use a call gate,&lt;BR /&gt;it points to a Descriptor Table and then you do some comparisons between&lt;BR /&gt;RPL, CPL , DPL before giving access to that code. I understand that this&lt;BR /&gt;Descriptor Table resides in memory.What i am confused is about the &lt;BR /&gt;protection of this Descriptor Table. If this Descriptor Table resides in&lt;BR /&gt;a lower privilege level, then we could modify that using any &lt;BR /&gt;MOV instruction right. So i guess it has to reside in a higher privilege &lt;BR /&gt;level(may be level 0) to be sure that we donot modify that. Correct me &lt;BR /&gt;if i am wrong.&lt;BR /&gt;&lt;BR /&gt;I have been looking at the Intel Architecture Software Developer?s Manual&lt;BR /&gt;about this protection mechanism. But they doesnot precisely state the&lt;BR /&gt;privilege level of the Descriptor Table.So i am wondering what are the&lt;BR /&gt;mechanisms that prevent modification of the Descriptor Table.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Nov 2006 11:11:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901493#M11107</guid>
      <dc:creator>shankarkolli</dc:creator>
      <dc:date>2006-11-08T11:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Ring Architecture</title>
      <link>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901494#M11108</link>
      <description>&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;Weforwarded your question toour application engineering team. One engineer responds:&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;Youshould re-read Section 4.8, 4.8.3 and 4.9 of "&lt;A href="http://developer.intel.com/products/processor/manuals/index.htm"&gt;Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3A: System Programming Guide, Part 1&lt;/A&gt;". I presume thatyou are IA-32 and using Call Gates SYSENTER/SYSEXIT and not IA-32e and using SYSCALL/SYSRET. A call-gate descriptorwill reside in the GDT or in a LDT and the only way to affect these arethrough use of privileged instructions, LGDT and LLDT,which &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;are protected from use by application programs.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;"The privileged instructions control system functions (such as the loading of system registers). They can be executed only when the CPL is 0 (most privileged). If one of these instructions is executed when the CPL is not 0, a general-protection exception (#GP) is generated."&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;"To access a call gate, a far pointer to the gate is provided as a target operand in a CALL or JMP instruction. The segment selector from this pointer identifies the call gate; the offset from the pointer is required, but not used or checked by the processor. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;When the processor has accessed the call gate, it uses the segment selector from the call gate to locate the segment descriptor for the destination code segment. This segment descriptor can be in the GDT or the LDT. It then combines the base address from the code-segment descriptor with the offset from the call gate to form the linear address of the procedure entry point in the code segment."&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV align="left"&gt;&lt;SPAN class="979143318-08112006"&gt;&lt;FONT face="Arial" color="#0000ff" size="2"&gt;So while you can munge together any GDT/LDT of yourchoosing,one cannot load the table and thus affect privileged state unless you were already at ring 0.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;FONT face="Arial" size="2"&gt;==&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;Lexi S.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;IntelSoftware NetworkSupport&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/software"&gt;&lt;/A&gt;&lt;A href="http://www.intel.co" target="_blank"&gt;http://www.intel.co&lt;/A&gt;
m/software &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/58987.htm"&gt;Contact us&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2006 02:18:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901494#M11108</guid>
      <dc:creator>Intel_Software_Netw1</dc:creator>
      <dc:date>2006-11-09T02:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Ring Architecture</title>
      <link>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901495#M11109</link>
      <description>Thanks a lot for the reply. I think i didn't make my point clear.&lt;BR /&gt;&lt;BR /&gt;I will try to explain the problem with the help of a simple example.&lt;BR /&gt;&lt;BR /&gt;Lets assume GDT starts at memory address, say 100(to make things simple) and it is already loaded into GDTR.&lt;BR /&gt;&lt;BR /&gt;Lets say i am currently at ring 3 and need access to higher privilege level. Then i should access this GDT via a call gate and do some privilege checking. If the privilege checking fails then the access is denied. &lt;BR /&gt;&lt;BR /&gt;What i am wondering is we could always do a hack like the following and pass the privilege cheking -&lt;BR /&gt;&lt;BR /&gt;MOV some_value, appropriate_entry_inGDT&lt;BR /&gt;&lt;BR /&gt;We can modify the GDT in memory with the above instruction and hack the appropriate entry and then i can follow it with a call gate access now with the right privilege levels to access a higher privilege level.&lt;BR /&gt;&lt;BR /&gt;What i am wondering about is the mechanisms that prevent this MOV instruction from being executed.&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;Hope i made my problem clear.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Nov 2006 03:23:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901495#M11109</guid>
      <dc:creator>shankarkolli</dc:creator>
      <dc:date>2006-11-10T03:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Ring Architecture</title>
      <link>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901496#M11110</link>
      <description>&lt;FONT color="navy" size="2"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Another of our engineers asked us to relay the following to you:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;As far as I see, you confusion is about where the Descriptor Table is stored ('in which privilege level') and what the chances are for your application to modify it. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;If so, I will try to give a simple answer, which is related to memory management in protected mode, which was introduced in x386 and has in principle remained the same up to EM64T - 64-bit processor in fact. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;The term 'Ring Architecture' is a logical concept, and is implemented by Intel micro-architecture in the following way: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Any code has a given privilege level (Intel calls it ring 0-3, and now -1 for VT server - to remain the same ring 0 for host OS highest privilege). Physically, this ring number is a property of a code segment and is stored in Segment Descriptor in that descriptor table.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Thus, the processor always knows the ring level while running the piece of the code, and the privilege level of data it accesses, and can preserve different violations with generating an exception (interruption) - and call some OS callbacks (see details in chapter 4).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;'Call Gate' is, as you mentioned, the mechanism to call procedures with a higher privilege level in some safe way.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Descriptors' tables are stored in 'Main Memory'. The processor has registers where it stores the LINEAR address of those tables: GDTR and LDTR (if not paging - linear address equal to physical address, with paging - its address in virtual memory space).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;At system boot - and this is the responsibility of the OS (on x386 this stuff was executed in real mode before switching to protected mode, now I am not sure what it's called, but I would say in real addressing-mode), OS code at first does all initialization/resets of hardware, including to create descriptor's tables and set the linear addresses into GDTR and LDTR. Before this, any addressing in protected mode is not possible.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;As already replied, the set of instructions which are limited to ring 0, includes but the instructions to load those registers - you cannot call them from lower privilege level code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Thus, you cannot reload these registers, you can call 'kernel' code which sets them, and you cannot directly access that memory where descriptor tables are - just because there is no such descriptor which will point you in protected (segmented address) mode to those tables, but the processor already has access to them via linear address in registers&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;Does it make sense? &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;If this is unclear, all details are in the manual in already-mentioned chapters. The only thing to note is that finally, the OS is responsible for right use of the processor's technology. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#006400"&gt;==&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;Lexi S.&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="F
ONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;IntelSoftware NetworkSupport&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/software"&gt;http://www.intel.com/software&lt;/A&gt; &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;A href="http://www.intel.com/cd/ids/developer/asmo-na/eng/58987.htm"&gt;Contact us&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: black; FONT-FAMILY: Arial"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2006 03:45:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ring-Architecture/m-p/901496#M11110</guid>
      <dc:creator>Intel_Software_Netw1</dc:creator>
      <dc:date>2006-11-10T03:45:36Z</dc:date>
    </item>
  </channel>
</rss>

