From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Bastian Blank <waldi@debian.org>,
linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com,
544145@bugs.debian.org, Keir Fraser <keir.fraser@eu.citrix.com>
Subject: Re: 32bit binaries on x86_64/Xen segfaults in syscall-vdso
Date: Fri, 04 Sep 2009 09:07:39 -0700 [thread overview]
Message-ID: <4AA13B4B.7020101@goop.org> (raw)
In-Reply-To: <20090903223603.GA19945@wavehammer.waldi.eu.org>
On 09/03/09 15:36, Bastian Blank wrote:
> This function looks weird. It tries to restores the user code segment.
> But the documentation from AMD explicitely stat that the CS and SS are
> restored from the STAR register.
And STAR is always set with:
wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
so when using sysret to return to 32-bit, it:
The CS selector value is set to MSR IA32_STAR[63:48]. The SS is set
to IA32_STAR[63:48] + 8.
so CS is __USER32_CS and SS is __USER32_DS.
The code for xen_sysret32 is:
ENTRY(xen_sysret32)
/*
* We're already on the usermode stack at this point, but
* still with the kernel gs, so we can easily switch back
*/
movq %rsp, PER_CPU_VAR(old_rsp)
movq PER_CPU_VAR(kernel_stack), %rsp
pushq $__USER32_DS
pushq PER_CPU_VAR(old_rsp)
pushq %r11
pushq $__USER32_CS
pushq %rcx
pushq $VGCF_in_syscall
1: jmp hypercall_iret
The iret frame is:
ss
rsp
rflags
cs
rip <-- rsp
so this constructs a frame of:
__USER32_DS
user_esp
user_eflags
__USER32_CS
user_eip <-- kernel rsp
and then it does the iret hypercall.
But for some reason that's triggering a failsafe callback, which invokes
a GP.
J
next prev parent reply other threads:[~2009-09-04 16:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-30 18:16 Bastian Blank
2009-09-03 20:51 ` Jeremy Fitzhardinge
2009-09-03 22:02 ` Bastian Blank
2009-09-03 22:06 ` Jeremy Fitzhardinge
2009-09-03 22:36 ` Bastian Blank
2009-09-04 16:07 ` Jeremy Fitzhardinge [this message]
2009-09-04 16:20 ` Bastian Blank
2009-09-04 16:56 ` Jeremy Fitzhardinge
2009-09-04 17:46 ` Bastian Blank
2009-09-04 18:19 ` Bastian Blank
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=4AA13B4B.7020101@goop.org \
--to=jeremy@goop.org \
--cc=544145@bugs.debian.org \
--cc=keir.fraser@eu.citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=waldi@debian.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®