From: Ingo Molnar <mingo@kernel.org>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
Brian Gerst <brgerst@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 2/4] x86/asm/entry: Untangle 'ia32_sysenter_target' into two entry points: entry_SYSENTER_32 and entry_SYSENTER_compat
Date: Tue, 9 Jun 2015 11:33:14 +0200 [thread overview]
Message-ID: <20150609093314.GA9675@gmail.com> (raw)
In-Reply-To: <CALCETrVFtGO5utiTffa7XLLWiBt6iPBe9WoQX73pbFOD-UnmUg@mail.gmail.com>
* Andy Lutomirski <luto@amacapital.net> wrote:
> On Mon, Jun 8, 2015 at 1:34 AM, Ingo Molnar <mingo@kernel.org> wrote:
> > So the SYSENTER instruction is pretty quirky and it has different behavior
> > depending on bitness and CPU maker.
> >
> > Yet we create a false sense of coherency by naming it 'ia32_sysenter_target'
> > in both of the cases.
> >
> > Split the name into its two uses:
> >
> > ia32_sysenter_target (32) -> entry_SYSENTER_32
> > ia32_sysenter_target (64) -> entry_SYSENTER_compat
> >
>
> Now that I'm rebasing my pile on top of this, I have a minor gripe
> about this one. There are (in my mind, anyway), two SYSENTER
> instructions: the 32-bit one and the 64-bit one. (That is, there's
> SYSENTER32, which happens when you do SYSENTER in 32-bit or compat
> mode, and SYSENTER64, which happens when you do SYSENTER in long
> mode.) SYSENTER32, from user code's perspective, does the same thing
> in either case [1]. That means that it really does make sense that
> we'd have two implementations of the same entry point, one written in
> 32-bit asm and one written in 64-bit asm.
>
> The patch I'm rebasing merges the two wrmsrs to MSR_IA32_SYSENTER, and
> this change makes it uglier.
>
> [1] Sort of. We probably have differently nonsensical calling
> conventions, but that's our fault and has nothing to do with the
> hardware.
Did you intend to merge these two wrmsr()s:
#ifdef CONFIG_X86_64
void syscall_init(void)
{
...
wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat);
...
}
#endif
#ifdef CONFIG_X86_32
void enable_sep_cpu(void)
{
...
wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
...
}
... and the new bifurcated names preserve the #ifdef, right?
So I mostly agree with you, but still I'm a bit torn about this, for the following
reason:
- SYSENTER on a 32-bit kernel behaves a bit differently from SYSENTER on a 64-bit
kernel: for example on 32-bit kernels we'll return with SYSEXIT, while on
64-bit kernels we return with SYSRET. The difference is small but user-space
observable: for example EDX is 0 on SYSRET while it points to ->sysenter_return
in the SYSEXIT case.
This kind of user-observable assymmetry does not exist for other unified syscall
ABIs, such as the INT80 method.
So I think that despite having to preserve a small non-unified #ifdef for this
initialization, we are still better off naming the two entry points differently,
along the pattern we use, because the behavior is slightly different depending on
the bitness of the kernel.
Thanks,
Ingo
next prev parent reply other threads:[~2015-06-09 9:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-08 8:34 [PATCH 0/4] x86: Untangle and standardize x86 system call entry point names Ingo Molnar
2015-06-08 8:34 ` [PATCH 1/4] x86/asm/entry: Rename compat syscall entry points Ingo Molnar
2015-06-08 8:47 ` Borislav Petkov
2015-06-08 8:34 ` [PATCH 2/4] x86/asm/entry: Untangle 'ia32_sysenter_target' into two entry points: entry_SYSENTER_32 and entry_SYSENTER_compat Ingo Molnar
2015-06-09 0:13 ` Andy Lutomirski
2015-06-09 9:33 ` Ingo Molnar [this message]
2015-06-09 16:33 ` Andy Lutomirski
2015-06-08 8:35 ` [PATCH 3/4] x86/asm/entry: Untangle 'system_call' into two entry points: entry_SYSCALL_64 and entry_INT80_32 Ingo Molnar
2015-06-08 8:35 ` [PATCH 4/4] x86/asm/entry/32: Clean up entry_32.S Ingo Molnar
2015-06-08 13:14 ` Denys Vlasenko
2015-06-08 18:51 ` [PATCH] x86/asm/entry/64: Clean up entry_64.S Ingo Molnar
2015-07-06 15:00 ` Sasha Levin
2015-07-06 16:07 ` Ingo Molnar
2015-07-06 16:19 ` Sasha Levin
2015-07-06 16:23 ` Ingo Molnar
2015-07-06 16:36 ` Sasha Levin
2015-07-06 16:43 ` Ingo Molnar
2015-07-06 17:02 ` Sasha Levin
2015-07-06 17:20 ` Andy Lutomirski
2015-07-06 17:34 ` Sasha Levin
2015-07-06 17:41 ` Ingo Molnar
2015-07-06 18:35 ` Andy Lutomirski
2015-07-06 18:39 ` Andy Lutomirski
2015-07-08 15:39 ` Sasha Levin
2015-07-07 7:01 ` Ingo Molnar
2015-07-09 0:59 ` Andy Lutomirski
2015-07-10 13:27 ` Sasha Levin
2015-07-10 15:26 ` Andrey Ryabinin
2015-07-10 15:36 ` Andy Lutomirski
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=20150609093314.GA9675@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).