From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753262AbeAIJjN (ORCPT + 1 other); Tue, 9 Jan 2018 04:39:13 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:56522 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752950AbeAIJiV (ORCPT ); Tue, 9 Jan 2018 04:38:21 -0500 Date: Tue, 9 Jan 2018 10:37:56 +0100 From: Peter Zijlstra To: Andi Kleen Cc: dwmw2@infradead.org, pjt@google.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, gregkh@linux-foundation.org, tim.c.chen@linux.intel.com, dave.hansen@intel.com, tglx@linutronix.de, luto@amacapital.net, Andi Kleen Subject: Re: [PATCH] x86/retpoline: Also fill return buffer after idle Message-ID: <20180109093756.GF6176@hirez.programming.kicks-ass.net> References: <20180108235126.28736-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180108235126.28736-1-andi@firstfloor.org> 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 Mon, Jan 08, 2018 at 03:51:26PM -0800, Andi Kleen wrote: > @@ -107,8 +109,15 @@ static inline void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) > } > > __monitor((void *)¤t_thread_info()->flags, 0, 0); > - if (!need_resched()) > + if (!need_resched()) { > __mwait(eax, ecx); > + /* > + * idle could have cleared the return buffer, > + * so fill it to prevent uncontrolled > + * speculation. > + */ > + fill_return_buffer(); wouldn't something like: if (static_cpu_has(X86_FEATURE_RETPOLINE)) fill_return_buffer(); be much saner? Then we avoid the entire call when not needed and you don't have to muck with the asm either. Also, you forgot mwait_idle() in process.c > + } > } > current_clr_polling(); > } > -- > 2.14.3 >