Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3337897imu; Fri, 18 Jan 2019 08:42:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN4UUs4WJUAqRKr8unc7ufdRg/GJUpO9cTzudrjGq1LUjEaARIr/gxn1OfMSI/JfZkVR6UBf X-Received: by 2002:a17:902:2006:: with SMTP id n6mr20156752pla.66.1547829744166; Fri, 18 Jan 2019 08:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547829744; cv=none; d=google.com; s=arc-20160816; b=0Ky3TjDWpJkJZAzM7iD1rp8vP7top0yPLosJ/gLWJUXKnFZa5D9G8KCipNq2p7B69/ uQ0Yw+FejIbS+DbnQCe876Vd0m6+GJJXKc73uPNPErTHujqC1xa3xd9pl8oOYJNMuYn+ s7vtL7BhGjwcW+Vwn20Uso2FjRHJdLcy8lfpet5pZ0V67mZsMkz2uEbQ38coZ4EOTTF8 vVgOexmZ0T2eFHClLKcbt8Tba76n6GjPy5J3jrKHdnaKb2UefputBEy5hYdra+XfUXpf UbpKZXN/zHMx2061YJvS5wT+O8h25Ndb1mGA0s+pboICae79MdmcWujCIvgxoB43aBo4 ceSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:from:date:message-id:references :in-reply-to:subject:cc:to; bh=PrS4jowBikGdXUndYq6SBVSGR02u9I7HIIz2ZByzQkM=; b=avuoMimXqkLnYFbJf1RMKXAmKljff/ovzuhUeKOXHA1WlJKFQM+a85SbLJm64yaMKb YP2qBsk0Ss+7NHdFGVlvtn32946ABMVSiZwiAZroOMij0MAbDTLi8BB9in+CCrAEX5Pe GmLE7w9F6pGAAzNpww1IIQh8ovJlih3adNU0TAsy2zB1qiFG4daS+mPe4RmctXlaPi4c KCfJxapl9neNJkeNdrGr3SBweqfIoO8SsO+BhO+/nshPQ4gZTnEl24JiA982ODhTRfpr Hds02kkvy50yVFwBPQeBDCEQ+UKdvS1r53CQ/cUCV7YL5JTkkzCmGKneLJ1C9hMvXig/ dVHQ== 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 b63si5060078pfa.250.2019.01.18.08.42.07; Fri, 18 Jan 2019 08:42:24 -0800 (PST) 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 S1728276AbfARQjP (ORCPT + 99 others); Fri, 18 Jan 2019 11:39:15 -0500 Received: from verein.lst.de ([213.95.11.211]:44675 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728161AbfARQjO (ORCPT ); Fri, 18 Jan 2019 11:39:14 -0500 Received: by newverein.lst.de (Postfix, from userid 2005) id 0414868DCF; Fri, 18 Jan 2019 17:39:13 +0100 (CET) To: Mark Rutland , Will Deacon , Catalin Marinas , Julien Thierry , Steven Rostedt , Josh Poimboeuf , Ingo Molnar , Ard Biesheuvel , Arnd Bergmann , AKASHI Takahiro , Amit Daniel Kachhap Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: [PATCH v7 3/3] arm64: use -fpatchable-function-entry if available In-Reply-To: <20190118163736.6A99268CEB@newverein.lst.de> References: <20190118163736.6A99268CEB@newverein.lst.de> Message-Id: <20190118163913.0414868DCF@newverein.lst.de> Date: Fri, 18 Jan 2019 17:39:13 +0100 (CET) From: duwe@lst.de (Torsten Duwe) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test whether gcc supports -fpatchable-function-entry and use it to promote DYNAMIC_FTRACE to DYNAMIC_FTRACE_WITH_REGS. Amend support for the new object section that holds the locations (__patchable_function_entries) and define a proper "notrace" attribute to switch it off. Signed-off-by: Torsten Duwe --- arch/arm64/Kconfig | 2 ++ arch/arm64/Makefile | 5 +++++ include/asm-generic/vmlinux.lds.h | 1 + include/linux/compiler_types.h | 2 ++ 4 files changed, 10 insertions(+) --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -132,6 +132,8 @@ config ARM64 select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS select HAVE_DYNAMIC_FTRACE + select HAVE_DYNAMIC_FTRACE_WITH_REGS \ + if $(cc-option,-fpatchable-function-entry=2) select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_TRACER --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -89,6 +89,11 @@ ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds endif +ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) + KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FENTRY + CC_FLAGS_FTRACE := -fpatchable-function-entry=2 +endif + # Default value head-y := arch/arm64/kernel/head.o --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -113,6 +113,7 @@ #define MCOUNT_REC() . = ALIGN(8); \ __start_mcount_loc = .; \ KEEP(*(__mcount_loc)) \ + KEEP(*(__patchable_function_entries)) \ __stop_mcount_loc = .; #else #define MCOUNT_REC() --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -112,6 +112,8 @@ struct ftrace_likely_data { #if defined(CC_USING_HOTPATCH) #define notrace __attribute__((hotpatch(0, 0))) +#elif defined(CC_USING_PATCHABLE_FENTRY) +#define notrace __attribute__((patchable_function_entry(0))) #else #define notrace __attribute__((__no_instrument_function__)) #endif