All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trammell Hudson <hudson@osresearch.net>
To: xen-devel@lists.xensource.com
Subject: Switching to user mode from domU kernel
Date: Sun, 30 Sep 2007 16:11:43 -0400	[thread overview]
Message-ID: <20070930201143.GC31619@osresearch.net> (raw)

I'm having trouble switching into user mode with my domU kernel --
everytime I call __HYPERVISOR_iret, the hypervisor calls into my
kernel via the registered callback handler.  None of the bits in
the event channel pending arrays are set.  If I return via the
iret call, the hypervisor immediately calls back into the handler.
The user RIP never changes, so it is clearly not making forward
progress.

The stackframe should be correctly setup with the flags, rip, cs,
rflags, rsp, and ss values and the currently installed LDT has
slots for the code and data segments that the user will use.

Am I not jumping into user space correctly?  Is there something
else that my code should do to make the transition?

On a documentation question, is __HYPERVISOR_iret documented
anywhere?  The Xen API* doesn't seem to include any details on it.
I deduced the stack arguments from looking at the code in the Linux
xen architecture and the xen-x86_64.h header.

This comment in the header, however, doesn't seem to match the
behaviour that my code seems to experience:

 * If flags contains VGCF_in_syscall:
 *   Restore RAX, RIP, RFLAGS, RSP.
 *   Discard R11, RCX, CS, SS.
 * Otherwise:
 *   Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP.

I am passing flags==0 and only push the values for flags, CS:RIP,
RFLAGS, and SS:RSP.  If I push values for RAX, R11, and RCX on the
stack the kernel ends up in all sorts of weird places rather than
my intended RIP and RSP.


Thanks!
-- Trammell

*: http://www.cl.cam.ac.uk/research/srg/netos/xen/readmes/interface/interface.html

             reply	other threads:[~2007-09-30 20:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-30 20:11 Trammell Hudson [this message]
2007-10-01  5:24 ` Switching to user mode from domU kernel Keir Fraser
2007-10-01 18:43   ` Trammell Hudson
2007-10-02  5:33     ` Keir Fraser
2007-10-22 19:52   ` Trammell Hudson
2007-10-22 20:12     ` Keir Fraser
2007-10-22 22:00       ` Trammell Hudson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070930201143.GC31619@osresearch.net \
    --to=hudson@osresearch.net \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.