Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964878AbeAJC2p (ORCPT + 1 other); Tue, 9 Jan 2018 21:28:45 -0500 Received: from mga14.intel.com ([192.55.52.115]:47271 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964817AbeAJC2m (ORCPT ); Tue, 9 Jan 2018 21:28:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,337,1511856000"; d="scan'208";a="20352201" From: Andi Kleen To: tglx@linutronix.de Cc: x86@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com, luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com, tim.c.chen@linux.intel.com, gregkh@linux-foundation.org, dave.hansen@intel.com, jikos@kernel.org, Andi Kleen Subject: [PATCH v3 2/3] x86/retpoline: Use better sequences for NOSPEC_CALL/JMP Date: Tue, 9 Jan 2018 18:28:30 -0800 Message-Id: <20180110022831.29826-3-andi@firstfloor.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180110022831.29826-1-andi@firstfloor.org> References: <20180110022831.29826-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Andi Kleen [This fixes a boot failure in the earlier patches so may want to be moved earlier to keep git bisect happy] With the latest tip x86/pti I get oopses when booting a 64bit VM in qemu with RETPOLINE/gcc7 and PTI enabled. Something is wrong with the ALTERNATIVE_2 sequence used in NOSPEC_JMP Linus suggested a better sequence that is shorter and simpler and avoids the problem. It requires excluding X86_FEATURE_RETPOLINE and X86_FEATURE_RETPOLINE_AMD, but that has been done in the previous patch. Use the new sequence for NOSPEC_CALL and NOSPEC_JMP. v2: Use new sequence for CALL/RET. Add extra patch for _COMMON. v3: Use RETPOLINE_GENERIC for Intel Fixes: ce004e1cb ("x86/retpoline: Add initial retpoline") Fixes: f3433c101 ("x86/retpoline/entry: Convert entry") Suggested-by: Linus Torvalds Signed-off-by: Andi Kleen --- arch/x86/include/asm/nospec-branch.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 8ddf8513550e..dc13325a9890 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -46,9 +46,8 @@ */ .macro JMP_NOSPEC reg:req #ifdef CONFIG_RETPOLINE - ALTERNATIVE_2 __stringify(jmp *\reg), \ - __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE, \ - __stringify(lfence; jmp *\reg), X86_FEATURE_RETPOLINE_AMD + ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD + ALTERNATIVE __stringify(jmp *\reg), __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE_GENERIC #else jmp *\reg #endif @@ -56,9 +55,8 @@ .macro CALL_NOSPEC reg:req #ifdef CONFIG_RETPOLINE - ALTERNATIVE_2 __stringify(call *\reg), \ - __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE,\ - __stringify(lfence; call *\reg), X86_FEATURE_RETPOLINE_AMD + ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD + ALTERNATIVE __stringify(call *\reg), __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE_GENERIC #else call *\reg #endif -- 2.14.3