<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>



        
        
        
        <style type="text/css">p { margin-bottom: 0.21cm; }a:link {  }</style>

<p style="margin-bottom: 0.5cm;"><font style="" face="Times New Roman">ok,i get
it. But, in order to maintain consistency between shadow PT and guest
PT, we have to write-protect the guest PT. The
hypervisor write-protects all physical pages that constitute the
guest PT. Any modification by the guest results in a page fault
exception. Now, when the guest O.S. change the CR3, we practically
have new PTs. What i would like to know is if VirtualBox uses the
memory tracing techinique<font style="font-size: 10pt;" size="2"> to maintain that consistency(</font></font><font style="font-size: 10pt;" face="Times new roman, serif" size="2">write
protect PTs </font><font style="font-size: 10pt;" face="Times new roman, serif" size="2">$B"*(B
</font><font style="font-size: 10pt;" face="Times new roman, serif" size="2">force
trap into hypervisor on each update)or another method(i found only
few documents, the most of them talks about memory traces):Lazy
shadowing of virtual page table:identify synchronisation
points,possible due to TLB semantics,real PT updates only become
effective once loaded into TLB</font><font style="font-size: 10pt;" face="Times new roman, serif" size="2">,
</font><font style="font-size: 10pt;" face="Times new roman, serif" size="2">explicit
TLB loads and flushes are natural synchronisation points. Can anyone
help me pointing out wich method is used by VirtualBox???<br></font></p>
<hr>
<p style="margin-bottom: 0cm;">From: knut.osmundsen@oracle.com<br>Date:
Sat, 23 Jul 2011 21:59:48 +0200<br>To:
vbox-dev@virtualbox.org<br>Subject: Re: [vbox-dev] Managing CR3 on
guest O.S.<br><br>Hi Francesco.</p>
<p style="margin-bottom: 0cm;"><br>
</p>
<p style="margin-bottom: 0cm;">On Jul 23, 2011, at 4:02 PM, Francesco
Di Paolo wrote:</p>
<br><br>
<BR>
<blockquote style="margin-bottom: 0cm; font-style: normal; font-weight: normal; widows: 2; orphans: 2;">
<font face="Tahoma"><font size="2"><font face="Times new roman, serif">Hello
there,<br>i'd like some hints in regards how the CR3 register is
handled. From what i've learned, it seems that VirtualBox, everytime
a guest O.S. try to write on CR3. generates a #GP and <br>uses a
function</font> <font color="#000000"><font face="FreeMono">EMInterpretCRxWrite() </font></font><font color="#000000"><font face="Times New Roman">that
calls </font></font><font color="#000000"><font face="FreeMono"><span lang="en-GB">emUpdateCRx</span></font></font><font color="#000000"><font face="FreeMono">() </font></font><font color="#000000"><font face="Times New Roman">which
modifies</font></font><font color="#000000"> </font><font color="#000000"><font face="Times New Roman">the
VCpu. In particular, in regards to CR3, it sets the new
value(with </font></font> <font color="#000000"><font face="FreeMono, monospace">CPUMSetGuestCR3</font></font> <font color="#000000"><font face="Times New Roman">)and
does a flush calling </font></font><font color="#000000"><font face="FreeMono, monospace">PGMFlushTLB</font></font><font color="#000000"><font face="FreeMono">() </font></font><font color="#000000"><font face="Times New Roman">that
remap the CR3 with the function </font></font><font color="#000000"><font face="FreeMono, monospace">MapCR3()</font></font><font color="#000000"><font face="FreeMono">. </font></font><font color="#000000"><font face="Times New Roman">Now,
i  think that VirtualBox has to do the setup of the new page
table right? And, in order to catch all the exceptions, it has to
write protect it or am i wrong?and if it is so,can anyone address me
to the source code that does these??</font></font></font></font></blockquote>
<blockquote style="border: medium none; padding: 0cm; font-style: normal; font-weight: normal; widows: 2; orphans: 2;">
<font color="#000000"><font face="Times New Roman"><font size="2">i
would appreciate</font></font></font></blockquote>
<p style="margin-bottom: 0cm;"><br>
</p>
<p style="margin-bottom: 0cm;">We cache shadow paging structures. So,
when the guest loads a new value into CR3 its very likely that it
will be in our cache. The cache is called PGMPool. It will take care
of monitoring the paging structures and keeping the shadow
sufficiently up to date.</p>
<p style="margin-bottom: 0cm;"><br>
</p>
<p style="margin-bottom: 0cm;">Missing entries in the shadow paging
structures will mostly be synced over from the guest structures when
a page fault occurs, i.e. when they normally would be loaded into the
CPUs TLB.</p>
<p style="margin-bottom: 0cm;"><br>
</p>
<p style="margin-bottom: 0cm; widows: 2; orphans: 2;"><font color="#000000"><font face="Helvetica"><font size="4"><span style="font-style: normal;"><span style="font-weight: normal;">-- <br><br>Kind
regards / Mit freundlichen Gruessen / Vennlig
hilsen,<br> bird<br><br>--<br><br>ORACLE Deutschland B.V. &
Co. KG  Knut St. Osmundsen<br>Werkstrasse 24
                   Senior
Staff Engineer, VirtualBox<br>71384 Weinstadt, Germany
         <a href="mailto:bird@sun.com">mailto:bird@sun.com</a><br><br>Hauptverwaltung:
Riesstr. 25, D-80992 Muenchen<br>Registergericht: Amtsgericht
Muenchen, HRA 95603<br><br>Komplementaerin: ORACLE Deutschland
Verwaltung B.V.<br>Rijnzathe 6, 3454PV De Meern,
Niederlande<br>Handelsregister der Handelskammer Midden-Niederlande,
Nr. 30143697<br>Geschaeftsfuehrer: J. Kunz, M. van de Molen, A. van
der Ven</span></span></font></font></font></p>
<p style="margin-bottom: 0cm;"><br><br>_______________________________________________
vbox-dev mailing list vbox-dev@virtualbox.org
http://vbox.innotek.de/mailman/listinfo/vbox-dev</p>
<p style="margin-bottom: 0cm;"><br>
</p>
                                          </div></body>
</html>