Received: by 10.213.65.68 with SMTP id h4csp466062imn; Fri, 16 Mar 2018 08:35:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELvgseULEiR+uHiB8bmFsqGAWN8LnJiQEJ8HoErP+bdZF7zj+Bz3YSw07LMWz0lUHLHyWhd3 X-Received: by 10.99.98.196 with SMTP id w187mr1833009pgb.307.1521214537249; Fri, 16 Mar 2018 08:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521214537; cv=none; d=google.com; s=arc-20160816; b=AebA4UAd/PrwdDUGnFMfn1dsCl78pwiJJ1Avz0GRGUvbI6scX8+dVAQenMX787Lajo 1WnHbBx5/zeOXnTw30BhuFyAHL7RTAQCEWj94TxHNMblhGVFIufGfaPKCBAybj2X+Uyo f9WL0VDvT+O5ja2XkpAgHwp+XV7jiBQLlBe9BT2kpJH0cNLxWcIumLYQZmRS+UkKzrgt 6bo+iBBtzDY4FFF/LGjwVrMS9fZH49Jb794TJ1l3C+V7ZIWyv5EPsRjeI+qazApBjQsP nqhYWcih2fNwKiu2idZ63IElIGYIhh1sJfwsZZTHyX2TEsqFrtywdvg+bmaKNLQhn9ey 59eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qzMM49WVtvNKOxoymm66Z/435RdUAseGVaip3wKfpCM=; b=ICkappSuFHVakBvd717vlFNsFt3X76UATQmFyndwRWeDZ1CwVlPVER3rx7OrLWGwmS e/5Tzaf1ZSvsfVT2Xn7vMWLgBQkRL9A0/EJcjTOKjQisxstO4baYKOtwBSoTnF5TUg6+ CZbQS1i0jG2P72O+GtTW0MS2NYo1RCSk3A7vgYyVsX3xuCY7ero39Tubt/gfPoQZoiWi hg/8A9QuirgysTrF40L9WgpwnjNykGh9ytD3tMHkymfbHC53Gp2rSN2qFXV/A63v3W06 LNsitPqUWQZUGV5khZ/O7XHXrjY30+4ocNC5xjPr0qvUaplO5EWAXOYmkCDw1EQ6iVUQ tSTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e23si5624151pfn.228.2018.03.16.08.35.22; Fri, 16 Mar 2018 08:35:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435AbeCPPds (ORCPT + 99 others); Fri, 16 Mar 2018 11:33:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39080 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933808AbeCPPdn (ORCPT ); Fri, 16 Mar 2018 11:33:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6ECD9D4F; Fri, 16 Mar 2018 15:33:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , David Woodhouse , Thomas Gleixner , Josh Poimboeuf , Andy Lutomirski , Arjan van de Ven , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Linus Torvalds , Ingo Molnar Subject: [PATCH 4.9 43/86] x86/speculation, objtool: Annotate indirect calls/jumps for objtool Date: Fri, 16 Mar 2018 16:23:06 +0100 Message-Id: <20180316152320.359267301@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra commit 9e0e3c5130e949c389caabc8033e9799b129e429 upstream. Annotate the indirect calls/jumps in the CALL_NOSPEC/JUMP_NOSPEC alternatives. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: David Woodhouse Acked-by: Thomas Gleixner Acked-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: Dave Hansen Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Linus Torvalds Cc: Peter Zijlstra Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/nospec-branch.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -68,6 +68,18 @@ .endm /* + * This should be used immediately before an indirect jump/call. It tells + * objtool the subsequent indirect jump/call is vouched safe for retpoline + * builds. + */ +.macro ANNOTATE_RETPOLINE_SAFE + .Lannotate_\@: + .pushsection .discard.retpoline_safe + _ASM_PTR .Lannotate_\@ + .popsection +.endm + +/* * These are the bare retpoline primitives for indirect jmp and call. * Do not use these directly; they only exist to make the ALTERNATIVE * invocation below less ugly. @@ -103,9 +115,9 @@ .macro JMP_NOSPEC reg:req #ifdef CONFIG_RETPOLINE ANNOTATE_NOSPEC_ALTERNATIVE - ALTERNATIVE_2 __stringify(jmp *\reg), \ + ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; jmp *\reg), \ __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE, \ - __stringify(lfence; jmp *\reg), X86_FEATURE_RETPOLINE_AMD + __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; jmp *\reg), X86_FEATURE_RETPOLINE_AMD #else jmp *\reg #endif @@ -114,9 +126,9 @@ .macro CALL_NOSPEC reg:req #ifdef CONFIG_RETPOLINE ANNOTATE_NOSPEC_ALTERNATIVE - ALTERNATIVE_2 __stringify(call *\reg), \ + ALTERNATIVE_2 __stringify(ANNOTATE_RETPOLINE_SAFE; call *\reg), \ __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE,\ - __stringify(lfence; call *\reg), X86_FEATURE_RETPOLINE_AMD + __stringify(lfence; ANNOTATE_RETPOLINE_SAFE; call *\reg), X86_FEATURE_RETPOLINE_AMD #else call *\reg #endif @@ -144,6 +156,12 @@ ".long 999b - .\n\t" \ ".popsection\n\t" +#define ANNOTATE_RETPOLINE_SAFE \ + "999:\n\t" \ + ".pushsection .discard.retpoline_safe\n\t" \ + _ASM_PTR " 999b\n\t" \ + ".popsection\n\t" + #if defined(CONFIG_X86_64) && defined(RETPOLINE) /* @@ -153,6 +171,7 @@ # define CALL_NOSPEC \ ANNOTATE_NOSPEC_ALTERNATIVE \ ALTERNATIVE( \ + ANNOTATE_RETPOLINE_SAFE \ "call *%[thunk_target]\n", \ "call __x86_indirect_thunk_%V[thunk_target]\n", \ X86_FEATURE_RETPOLINE)