[vbox-dev] Fwd: Explanation about Ring0 context

Michal Necasek michal.necasek at oracle.com
Tue Feb 2 09:05:23 GMT 2016


  It doesn't *need* to be in R0 context. You can disable the R0 device 
bits and see what that does to performance. Hint: Switching R0->R3->R0 
takes a lot more time than not switching at all.

  Keep in mind that with hardware virtualization, guest code effectively 
runs in the host's R0 context because that's where VM entries and exits 
happen.

     - Michal

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





More information about the vbox-dev mailing list