<?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 I figured out the issue in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Trouble-handling-host-code-programming-errors-via-exceptions/m-p/948972#M19064</link>
    <description>&lt;P&gt;I figured out the issue myself this weekend and learned somthing very interesting in the process.&lt;/P&gt;
&lt;P&gt;Because exception handling was working correctly just before the VM was launched, I assumed the IDT was setup correctly and that the host's IDTR or TSS base was screwed up in the VMCS.&amp;nbsp; However, double checking IDTR base, IDT entries, TSS base, TSS entries did not yield any solution.&amp;nbsp; Then, on a hunch I checked the GDTR base and that was incorrect!&amp;nbsp; I never thought of checking that value because the host code was working correctly!&lt;/P&gt;
&lt;P&gt;Well, it seems that my host code never needed to load a segemet selector so the CPU never needed to reference the GDT.&amp;nbsp; So the incorrect GDTR base value was never&amp;nbsp;used, and therefroe,&amp;nbsp;did not cause an issue.&amp;nbsp; However, because exception handling requires the CS and an offset of handler code to be laoded, the CPU did need to reference the GDT which was not at the specified location -- this cause another exception resutling in a hung CPU.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 May 2013 16:50:46 GMT</pubDate>
    <dc:creator>Yogi_D_</dc:creator>
    <dc:date>2013-05-06T16:50:46Z</dc:date>
    <item>
      <title>Trouble handling host code programming errors via exceptions</title>
      <link>https://community.intel.com/t5/Software-Archive/Trouble-handling-host-code-programming-errors-via-exceptions/m-p/948971#M19063</link>
      <description>&lt;P&gt;Hi.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am writing a small OS-agnostic hypervisor as a teaching tool for my students.&amp;nbsp; The hypervisor code is loaded by the code I embed in a custom MBR on the boot device when the system boots.&amp;nbsp; The hypervisor code switches to 32-bit proceted mode and then IA32e (64-bit mode, paged with identity mapping of linear -- physical addresses).&amp;nbsp; It then sets up the 64-bit exception handling mechanism and tests of this exception handling mechanism are successful (CPL and DPL&amp;nbsp;are 0 so no stack switching is expected).&amp;nbsp; E.g., divide by 0, and page faults are handled as expected.&lt;/P&gt;
&lt;P&gt;Next, an IA32e mode guest is launched.&amp;nbsp; The guest has its own paging tables (these are not identity mapped).&amp;nbsp; The guest handles exceptions and interrutps by itself (i.e., it has a different IDT than the host, and the exception bitmap control is set to 0).&amp;nbsp; All this is working.&amp;nbsp; External interrupts, exceptions, memory accesses, access to I/O devices is working well int he guest.&amp;nbsp; The guest exits to the host because of various conditions and is resumed correctly.&lt;/P&gt;
&lt;P&gt;The issue occurs when I try to capture programming mistakes in the VM exit handler (host code).&amp;nbsp; For example, a divide by 0, invalid, opcode, page fault exceptions all result in the CPU locking up.&amp;nbsp; The host essentially has the same IDT setting as before the launch of the guest, but clearly something is getting screwed up.&amp;nbsp; Any thoughts as to what I should be looking at in particular to help solve this issue?&lt;/P&gt;
&lt;P&gt;For the host, I am setting up TR selector, IDTR base, TR base to the same values they are before VM launch is executed.&amp;nbsp; Because the host is running witch CPL of 0 and the handler code's CS has DPL of 0, I am not expecting a stack switch.&amp;nbsp; Therefore, I am not specifying&amp;nbsp;any stacks in the 64-bit TSS (all entries in the hosts TSS are 0 except for the I/O bitmap offset).&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;-Yogi&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2013 17:41:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Trouble-handling-host-code-programming-errors-via-exceptions/m-p/948971#M19063</guid>
      <dc:creator>Yogi_D_</dc:creator>
      <dc:date>2013-05-04T17:41:20Z</dc:date>
    </item>
    <item>
      <title>I figured out the issue</title>
      <link>https://community.intel.com/t5/Software-Archive/Trouble-handling-host-code-programming-errors-via-exceptions/m-p/948972#M19064</link>
      <description>&lt;P&gt;I figured out the issue myself this weekend and learned somthing very interesting in the process.&lt;/P&gt;
&lt;P&gt;Because exception handling was working correctly just before the VM was launched, I assumed the IDT was setup correctly and that the host's IDTR or TSS base was screwed up in the VMCS.&amp;nbsp; However, double checking IDTR base, IDT entries, TSS base, TSS entries did not yield any solution.&amp;nbsp; Then, on a hunch I checked the GDTR base and that was incorrect!&amp;nbsp; I never thought of checking that value because the host code was working correctly!&lt;/P&gt;
&lt;P&gt;Well, it seems that my host code never needed to load a segemet selector so the CPU never needed to reference the GDT.&amp;nbsp; So the incorrect GDTR base value was never&amp;nbsp;used, and therefroe,&amp;nbsp;did not cause an issue.&amp;nbsp; However, because exception handling requires the CS and an offset of handler code to be laoded, the CPU did need to reference the GDT which was not at the specified location -- this cause another exception resutling in a hung CPU.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2013 16:50:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Trouble-handling-host-code-programming-errors-via-exceptions/m-p/948972#M19064</guid>
      <dc:creator>Yogi_D_</dc:creator>
      <dc:date>2013-05-06T16:50:46Z</dc:date>
    </item>
  </channel>
</rss>

