Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbeADCAz (ORCPT + 1 other); Wed, 3 Jan 2018 21:00:55 -0500 Received: from mga03.intel.com ([134.134.136.65]:20809 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbeADCAq (ORCPT ); Wed, 3 Jan 2018 21:00:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,505,1508828400"; d="scan'208";a="7247503" From: Andi Kleen To: tglx@linutronix.de Cc: torvalds@linux-foundation.org, gregkh@linux-foundation.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, Andi Kleen Subject: [PATCH v2 04/12] x86/retpoline/ftrace: Convert ftrace assembler indirect jumps Date: Wed, 3 Jan 2018 18:00:11 -0800 Message-Id: <20180104020019.1173-5-andi@firstfloor.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180104020019.1173-1-andi@firstfloor.org> References: <20180104020019.1173-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 Convert all indirect jumps in ftrace assembler code to use non speculative sequences. Based on code from David Woodhouse and Tim Chen Signed-off-by: Andi Kleen --- arch/x86/kernel/ftrace_32.S | 3 ++- arch/x86/kernel/ftrace_64.S | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S index b6c6468e10bc..c0c10ba53375 100644 --- a/arch/x86/kernel/ftrace_32.S +++ b/arch/x86/kernel/ftrace_32.S @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef CC_USING_FENTRY # define function_hook __fentry__ @@ -241,5 +242,5 @@ return_to_handler: movl %eax, %ecx popl %edx popl %eax - jmp *%ecx + NOSPEC_JMP %ecx #endif diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S index c832291d948a..4814c4b30b8d 100644 --- a/arch/x86/kernel/ftrace_64.S +++ b/arch/x86/kernel/ftrace_64.S @@ -7,7 +7,7 @@ #include #include #include - +#include .code64 .section .entry.text, "ax" @@ -286,7 +286,7 @@ trace: * ip and parent ip are used and the list function is called when * function tracing is enabled. */ - call *ftrace_trace_function + NOSPEC_CALL ftrace_trace_function restore_mcount_regs @@ -329,5 +329,5 @@ GLOBAL(return_to_handler) movq 8(%rsp), %rdx movq (%rsp), %rax addq $24, %rsp - jmp *%rdi + NOSPEC_JMP %rdi #endif -- 2.14.3