From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbeAJBaM (ORCPT + 1 other); Tue, 9 Jan 2018 20:30:12 -0500 Received: from one.firstfloor.org ([193.170.194.197]:37602 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbeAJBaL (ORCPT ); Tue, 9 Jan 2018 20:30:11 -0500 Date: Tue, 9 Jan 2018 17:30:09 -0800 From: Andi Kleen To: Tom Lendacky Cc: Thomas Gleixner , Linus Torvalds , Andi Kleen , the arch/x86 maintainers , Linux Kernel Mailing List , David Woodhouse , Paul Turner , Andrew Lutomirski , Peter Zijlstra , Tim Chen , Greg Kroah-Hartman , Dave Hansen , Jiri Kosina , Andi Kleen Subject: Re: [PATCH] x86/retpoline: Fix NOSPEC_JMP for tip Message-ID: <20180110013009.5ysxlkuhczuv7uwg@two.firstfloor.org> References: <20180110003139.10531-1-andi@firstfloor.org> <184a65a3-6afe-4c82-7f7d-2c1d4a5198bc@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <184a65a3-6afe-4c82-7f7d-2c1d4a5198bc@amd.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 09, 2018 at 06:45:34PM -0600, Tom Lendacky wrote: > On 1/9/2018 6:40 PM, Thomas Gleixner wrote: > > On Tue, 9 Jan 2018, Linus Torvalds wrote: > > > >> On Tue, Jan 9, 2018 at 4:31 PM, Andi Kleen wrote: > >>> > >>> The following patch fixes it for me. Something doesn't > >>> seem to work with ALTERNATIVE_2. It adds only a few bytes > >>> more code, so seems acceptable. > >> > >> Ugh. It's kind of stupid, though. > >> > >> Why is the code sequence not simply: > >> > >> ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD > >> ALTERNATIVE __stringify(jmp *\reg), __stringify(RETPOLINE_JMP \reg), > >> X86_FEATURE_RETPOLINE > >> > >> ie make that X86_FEATURE_RETPOLINE_AMD _only_ emit the "lfence", and > >> simply fall through to what will be the "jmp *\reg" of the > >> non-RETPOLINE version. > >> > >> Then just make sure X86_FEATURE_RETPOLINE_AMD disables X86_FEATURE_RETPOLINE. > > I think there are areas that rely on X86_FEATURE_RETPOLINE being set > even if X86_FEATURE_RETPOLINE_AMD is set. For example, line 261 in > arch/x86/entry/entry_32.S is only checking for X86_FEATURE_RETPOLINE. I audited the difference places. They all seem ok. I assume you don't need FILL_RETURN_BUFFER on AMD. If not let me know and we can add a X86_FEATURE_RETPOLINE_COMMON -Andi