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] how to callback from hypervisor to guest os?

To: weiming <zephyr.zhao@xxxxxxxxx>
Subject: Re: [Xen-devel] how to callback from hypervisor to guest os?
From: Daniel Stodden <stodden@xxxxxxxxxx>
Date: Sun, 06 Jul 2008 02:15:38 -0700
Cc: Xen Developers <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Sun, 06 Jul 2008 02:16:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <add59a3f0807052118o184a1d20q3f750b57ac96c8f7@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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Fakultät für Informatik I10, Technische Universität München
References: <add59a3f0807052118o184a1d20q3f750b57ac96c8f7@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Sun, 2008-07-06 at 00:18 -0400, weiming wrote:
> I try to let xen calls a kernel function in guest OS, is it possible?
> 
> Here is the detail:
> 
> Normally, when a guest hits a fault, the control is transfered to xen.
> Then xen handles the fault and then transfer the control back to
> guest.
> 
> For example, in original xen:
> void some_fault_handler()
> {
> 
>    ...
>    ...
>    finally, then let guest os handles it
> }
> 
> Now, I want to call some guest OS function in xen's handler:
> 
> void some_fault_handler()
> {
> 
>   guest_func() // a function in guest kernel
>    ...
>    ...
>    finally, then let guest os handles it
> }
> 
> 
> I can write a module (driver) in guest os, so when guest os boots, I
> can pass the address of my function to xen. My question is that when
> xen calls my function, it needs to swtich to "guest mode". How to do
> this? and when the function call finishes, how to let it come back to
> xen's context?

The way you envision it, i.e. per function pointer, this is just a
mega-bad idea :). While in theory possible, you'd execute arbitrary
insecure (per definition) guest system code at the VMM privilege level.
If at all, it would only work if the calling conventions in Xen and the
guest code match. Beyond that, there's 32/64-bit mixed modes, NPT
translation, and many more reasons not even to consider it.

There's different ways for Xen to communicate with guests. None of them
can give you the simple synchronous calling scheme you suggest.
Reasons include limitations in how the hardware implements control
transfers accross different privilege levels and security/stability
considerations. Even if that were not enough, you would experience some
funny effects in the guest kernel, and an overall hypervisor design
which will just refuse to switch back and forth between VMM and guest
execution.

Have a look at Xen's event channels, trap (interrupt) injections and the
overall shared memory paradigm underlying communications with guests. If
that's what you need, then maybe send a description on what you're
actually up to. :)

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