All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"linux-tip-commits@vger.kernel.org" 
	<linux-tip-commits@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Denys Vlasenko <dvlasenk@redhat.com>
Subject: Re: [tip:x86/urgent] x86/entry/32: Add an ASM_CLAC to entry_SYSENTER_32
Date: Thu, 25 Feb 2016 11:52:51 -0800	[thread overview]
Message-ID: <CALCETrWTU6LZn+j=Nz_mkDyjaLkPhFLcpjk7Zc2TGotPoUn0Vw@mail.gmail.com> (raw)
In-Reply-To: <CAMzpN2jqP74br2+pSP-X_WCpRTgK4Q6eV4N2_ZWCLkw9u4symQ@mail.gmail.com>

On Thu, Feb 25, 2016 at 11:49 AM, Brian Gerst <brgerst@gmail.com> wrote:
> On Thu, Feb 25, 2016 at 2:39 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>> On Thu, Feb 25, 2016 at 11:31 AM, Brian Gerst <brgerst@gmail.com> wrote:
>>> On Thu, Feb 25, 2016 at 1:30 PM, Linus Torvalds
>>> <torvalds@linux-foundation.org> wrote:
>>>> On Thu, Feb 25, 2016 at 10:20 AM, Andy Lutomirski <luto@amacapital.net> wrote:
>>>>>
>>>>> Ideally we'd fix this up and restore flags on sysexit.  At least
>>>>> failing to restore arithmetic flags isn't an info leak because the
>>>>> exit code clobbers them with entirely predictable data.  I doubt
>>>>> anyone cares all that much if we clobber AC.
>>>>
>>>> As long as the "clobber AC" is purely about clearing it, it's probably fine.
>>>>
>>>> Although there may be programs that set AC in order to actually get
>>>> notified about alignment issues (perhaps for portability reasons,
>>>> perhaps for small performance reasons). Clearing it will make those
>>>> programs still work, but they lose the checking.
>>>>
>>>>> I wrote a test for NT and the test fails for a different reason: our
>>>>> TF handling appears broken as well.  (Our sysenter TF handling is
>>>>> *crap*, but it seems to work on 64-bit kernels at least.)
>>>>
>>>> TF should be entirely immaterial for system calls. Why would we care?
>>>> We need it for correct handling of real traps, but not for the system
>>>> call case afaik. Returning with TF clear is the right thing, since
>>>> we're not returning *to* the system call instruction, but the
>>>> instruction after.
>>>>
>>>>> My personal preference would be to add the missing popf.
>>>>
>>>> I don't mind adding the popf, but it won't help for iopl. Only iret
>>>> restores iopl, if I recall correctly (but maybe I don't, and I'm too
>>>> lazy to take the 30 seconds to look it up).
>>>>
>>>>                Linus
>>>
>>> According to the SDM, popf will change IOPL only at CPL0, which is why
>>> Xen (which runs at CPL1 on 32-bit) has a paravirt hook for it.
>>
>> But maybe we can ditch that paravirt hook and just modify regs->flags
>> in sys_iopl.  Xen never uses sysexit at all:
>>
>>     /* XEN PV guests always use IRET path */
>>     ALTERNATIVE "testl %eax, %eax; jz .Lsyscall_32_done", \
>>             "jmp .Lsyscall_32_done", X86_FEATURE_XENPV
>>
>> and if we add the missing popf, we should be good to go.
>
> IRET won't change IOPL either at CPL != 0, so Xen still needs that hook.

But xen_iret isn't the same thing as IRET at all.  We don't use a real
IRET instruction to switch between kernel and user mode on Xen PV.

--Andy

>
> --
> Brian Gerst



-- 
Andy Lutomirski
AMA Capital Management, LLC

  reply	other threads:[~2016-02-25 19:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 21:19 [PATCH] x86/entry/32: Add an ASM_CLAC to entry_SYSENTER_32 Andy Lutomirski
2016-02-24 15:46 ` Brian Gerst
2016-02-24 16:56   ` Andy Lutomirski
2016-02-25  5:53 ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2016-02-25  6:00   ` H. Peter Anvin
2016-02-25  8:07     ` Andy Lutomirski
2016-02-25  8:11       ` Andy Lutomirski
2016-02-25  8:14       ` Ingo Molnar
2016-02-25  8:29         ` Mike Galbraith
2016-02-25  8:40           ` Ingo Molnar
2016-02-25  9:08             ` Mike Galbraith
     [not found]     ` <CALCETrWqCnhxvQ5qNp_O_7K7KW1H3FmHiX=mp+C5oeBEx=3YVA@mail.gmail.com>
2016-02-25 13:47       ` Brian Gerst
2016-02-25 15:42         ` Brian Gerst
2016-02-25 18:20           ` Andy Lutomirski
2016-02-25 18:30             ` Linus Torvalds
2016-02-25 18:40               ` Andy Lutomirski
2016-02-25 19:31               ` Brian Gerst
2016-02-25 19:39                 ` Andy Lutomirski
2016-02-25 19:49                   ` Brian Gerst
2016-02-25 19:52                     ` Andy Lutomirski [this message]
2016-02-25 20:54                 ` Linus Torvalds

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='CALCETrWTU6LZn+j=Nz_mkDyjaLkPhFLcpjk7Zc2TGotPoUn0Vw@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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 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.