Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030360AbeAORiE (ORCPT + 1 other); Mon, 15 Jan 2018 12:38:04 -0500 Received: from smtp.eu.citrix.com ([185.25.65.24]:2323 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030320AbeAORiD (ORCPT ); Mon, 15 Jan 2018 12:38:03 -0500 X-IronPort-AV: E=Sophos;i="5.46,364,1511827200"; d="scan'208";a="66081349" Subject: Re: Improve retpoline for Skylake To: Andy Lutomirski , Jon Masters CC: Henrique de Moraes Holschuh , Andi Kleen , David Woodhouse , , , , , , , , , References: <20180112184550.6573-1-andi@firstfloor.org> <1515784373.22302.492.camel@infradead.org> <20180112192126.su2evwfefdfeaa6g@two.firstfloor.org> <20180112220349.7dorb3lde4tffsjm@khazad-dum.debian.net> <985f979e-0740-5d8a-d6b8-b023105aa021@jonmasters.org> From: Andrew Cooper Message-ID: <445ec6c6-a835-fbdc-dca3-222a73d19816@citrix.com> Date: Mon, 15 Jan 2018 17:38:01 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 15/01/18 16:57, Andy Lutomirski wrote: > >> On Jan 15, 2018, at 12:26 AM, Jon Masters wrote: >> >>> On 01/12/2018 05:03 PM, Henrique de Moraes Holschuh wrote: >>> On Fri, 12 Jan 2018, Andi Kleen wrote: >>>>> Skylake still loses if it takes an SMI, right? >>>> SMMs are usually rare, especially on servers, and are usually >>>> not very predictible, and even if you have >>> FWIW, a data point: SMIs can be generated on demand by userspace on >>> thinkpad laptops, but they will be triggered from within a kernel >>> context. I very much doubt this is a rare pattern... >> Sure. Just touch some "legacy" hardware that the vendor emulates in a >> nasty SMI handler. It's definitely not acceptable to assume that SMIs >> can't be generated under the control of some malicious user code. >> >> Our numbers on Skylake weren't bad, and there seem to be all kinds of >> corner cases, so again, it seems as if IBRS is the safest choice. >> > And keep in mind that SMIs generally hit all CPUs at once, making them extra nasty. > > Can we get firmware vendors to refill the return buffer just before RSM? Refill or not, you are aware that a correctly timed SMI in a leaf function will cause the next ret to speculate into userspace, because there is guaranteed peturbance in the RSB?  (On the expectation that the SMM handler isn't entirely devoid of function calls). Having firmware refill the RSB only makes a difference if you are on Skylake+ were RSB underflows are bad, and you're not using IBRS to protect your indirect predictions. ~Andrew