WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Xen-aware kernel module

To: "Steven Y. Ko" <sko@xxxxxxxxxxx>
Subject: Re: [Xen-devel] Xen-aware kernel module
From: Daniel Stodden <stodden@xxxxxxxxxx>
Date: Wed, 21 Nov 2007 05:48:03 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 20 Nov 2007 20:48:45 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <5fa100fd0711201630y668d0846ufd5a6de2e065a17e@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Fakultät für Informatik I10, Technische Universität Münche
References: <5fa100fd0711201630y668d0846ufd5a6de2e065a17e@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2007-11-20 at 18:30 -0600, Steven Y. Ko wrote:
> Hello,
> 
> (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_XEN
# ifdef CONFIG_X86_32
ring = 1;
# else
ring = 3;
# endif
#else
ring = 0;
#endif

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.

hth,
daniel

-- 
Daniel Stodden
LRR     -      Lehrstuhl für Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München             D-85748 Garching
http://www.lrr.in.tum.de/~stodden         mailto:stodden@xxxxxxxxxx
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33  3D80 457E 82AE B0D8 735B



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>