From patchwork Fri Feb 8 15:10:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torsten Duwe X-Patchwork-Id: 10803291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0487A1575 for ; Fri, 8 Feb 2019 15:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E31762E301 for ; Fri, 8 Feb 2019 15:26:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5EBB2E8E4; Fri, 8 Feb 2019 15:26:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A25A62E301 for ; Fri, 8 Feb 2019 15:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:From:Date: Message-Id:References:In-Reply-To:Subject:To:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JnFf1qDpvFei7E+520P9h8BvmtgH1PpObZWKdyuyMqg=; b=HLb7g6H7ziZtyZ2WLMWJgjhNH0 gwnoyuwkRFGSMYr80F2iVxhua/cywOoSDbZ39Ho74OUyxTbS3Pdl+gpldmnXsndnv80j2gS9OC+VV rWbMZB44gTJML80keyoaTUjxGYIbwh1ceKBYVqiEHIwIbTzW9UPf/siUi0WalJL9ePGFkajgqq9jy l+O47sYHvWRRJH0eIB4PSScVd+I+qly0GSPjDJCWpNDgysUqXyQX0XwMj7fJE+nZyO9ZmeDZlCIpD CBSGsCkh32vI+s1JsaN5oYKUPpJW1OUGPFFq/WOYHZ0gVylXKzG/tEDMDE9TSugg8Hzhqo0/yXLd0 H40ZxRQw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs830-0003YZ-Ny; Fri, 08 Feb 2019 15:26:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs82y-0003Ie-RW for linux-arm-kernel@bombadil.infradead.org; Fri, 08 Feb 2019 15:26:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=From:Date:Message-Id:References: In-Reply-To:Subject:Cc:To:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u5deY7nIp8p0TaPc+MYTZr7jgSMktdqt0g4G4u+Z2QY=; b=UYLHZ3WhNEOUiTaI0sheSBVsP koXHt5NyrE+p4UNSWV2MopYSpIqKxmKtwlPhiYgDwv4NwfVGkkfI6Sywr3vlR+COZDn9O5/7odn9/ BULvdZsDSkKNDDQScLOtl8EYFOvLBylIicyhGxwq7E0lN03hwjLqEtWRYEiFEyZ8EOJ71aIgmoWnL tfaZ0GPwJorIxqPEMk1gD3h/GtmTby2n32qo37rnDvCu2VHpAWtFHO95tTEyeNbFUU9ZxuKmw7yUE wbBrhc7Q44Q7sWKDqiSyyqvDD0zA049RCdQ/8FGUPPbJRkJckcdD+7nhKa6oYQC+40BDgWOJuTNrr PWZCemnLw==; Received: from verein.lst.de ([213.95.11.211] helo=newverein.lst.de) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gs7nO-0000P3-LL for linux-arm-kernel@lists.infradead.org; Fri, 08 Feb 2019 15:10:28 +0000 Received: by newverein.lst.de (Postfix, from userid 2005) id 676A168DEE; Fri, 8 Feb 2019 16:10:24 +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 Subject: [PATCH v8 5/5] arm64: use -fpatchable-function-entry if available In-Reply-To: <20190208150826.44EBC68DD2@newverein.lst.de> References: <20190208150826.44EBC68DD2@newverein.lst.de> Message-Id: <20190208151024.676A168DEE@newverein.lst.de> Date: Fri, 8 Feb 2019 16:10:24 +0100 (CET) From: duwe@lst.de (Torsten Duwe) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190208_151026_736343_8B264E9A X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ++ kernel/module.c | 7 ++++++- 5 files changed, 16 insertions(+), 1 deletion(-) --- 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 --- a/kernel/module.c +++ b/kernel/module.c @@ -3122,7 +3122,12 @@ static int find_module_sections(struct m #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD /* sechdrs[0].sh_size is always zero */ - mod->ftrace_callsites = section_objs(info, "__mcount_loc", + mod->ftrace_callsites = section_objs(info, +#ifdef CC_USING_PATCHABLE_FENTRY + "__patchable_function_entries", +#else + "__mcount_loc", +#endif sizeof(*mod->ftrace_callsites), &mod->num_ftrace_callsites); #endif