<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Ric,<br>
    <br>
    <div class="moz-cite-prefix">On 30.03.2016 02:02, Vilbig, Ric wrote:<br>
    </div>
    <blockquote
cite="mid:CDEB11797F7D624793A80A777C19829C01A6454DC2@NA-MBX-01.mgc.mentorg.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <meta name="Generator" content="Microsoft Word 14 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#002060;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D">Hi,<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">I obviously
            carried on with my investigation after sending the original
            email, and have figured out what is triggering this abort
            (not really fair to call it a crash).</span></p>
      </div>
    </blockquote>
    VBox.log actually is showing that the VM was never fully powered up.
    So the crash happens before the CPU started executing instructions.
    See below, I know that this doesn't make much sense to you.<br>
    <blockquote
cite="mid:CDEB11797F7D624793A80A777C19829C01A6454DC2@NA-MBX-01.mgc.mentorg.com"
      type="cite">
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D"><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D">When the BIOS
            starts initializing the PCI Configuration space for my PCIe
            switch, it reads the secondary bus register (PCI CFG 0x19)
            before it’s been initialized, so the device model is
            returning 0.  This puts the BIOS into a loop, repeating the
            following over 5000 times before aborting the VM session.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Rd 0x0a L 2 = 0x0604     // Class<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Rd 0x00 L 2 = 0x14ab     // VendID<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Rd 0x02 L 2 = 0x1000     // DevID<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Wr 0x1c L 1 = 0xd0       // IOBase<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Wr 0x20 L 2 = 0xf000     // MemBase<o:p></o:p></span></p>
        <p class="MsoNormal" style="margin-left:.5in"><span
            style="font-size:8.0pt;font-family:"Courier New"">PCI
            CFG Root  Rd 0x19 L 1 =
            <b><span style="color:#C00000">0x00</span></b>       //
            SecBus<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060">If I intercept
            the secondary bus register read, and return a 3 instead of
            reading 0 from RTL, then it carries on with root
            configuration and my VM boots and runs correctly.  It’s not
            detecting the downstream end point, but that is a separate
            issue.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060">Meanwhile, does
            it make sense for the BIOS to read the secondary bus
            register
          </span><span style="color:#1F497D">before it’s been
            initialized?  It seems like that register should be set up
            as the BIOS proceeds through the enumeration.  That is what
            the VM with PIIX3 chipset does.</span></p>
      </div>
    </blockquote>
    It does, but for a non-obvious reason. VirtualBox pre-configures its
    PCI devices before it starts the BIOS, especially the bus numbers.
    Looks like for some reason this isn't done properly (or not making
    it correctly to your PCIe switch). This confuses the code, most
    likely causing endless recursion and thus a stack overflow. You
    should be able to use a debugger on the VM process to find out the
    detail, because this is all normal userland code on the host - which
    wouldn't work if it's BIOS code running inside the VM.<br>
    <br>
    The motivation for moving the PCI bus configuration out of the BIOS
    is to some extent historic (in the old days we always fought with
    the BIOS size restriction, due to the extremely bad code quality by
    the BCC compiler), to some extent an optimization (it's far easier
    and more efficient to do the hairy stuff in 32 bit code on the host,
    and not in in the actual BIOS, which is annoying 16 bit real mode
    code).<br>
    <br>
    Klaus<br>
    <blockquote
cite="mid:CDEB11797F7D624793A80A777C19829C01A6454DC2@NA-MBX-01.mgc.mentorg.com"
      type="cite">
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:#1F497D"><o:p></o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060">_____________________________________________<o:p></o:p></span></p>
        <p class="MsoNormal"><b><span
              style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></b></p>
        <p class="MsoNormal"><b><span style="color:#002060">Ric Vilbig</span></b><span
            style="color:#002060"><o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060">Mentor Graphics,
            Emulation Division</span><span
            style="font-size:10.0pt;color:#002060"><o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060">46871 Bayside
            Parkway, Fremont CA, 94538<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060">Phone:  510-354-7360<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060">Mobile: 408-529-2365<o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060">email:  <a
              moz-do-not-send="true" href="mailto:ric_vilbig@mentor.com">
              <a class="moz-txt-link-abbreviated" href="mailto:ric_vilbig@mentor.com">ric_vilbig@mentor.com</a></a><o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
        <div style="border:none;border-left:solid blue 1.5pt;padding:0in
          0in 0in 4.0pt">
          <div>
            <div style="border:none;border-top:solid #B5C4DF
              1.0pt;padding:3.0pt 0in 0in 0in">
              <p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
                  Vilbig, Ric
                  <br>
                  <b>Sent:</b> Tuesday, March 29, 2016 11:40<br>
                  <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:vbox-dev@virtualbox.org">vbox-dev@virtualbox.org</a><br>
                  <b>Cc:</b> Vilbig, Ric<br>
                  <b>Subject:</b> VM crash, NS_ERROR_FAILURE<o:p></o:p></span></p>
            </div>
          </div>
          <p class="MsoNormal"><o:p> </o:p></p>
          <p class="MsoNormal"><span style="color:#002060">Hi experts,<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">I would like
              to ask for some help to figure out why a certain VM
              crashes on start-up.  Although the problem is evidently
              induced by my PDM plug-in, the crash does not appear to be
              happening therein.  I need some help to root cause where
              VBox is aborting the VM session.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:8.0pt;font-family:"Courier
              New"">>  VBoxManage startvm "U14_ICH9_2"<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:8.0pt;font-family:"Courier
              New"">Waiting for VM "U14_ICH9_2" to power on...<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:8.0pt;font-family:"Courier
              New"">VBoxManage: error: The VM session was aborted<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:8.0pt;font-family:"Courier
              New"">VBoxManage: error: Details: code
              NS_ERROR_FAILURE (0x80004005), component SessionMachine,
              interface ISession<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">I created
              this VM from the VirtualBox GUI, v5.0.16, which I built
              from the tarball at
              <a moz-do-not-send="true"
                href="https://www.virtualbox.org/wiki/Downloads">https://www.virtualbox.org/wiki/Downloads</a>
              and am running on an Ubuntu 14 host.  Then I switched the
              chipset to ICH9, then I installed Ubuntu 14 as the guest. 
              The VM runs well, until I plug my virtual device model
              into PDM (it’s a PCIe switch with downstream endpoint). 
              After plugging in my virtual device, the VM crashes as
              shown above.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">I tracked
              down everywhere NS_ERROR_FAILURE is mentioned in the
              sources.  I found that DirectoryServiceProvider::GetFile()
              returns that error twice, right away, but that is also
              true in the working case when my device is unplugged.  In
              no other place is that specific error ever returned or
              asserted.  However, I found that E_FAIL is #defined to
              NS_ERROR_FAILURE, and there are hundreds of references to
              E_FAIL, so I gave up trying to instrument them all.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">I need some
              help to root cause this problem.  Log files show that it
              is getting as far as BIOS starting to initialize the
              switch, apparently stuck in a loop doing that, but then
              lights out with no trail that I can follow.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">Log files are
              attached.  Lines bearing the “RicV” prefix were
              instrumented by me to investigate this problem.  Lines
              bearing the “RemDev” prefix are coming from my PDM
              plug-in.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">Thanks,<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="color:#002060">_____________________________________________<o:p></o:p></span></p>
          <p class="MsoNormal"><b><span
                style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></b></p>
          <p class="MsoNormal"><b><span style="color:#002060">Ric Vilbig</span></b><span
              style="color:#002060"><o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060">Mentor Graphics,
              Emulation Division<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060">46871 Bayside
              Parkway, Fremont CA, 94538<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060">Phone: 
              510-354-7360<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060">Mobile:
              408-529-2365<o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060">email:  <a
                moz-do-not-send="true"
                href="mailto:ric_vilbig@mentor.com">
                <a class="moz-txt-link-abbreviated" href="mailto:ric_vilbig@mentor.com">ric_vilbig@mentor.com</a></a><o:p></o:p></span></p>
          <p class="MsoNormal"><span
              style="font-size:10.0pt;color:#002060"><o:p> </o:p></span></p>
          <p class="MsoNormal"><o:p> </o:p></p>
        </div>
      </div>
      <br>
    </blockquote>
  </body>
</html>