Received: by 10.223.176.46 with SMTP id f43csp2471385wra; Thu, 25 Jan 2018 10:19:48 -0800 (PST) X-Google-Smtp-Source: AH8x226IJ8VBSMcRh1MzKf2nMuv69TWd9asBwGaiTw+JCGaM3qfWpSWjlMUMIG32kilq1gQH3t5r X-Received: by 10.101.73.203 with SMTP id t11mr14106675pgs.48.1516904388459; Thu, 25 Jan 2018 10:19:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516904388; cv=none; d=google.com; s=arc-20160816; b=Tk3pjXYYzXO/RKQ8Bd10xkGmX7bbhl+fBbcdDEuwk9puf1YMN7Wp71B2mHktVI673m FqZi1mB+Xz0Hufob30xt/Ma7j+okRCTRoab8eIzhWeVCbQ0NLRNHlcizaHFIvtm1saqO fEz9asnGelhARuGW+ieKRZ7ZS8mfSdEuiJSILp36kt/6x0VPvO8tGw+s4C5h6YVhguZM 66p5FP60zWznqIF4mROJA77DGWnaNrFfcPaNOtkbvHF9f8AhRFVHE2z6ynnTps2iNwU0 /0Yqw4qs4gNiB0ICpgvX/2lKEcivYcC6Jivav+4XqsBc0jHVEgS/Wm6rt1iIgb6gdS3P KtJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender: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=XU23K6h91Sgkl1G3UMjISUVm1txQF+Sk5bF9jz3FkYjBXOSyzu9iadaJCWtHJetMe/ BW68az3DVvjZXg0P5RmmEAgBhB81v5xG6x0zMXjqZqfqMy5LxWfE3LhZrPYhCekNLIm0 BdRGffq9ZfuJ8ZBGtzyvzUR6Y00fEnTogQqWjp1pwgSCxrfu8XsB9U/r24lPJ+Ei8QN3 Djbrk1akfhMdZ2Nsp4r7P4DoGFvZacB9ZOPXPEIB2FKIFn2SZNaafTggS9omevXL4oK0 ve3bKiSScW/hqlZDF9PYRx7mAKeiW5GLlmROP1hLmoehUeo9XnsLmkNIswaxLTTbAWDU cHqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=R1YLS8+A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si4973863pfs.2.2018.01.25.10.19.33; Thu, 25 Jan 2018 10:19:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=R1YLS8+A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751204AbeAYSTK (ORCPT + 99 others); Thu, 25 Jan 2018 13:19:10 -0500 Received: from merlin.infradead.org ([205.233.59.134]:36832 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750994AbeAYSTJ (ORCPT ); Thu, 25 Jan 2018 13:19:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vI1rwdNtDYz0On2pzZ/tLSf+3M73hseWGO2Bt9M/LDk=; b=R1YLS8+AX77Dd1tvHt6HdJWLE SsHAeXWMow+HXdYcF1uO4GSoNtElCL6fKLMxeFT/Tij2rnu+VLQPka5VnKQcyV8yuFzxVuJ1Dra+l 2KUb6uOO9HvQWw69+1GWkBZaKY/O80JCbSjFJWdVK4XX6LC1Af+y+kJoypOcjN6QN5/AW+gfjppmY 7PY5wCMp+1LHg5ic8jE+59q/KcRtMePAsqvIOU614ztBQIJwOQIlwdHW6NhuRqItNokyFu8glaOts 4aB1JFKTAwYs16INOnsFrjLiYl3Hna4prEei6F65+2lfwA7FN1816HuTa6kzy7KBEubu8y+SYHJ6S BhC/cyexQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eem6x-00087F-BP; Thu, 25 Jan 2018 18:18:55 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7EDB92029B117; Thu, 25 Jan 2018 19:18:52 +0100 (CET) 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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..