[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] Xen-aware kernel module
On Tue, 2007-11-20 at 18:30 -0600, Steven Y. Ko wrote:
> (I'm not sure if this is an appropriate place to ask this question. I
> apologize, if it's not)
> I'm trying to write a kernel module, that's sort of Xen-aware (or
> virtualisation-aware). I say "sort of", because what I actually need
> is checking the ring. Specifically, in my kernel module, I want to
> check which ring the code is running on (ring0, ring1, or even ring
> 3!), and behave differently. Does Xen provide any interface to do it?
> or is there any way to do it in a kernel module? Thanks for any help.
well, if you had a xen interface to check it, then you already know
you're not running on ring0, right?
i suppose you will not consider HVM in your equation, because the ring
idea makes only sense with pv. so, the solution may be:
# ifdef CONFIG_X86_32
ring = 1;
ring = 3;
ring = 0;
amounts to a minumum of runtime overhead <:). i forgot: add tests for
XENFEAT_supervisor_mode_kernel, but I believe it that never really got
into vogue (someone correct me if i'm wrong).
CPL is stored only internally. If it should look smarter, one might
consider following the %cs selector, but strictly speaking this isn't
bulletproof as the descriptor might have altered in the meanwhile (on
linux, it's usually safe). There may be some alternatives I'm admittedly
rather unaware of.
checking privilege levels that way will, if at all, only work on PV.
full virtualization (because you mentioned 'virtualization-aware' vs.
xen-only) will do its best to assure you you're running on cpl 0.
similar applies to VT-x root vs. non-root mode.
LRR - Lehrstuhl fÃr Rechnertechnik und Rechnerorganisation
Institut fÃr Informatik der TU MÃnchen D-85748 Garching
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B
Xen-devel mailing list