Received: by 10.213.65.68 with SMTP id h4csp458173imn; Tue, 13 Mar 2018 09:41:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELu1YvCD9SYXzf3/hVDiXmPgFhqWsBtIPP0aq8smlAVCjThLM3vfWddVzEQmDxUpU6uh9+5L X-Received: by 10.99.120.5 with SMTP id t5mr1012180pgc.156.1520959294396; Tue, 13 Mar 2018 09:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520959294; cv=none; d=google.com; s=arc-20160816; b=DRX3XVV9OcM83v0tkBwoTeb3wOz4h3laXf6YTQO2PbWMS8RmWHFRLoTGDK7/uLCHX0 cptBL4fV+b1GCZyW6mFmFntm3fNTYQLrSiszxgqHrFCiKhcKdh8ABR1MH0OckDY2wUWf 8+uUhQp9+YrBpyDN2NoxDngCO+nT5GK+zq/3225hPLvuMT2q+fzDbGdw0U+U8E/+s+xD jy4SxgjoA8iAm1hSf6xRqbeSIor+kMx/PTvD1QsQe6KXyfhjL5DwKpRDz1ZVlf5S0Y7R /eMqGXaHVhBwUc+ETQKhiQg15j6NAAFEQzqEZEHD2qkR6Ww9m3BuaGEBs+XMpqb7HORt D/ZA== 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=SVP7GPh9e9gBvM9oYYmbf5OKNynjwo+SiJMNs3Bf90Q=; b=UMh7thiQ3ycPAT2vMYt34uKG7tgukGdsDGNwP9ROTAzG0vN+j4OkLOxSok7YZKxawf HMOW1mgZyZPbGk+2KxhY1cwM9sHdpFcKK770Vwf9Xpb5RGB/5Hg3qGP4dyAgNe3SJxPr BujCtRXA3wnSQAL1NSTc8ksD2dBsQ0yNUg+l1HH9Q9H2LCmbagzIyT/eW2Ah155M29Bp dji7DuCro9OyaasnjEJ5a58Q1Rx1sfNdY3c4hn+52iGgznq2roseYdux7iJ/X484S9s7 Vr99ZRQZvwFqc5bY5LN1UMuYQxs7TvZZB+aABDskvgr1HF8hUJA55FhuH9l52tcWWBR3 x0yQ== 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 f5si284850pgq.806.2018.03.13.09.41.19; Tue, 13 Mar 2018 09:41:34 -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 S1752983AbeCMQjk (ORCPT + 99 others); Tue, 13 Mar 2018 12:39:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59530 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762AbeCMPbw (ORCPT ); Tue, 13 Mar 2018 11:31:52 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DEA86504; Tue, 13 Mar 2018 15:31:50 +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.15 092/146] x86/speculation, objtool: Annotate indirect calls/jumps for objtool Date: Tue, 13 Mar 2018 16:24:19 +0100 Message-Id: <20180313152327.779062547@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-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)