Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932966AbeAKJ6p (ORCPT + 1 other); Thu, 11 Jan 2018 04:58:45 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:55308 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932362AbeAKJ6o (ORCPT ); Thu, 11 Jan 2018 04:58:44 -0500 Date: Thu, 11 Jan 2018 10:58:30 +0100 From: Peter Zijlstra To: Borislav Petkov Cc: "Woodhouse, David" , "Thomas.Lendacky@amd.com" , "linux-kernel@vger.kernel.org" , "tim.c.chen@linux.intel.com" , "Ghitulete, Razvan-alin" , "torvalds@linux-foundation.org" , "tglx@linutronix.de" , "ak@linux.intel.com" , "x86@kernel.org" , "riel@redhat.com" , "keescook@google.com" , "gnomes@lxorguk.ukuu.org.uk" , "pjt@google.com" , "dave.hansen@intel.com" , "luto@amacapital.net" , "jikos@kernel.org" , "gregkh@linux-foundation.org" Subject: Re: [PATCH] x86/retpoline: Fill return stack buffer on vmexit Message-ID: <20180111095830.GY6176@hirez.programming.kicks-ass.net> References: <1515624682-3556-1-git-send-email-dwmw@amazon.co.uk> <5371f9a0-f221-af1f-641f-05e4d0991847@linux.intel.com> <1515629074.22302.282.camel@amazon.co.uk> <20180111084238.GT6176@hirez.programming.kicks-ass.net> <1F5F831F-0C4B-4DA9-8A48-D0D1C1ADC0D7@alien8.de> <1515661628.22302.294.camel@amazon.co.uk> <20180111093231.GX6176@hirez.programming.kicks-ass.net> <20180111094759.aohvm5tqztza72es@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180111094759.aohvm5tqztza72es@pd.tnic> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 11, 2018 at 10:47:59AM +0100, Borislav Petkov wrote: > On Thu, Jan 11, 2018 at 10:32:31AM +0100, Peter Zijlstra wrote: > > can't you do lovely things like: > > > > volatile asm ("call __fill_rsb_thunk_%1" : : "r" (dummy)) > > > > which would still let gcc select the register ? > > Calling a function from asm is nasty because you need to pay attention > to clobbered registers as gcc doesn't see the function. The point is that this is an asm function, much like the retpoline thunks, replicated for each register. And by stuffing the register in the function name and using a dummy argument you let GCC pick which register to clobber. Heck we could even pass in the actual stuff-count instead of treating it as a pure dummy.