Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933129AbeAHW0Z (ORCPT + 1 other); Mon, 8 Jan 2018 17:26:25 -0500 Received: from merlin.infradead.org ([205.233.59.134]:57386 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754900AbeAHW0X (ORCPT ); Mon, 8 Jan 2018 17:26:23 -0500 Date: Mon, 8 Jan 2018 23:26:04 +0100 From: Peter Zijlstra To: "Woodhouse, David" Cc: "andi@firstfloor.org" , "linux-kernel@vger.kernel.org" , "tim.c.chen@linux.intel.com" , "tglx@linutronix.de" , "ak@linux.intel.com" , "pjt@google.com" , "dave.hansen@intel.com" , "luto@amacapital.net" , "gregkh@linux-foundation.org" Subject: Re: [PATCH] x86/retpoline: Avoid return buffer underflows on context switch Message-ID: <20180108222604.GW29822@worktop.programming.kicks-ass.net> References: <20180108201531.6782-1-andi@firstfloor.org> <20180108221121.GU29822@worktop.programming.kicks-ass.net> <1515449839.4423.37.camel@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1515449839.4423.37.camel@amazon.co.uk> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 10:17:19PM +0000, Woodhouse, David wrote: > On Mon, 2018-01-08 at 23:11 +0100, Peter Zijlstra wrote: > > > > So pjt did alignment, a single unroll and per discussion earlier today > > (CET) or late last night (PST), he only does 16. > > Hey Intel, please tell us precisely how many RSB entries there are, on > each family of CPU... :) Right, and we can always fall back to 32 for unknown models. > > Also, pause is unlikely to stop speculation, that comment doesn't make > > sense. Looking at PJT's version there used to be a speculation trap in > > there, but I can't see that here. > > In this particular code we don't need a speculation trap; that's > elsewhere. This one is *just* about the call stack. And the reason we > don't just have... > > ?call . + 5 > ?call . + 5 > ?call . + 5 > ?... > > is because that might get interpreted as a "push %rip" and not go on > the RSB at all. Hence the 'pause' between each one. OK, then make the comment say that.