From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Andy Lutomirski <luto@kernel.org>, Brian Gerst <brgerst@gmail.com>
Cc: X86 ML <x86@kernel.org>, Juergen Gross <jgross@suse.com>,
Borislav Petkov <bpetkov@suse.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v2] x86/xen/64: Rearrange the SYSCALL entries
Date: Mon, 14 Aug 2017 07:45:13 +0100 [thread overview]
Message-ID: <ee0541ca-3986-7379-4fd9-b2a188b12841@citrix.com> (raw)
In-Reply-To: <CALCETrUUyBzPv4ZqXJ6pC8YVTZBs+rw305f53yw_xc1xi6EEjw@mail.gmail.com>
On 14/08/2017 06:53, Andy Lutomirski wrote:
> On Sun, Aug 13, 2017 at 7:44 PM, Brian Gerst <brgerst@gmail.com> wrote:
>> On Mon, Aug 7, 2017 at 11:59 PM, Andy Lutomirski <luto@kernel.org> wrote:
>>> /* Normal 64-bit system call target */
>>> ENTRY(xen_syscall_target)
>>> - undo_xen_syscall
>>> - jmp entry_SYSCALL_64_after_swapgs
>>> + popq %rcx
>>> + popq %r11
>>> + jmp entry_SYSCALL_64_after_hwframe
>>> ENDPROC(xen_syscall_target)
>>>
>>> #ifdef CONFIG_IA32_EMULATION
>>>
>>> /* 32-bit compat syscall target */
>>> ENTRY(xen_syscall32_target)
>>> - undo_xen_syscall
>>> - jmp entry_SYSCALL_compat
>>> + popq %rcx
>>> + popq %r11
>>> + jmp entry_SYSCALL_compat_after_hwframe
>>> ENDPROC(xen_syscall32_target)
>>>
>>> /* 32-bit compat sysenter target */
>>> ENTRY(xen_sysenter_target)
>>> - undo_xen_syscall
>>> + mov 0*8(%rsp), %rcx
>>> + mov 1*8(%rsp), %r11
>>> + mov 5*8(%rsp), %rsp
>>> jmp entry_SYSENTER_compat
>>> ENDPROC(xen_sysenter_target)
>> This patch causes the iopl_32 and ioperm_32 self-tests to fail on a
>> 64-bit PV kernel. The 64-bit versions pass. It gets a seg fault after
>> "parent: write to 0x80 (should fail)", and the fault isn't caught by
>> the signal handler. It just dumps back to the shell. The tests pass
>> after reverting this.
> I can reproduce it if I emulate an AMD machine. I can "fix" it like this:
>
> diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
> index a8a4f4c460a6..6255e00f425e 100644
> --- a/arch/x86/xen/xen-asm_64.S
> +++ b/arch/x86/xen/xen-asm_64.S
> @@ -97,6 +97,9 @@ ENDPROC(xen_syscall_target)
> ENTRY(xen_syscall32_target)
> popq %rcx
> popq %r11
> + movq $__USER32_DS, 4*8(%rsp)
> + movq $__USER32_CS, 1*8(%rsp)
> + movq %r11, 2*8(%rsp)
> jmp entry_SYSCALL_compat_after_hwframe
> ENDPROC(xen_syscall32_target)
>
> but I haven't tried to diagnose precisely what's going on.
>
> Xen seems to be putting the 0xe0?? values in ss and cs, which oughtn't
> to be a problem, but it kills opportunistic sysretl. Maybe that's
> triggering a preexisting bug?
The reason %rcx/%r11 are extra on the stack is because Xen uses sysret
to get here. This is part of the 64bit PV ABI.
%cs will be 0xe033 (FLAT_CS64) and %ss will be 0xe02b (FLAT_SS64).
I would expect it to kill opportunistic sysret, as Xen's and Linux's
idea of using sysret differ.
~Andrew
next prev parent reply other threads:[~2017-08-14 6:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-08 3:59 Andy Lutomirski
2017-08-09 15:39 ` Juergen Gross
2017-08-10 12:22 ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2017-08-14 2:44 ` [PATCH v2] " Brian Gerst
2017-08-14 5:53 ` Andy Lutomirski
2017-08-14 6:42 ` Andy Lutomirski
2017-08-14 6:45 ` Andrew Cooper [this message]
2017-08-14 12:46 ` Brian Gerst
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=ee0541ca-3986-7379-4fd9-b2a188b12841@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bpetkov@suse.de \
--cc=brgerst@gmail.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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®