From: Tim Chen <tim.c.chen@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>, Andy Lutomirski <luto@kernel.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>,
LKML <linux-kernel@vger.kernel.org>,
KarimAllah Ahmed <karahmed@amazon.de>,
Andi Kleen <ak@linux.intel.com>,
Andrea Arcangeli <aarcange@redhat.com>,
Ashok Raj <ashok.raj@intel.com>,
Asit Mallick <asit.k.mallick@intel.com>,
Borislav Petkov <bp@suse.de>,
Dan Williams <dan.j.williams@intel.com>,
Dave Hansen <dave.hansen@intel.com>,
David Woodhouse <dwmw@amazon.co.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"H . Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>,
Joerg Roedel <joro@8bytes.org>,
Jun Nakajima <jun.nakajima@intel.com>,
Laura Abbott <labbott@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Radim Krcmar <rkrcmar@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Tom Lendacky <thomas.lendacky@amd.com>, X86 ML <x86@kernel.org>
Subject: Re: [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process
Date: Thu, 25 Jan 2018 11:32:46 -0800 [thread overview]
Message-ID: <aa7cfe53-d8ee-9f56-a5c7-775d878cee15@linux.intel.com> (raw)
In-Reply-To: <20180125181852.GL2249@hirez.programming.kicks-ass.net>
On 01/25/2018 10:18 AM, Peter Zijlstra wrote:
> On Thu, Jan 25, 2018 at 09:04:21AM -0800, Andy Lutomirski wrote:
>> I haven't tried to fully decipher the patch, but I think the idea is
>> wrong. (I think it's the same wrong idea that Rik and I both had and
>> that I got into Linus' tree for a while...) The problem is that it's
>> not actually correct to run indefinitely in kernel mode using stale
>> cached page table data. The stale PTEs themselves are fine, but the
>> stale intermediate translations can cause the CPU to speculatively
>> load complete garbage into the TLB, and that's bad (and causes MCEs on
>> AMD CPUs).
>
> Urggh.. indeed :/
>
>> I think we only really have two choices: tlb_defer_switch_to_init_mm()
>> == true and tlb_defer_switch_to_init_mm() == false. The current
>> heuristic is to not defer if we have PCID, because loading CR3 is
>> reasonably fast.
>
> I just _really_ _really_ hate idle drivers doing leave_mm(). I don't
> suppose limiting the !IPI case to just the idle case would be correct
> either, because between waking from idle and testing our 'should I have
> invalidated' bit it can (however unlikely) speculate into stale TLB
> entries too..
>
>
Peter,
This patch is not ideal as it comes with the caveats that
patch 2 tries to close. I put it out here to see if it can prompt
people to come up with a better solution. Keeping active_mm around would
have been cleaner but it looks like there are issues that Andy mentioned.
The "A -> idle -> A" case would not trigger IBPB if tlb_defer_switch_to_init_mm()
is true (non pcid) as we does not change the mm.
This patch tries to address the case when we do switch to init_mm and back.
Do you still have objections to the approach in this patch
to save the last active mm before switching to init_mm?
Tim
next prev parent reply other threads:[~2018-01-25 19:32 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-25 0:36 [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process Tim Chen
2018-01-25 0:36 ` [RFC PATCH 2/2] x86/ibpb: Prevent missed IBPB flush Tim Chen
2018-01-25 8:20 ` David Woodhouse
2018-01-25 16:56 ` Tim Chen
2018-01-25 8:58 ` [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process Peter Zijlstra
2018-01-25 9:22 ` Peter Zijlstra
2018-01-25 13:21 ` Arjan van de Ven
2018-01-25 13:50 ` Peter Zijlstra
2018-01-25 14:07 ` Arjan van de Ven
2018-01-25 16:41 ` Peter Zijlstra
2018-01-25 17:04 ` Andy Lutomirski
2018-01-25 18:18 ` Peter Zijlstra
2018-01-25 19:32 ` Tim Chen [this message]
2018-01-25 19:34 ` Arjan van de Ven
2018-01-25 19:45 ` Dave Hansen
2018-01-25 20:46 ` Peter Zijlstra
2018-01-25 21:04 ` Andy Lutomirski
2018-01-25 21:57 ` Andi Kleen
2018-01-25 22:01 ` Andy Lutomirski
2018-01-25 23:07 ` Tim Chen
2018-01-26 0:01 ` Peter Zijlstra
2018-01-25 17:24 ` Arjan van de Ven
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=aa7cfe53-d8ee-9f56-a5c7-775d878cee15@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=Janakarajan.Natarajan@amd.com \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=arjan@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=asit.k.mallick@intel.com \
--cc=bp@suse.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=joro@8bytes.org \
--cc=jun.nakajima@intel.com \
--cc=karahmed@amazon.de \
--cc=labbott@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=torvalds@linux-foundation.org \
--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 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.