From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224A38+tODB5PMbi2Fiy7aR4qko85ME0HTVikEI02pMEkQ3SKI0BSRK88mCSgiFXRfcAaAOm ARC-Seal: i=1; a=rsa-sha256; t=1516904348; cv=none; d=google.com; s=arc-20160816; b=t8dVBA58Rm7KpKol1LQt97H+JMN99BTfhC+FkjzDtIPa0to0MSmlsrc+1Rr1AahsvF D6fAi82Xb3lPClQUcNk1ZB7jixKuAQXCID5jMR1qibviBQyvg2ca/Ug4a0R6b2zwKteC w3mSEYFgj/W05Z0h2BsSc2Il9qouMObj0x2BCaUy2vYWyGVgw9ulv8nQMq4yV7sa2wU2 92OijM4eoL+SbLgm+Z/9IRhXwLaQX0R/T0w5Y5J6gJs/DZIDoo8XqLGJh6NaZ3B/aVro TmThBB4k+2DHHTwLY5l/ViEC5ZZJTDKRBlWvFKM+EPteywP8jNXUJT4Crg6eDyhP4Ym5 UCIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=vI1rwdNtDYz0On2pzZ/tLSf+3M73hseWGO2Bt9M/LDk=; b=rDfTYL83z+g3EXObPNHVhdR5KzPp5k3pAqHSoRTfMick/nFMOpDtD7ZedWMh2NKJ6O rzHJdoSXOj1t/EHvd0U0SoNAc3nKiN+IDPqY0uHNdlaEtXA5YpUwYuTEmNT9Zgr6VFk2 hmPC2t2SPhzzjsUldDFXiHprcIhzA6dEPnuK8OV4BGB7Lx9Fs3mbepbQihNighdVmvqV MFLlehUHCWn/3rybShfDRThbr6zFtrx3gXjMnFplHxk6P9M3Qkmw3e4O1okMMMaf0/9a Ewl5kozmHBn+OpCrpI+scjcGEMZfzhED/uJxHmRWSFnxzOIWmbEfC0UtsnVwYpBYmybV DaRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=R1YLS8+A; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=R1YLS8+A; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Date: Thu, 25 Jan 2018 19:18:52 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Arjan van de Ven , Tim Chen , LKML , KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Radim Krcmar , Thomas Gleixner , Tom Lendacky , X86 ML Subject: Re: [RFC PATCH 1/2] x86/ibpb: Skip IBPB when we switch back to same user process Message-ID: <20180125181852.GL2249@hirez.programming.kicks-ass.net> References: <20180125085820.GV2228@hirez.programming.kicks-ass.net> <20180125092233.GE2295@hirez.programming.kicks-ass.net> <86541aca-8de7-163d-b620-083dddf29184@linux.intel.com> <20180125135055.GK2249@hirez.programming.kicks-ass.net> <20180125164139.GM2269@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590523944221221739?= X-GMAIL-MSGID: =?utf-8?q?1590589493699623450?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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..