<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Gregory, thanks for the reply;<div>anyway, my question was about R3 context of the host.</div><div>Since the host must emulate the E1000 behaviour, it doesn't need to access</div><div>the I/O space on the host. So, why does it need to be in R0 context?</div><div>Also, as far as I know, the file VBoxDD.so is a library for R3 context, and it has the references</div><div>for functions running in R0 context (e.g. e1kRegWriteTDT).</div><div>How can it be possible?</div><div><br></div><div>Kind Regards,</div><div>Luca Carotenuto</div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2016-02-01 16:11 GMT+01:00 Gregory Woodbury <span dir="ltr"><<a href="mailto:redwolfe@gmail.com" target="_blank">redwolfe@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Depending on the CPU architecture, Ring 3 processes cannot access the<br>
I/O space without causing a General Protection Exception.<br>
<br>
Callback routines from IO requests are to let the application be told<br>
that an operation is completed.<br>
And thus have to be in the application's memory space, but they are<br>
actually called from the<br>
kernel in R0 space. There are special provisions in the x86 type<br>
architecture for this, and<br>
the callback routine has only a limited amount of freedom to access IO space.<br>
<br>
In a fully emulated environment, this might not be necessary, but<br>
using the hardware virtualization of KVM/QEMU, to access<br>
the IO space still requires Ring0 privleges.  I is a sort of<br>
mind-bending set of restrictions and interactioins until one<br>
gets used to thinking like the system developers did.<br>
<div><div><br>
<br>
On Mon, Feb 1, 2016 at 6:59 AM, Luca Carotenuto<br>
<<a href="mailto:luca.carotenuto.91@gmail.com" target="_blank">luca.carotenuto.91@gmail.com</a>> wrote:<br>
<br>
> 1) As I understand, when we talk about Ring-0 context, we refer to kernel<br>
> space, while Ring-3 context refers to user space. Am I right?<br>
><br>
> 2) I'm looking inside the E1000 emulation code<br>
> (/src/VBox/Devices/Network/DevE1000.cpp).<br>
> Assuming that the above is right, for what concerns the registers callbacks,<br>
>  I do not understand why those callbacks are compiled to be executed in<br>
> Ring-0 context<br>
> (When I use logging inside those functions, the thread name i R0).<br>
> Infact, looking inside the VboxDD.so file in the "out/bin" directory (using<br>
> objdump tool), it seems that this code "belongs" to Ring-3 context,<br>
> so why is it running in Ring-0 context?<br>
<br>
</div></div><span><font color="#888888">--<br>
G.Wolfe Woodbury<br>
<a href="mailto:redwolfe@gmail.com" target="_blank">redwolfe@gmail.com</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div><div dir="ltr">Luca Carotenuto</div></div>
</font></span></div>
</div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Luca Carotenuto</div></div>
</div>