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] Switching to user mode from domU kernel

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] Switching to user mode from domU kernel
From: Trammell Hudson <hudson@xxxxxxxxxxxxxx>
Date: Mon, 22 Oct 2007 15:52:15 -0400
Delivery-date: Mon, 22 Oct 2007 12:52:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <C3264307.E410%Keir.Fraser@xxxxxxxxxxxx>
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>
References: <20070930201143.GC31619@xxxxxxxxxxxxxx> <C3264307.E410%Keir.Fraser@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.10i
On Mon, Oct 01, 2007 at 06:24:07AM +0100, Keir Fraser wrote:
> On 30/9/07 21:11, "Trammell Hudson" <hudson@xxxxxxxxxxxxxx> wrote:
> 
> > Am I not jumping into user space correctly?  Is there something
> > else that my code should do to make the transition?
> 
> It sounds like event delivery is masked before the iret, and then you have
> IF set in the RFLAGS value in the iret frame, which causes event delivery to
> be unmasked during iret.

If I disable the domU event channel console and use the
HYPERVISOR_console_io hypercall instead, the user process is run
as expected.  It deliberately causes a GPF by executing HLT after
a few instructions so that I know that it began executing user code.
That let's me know that my GDT and LDT are setup correctly and
that the user page tables are installed for at least the code segment.
If I have done any console output via EVTCHNOP_send my user app
never makes progress -- the domU kernel event callback is called
a few million times per second and the registers on the stack indicate
that the app is still on its first instruction (not the HLT).

The console output code is nearly a direct copy of the mini-os code
and uses the xencons_interface in the same way (with the addition
of newline mapping):

        struct xencons_interface *intf = xen_console;
        XENCONS_RING_IDX cons = intf->out_cons;
        XENCONS_RING_IDX prod = intf->out_prod;

        mb();
        while ((sent < len) && ((prod - cons) < sizeof(intf->out)-1))
        {
                char c = data[ sent++ ];
                if( c == '\n' )
                        intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = '\r';
                intf->out[MASK_XENCONS_IDX(prod++, intf->out)] = c;
        }

        wmb();
        intf->out_prod = prod;

        struct evtchn_send send = {
                .port = xen_start_info->console.domU.evtchn,
        };

        HYPERVISOR_event_channel_op( EVTCHNOP_send, &send );

I've masked all events and the pending field in the shared_info
structure is zero.  There are no waiting characters in the incoming
xen_console->in_prod array.

So, any ideas as to what I'm missing and why Xen keeps calling
the callback?

Thanks!
-- Trammell

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