From: David Laight <David.Laight@ACULAB.COM>
To: 'Brian Gerst' <brgerst@gmail.com>
Cc: Andy Lutomirski <luto@kernel.org>, X86 ML <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>, "H . Peter Anvin" <hpa@zytor.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
"Oleg Nesterov" <oleg@redhat.com>
Subject: RE: [PATCH] x86: Remove force_iret()
Date: Fri, 20 Dec 2019 12:35:27 +0000 [thread overview]
Message-ID: <e7ad139dcf5b4025b516eb147cba79fa@AcuMS.aculab.com> (raw)
In-Reply-To: <CAMzpN2i+DrKkzDyiS6Cj61LmCu+--e5puQpKrNxYVMDRPMvvBw@mail.gmail.com>
From: Brian Gerst
> Sent: 20 December 2019 12:18
...
> > Is it ever possible for any of the segment registers to refer to the LDT
> > and for another thread to invalidate the entries 'very late' ?
> > So even though the values were valid when changed, they are
> > invalid during the 'return to user' sequence.
>
> Not in the SYSRET case, where the kernel requires that CS and SS are
> static segments in the GDT. Any userspace context that uses LDT
> segments for CS/SS must return with IRET. There is fault handling for
> IRET (fixup_bad_iret()) for this case.
Ok - It is a long time since i looked at these 'syscall' instructions.
...
> > Is it actually cheaper to properly validate the segment registers,
> > or take the 'hit' of the slightly slower IRET path and get the cpu
> > to do it for you?
>
> SYSRET is faster because it avoids segment table lookups and
> permission checks for CS and SS. It simply sets the selectors to
> values set in an MSR and the attributes (base, limit, etc.) to fixed
> values. It is up to the OS to make sure the actual segment
> descriptors in memory match those default attributes.
I wonder how much difference that make when 'page table separation'
is used?
I guess the loading of ds/es/fs/gs can fault - but that it no harder
to handle than in the IRET case.
David
Anyway, off until the new year now.
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2019-12-20 12:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-19 11:58 [PATCH] x86: Remove force_iret() Brian Gerst
2019-12-20 1:49 ` Andy Lutomirski
2019-12-20 3:48 ` Brian Gerst
2019-12-20 10:10 ` David Laight
2019-12-20 10:30 ` Andy Lutomirski
2019-12-20 10:59 ` David Laight
2019-12-20 21:20 ` Andy Lutomirski
2019-12-20 12:18 ` Brian Gerst
2019-12-20 12:35 ` David Laight [this message]
2019-12-20 19:35 ` Oleg Nesterov
2020-01-08 20:30 ` [tip: x86/asm] " tip-bot2 for 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=e7ad139dcf5b4025b516eb147cba79fa@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=boris.ostrovsky@oracle.com \
--cc=brgerst@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=x86@kernel.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).