From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 723D9C433EF for ; Fri, 28 Jan 2022 21:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LW8jdegkrl8W/aX9ttAVOxm8hS92oXqKdk31XMg4TaQ=; b=W1oPgvMQOj0H1d lEtrX/9F8MrVYx7zEivR2g8fsDbSAlnb2Rm8pQuAvtHJx4g0f5JF/rNzuyr3VvzRzk9mpXLjYe9ID YCLH8EuSJSSJ8FTQ2KeN2lbTYcKQEDI+AIk/Df9xpAMmxPngGxa1fKVoCcAY35BF/yQJqEWhpUa4E CfQYcGVkEBE16v2J9v5f1KCOGB5dH0IeMp9JJEakv70px4HmZv8pK4kHqed/PtsY3lsxRDNDmDxVk z0X6vytjzy37JJ3KOmS7JB922t6Y0xLOwYyCbrzABtEtNOmZEvlpIqAPAGgZhRzEiojh5YDpohUld 6vC3RrcXR01afDH4nYxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDYYn-003Z1x-Kx; Fri, 28 Jan 2022 21:13:33 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nDYYj-003Z1G-WA for linux-arm-kernel@lists.infradead.org; Fri, 28 Jan 2022 21:13:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643404407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Kl8+hZCih6hFrtPcq+y44yJja7mQTiBvhEFz2HD3rIc=; b=ca7chL2KnyKxaoyAicc1ISsLYYV4pnTgB1/miuEOgB88dERAUXOqAzKOlfsi4Hc1XUUei+ D7YtOcGQZLP19t3la52ALDB3AUkQ/3DfSbiIjBK9PsjIfiWOmar2dTrkvE1UMgrXx0Vn7c Th7NZwonf5CNGG4uV3VYGQ1Yg9T8yIM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-FC5CJJmQPCSoTVo_UCHjmA-1; Fri, 28 Jan 2022 16:11:46 -0500 X-MC-Unique: FC5CJJmQPCSoTVo_UCHjmA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3973C851A03; Fri, 28 Jan 2022 21:11:44 +0000 (UTC) Received: from redhat.com (unknown [10.22.8.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6D6C519BF; Fri, 28 Jan 2022 21:11:41 +0000 (UTC) Date: Fri, 28 Jan 2022 16:11:39 -0500 From: Joe Lawrence To: Steven Rostedt Cc: LKML , Ingo Molnar , Andrew Morton , Mark Rutland , Yinan Liu , Ard Biesheuvel , Kees Cook , Sachin Sant , linuxppc-dev@lists.ozlabs.org, Russell King , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] ftrace: Have architectures opt-in for mcount build time sorting Message-ID: References: <20220127114249.03b1b52b@gandalf.local.home> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220127114249.03b1b52b@gandalf.local.home> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220128_131330_220762_30A6881A X-CRM114-Status: GOOD ( 36.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jan 27, 2022 at 11:42:49AM -0500, Steven Rostedt wrote: > From: "Steven Rostedt (Google)" > > First S390 complained that the sorting of the mcount sections at build > time caused the kernel to crash on their architecture. Now PowerPC is > complaining about it too. And also ARM64 appears to be having issues. > > It may be necessary to also update the relocation table for the values > in the mcount table. Not only do we have to sort the table, but also > update the relocations that may be applied to the items in the table. > > If the system is not relocatable, then it is fine to sort, but if it is, > some architectures may have issues (although x86 does not as it shifts all > addresses the same). > > Add a HAVE_BUILDTIME_MCOUNT_SORT that an architecture can set to say it is > safe to do the sorting at build time. > > Also update the config to compile in build time sorting in the sorttable > code in scripts/ to depend on CONFIG_BUILDTIME_MCOUNT_SORT. > > Link: https://lore.kernel.org/all/944D10DA-8200-4BA9-8D0A-3BED9AA99F82@linux.ibm.com/ > > Cc: Mark Rutland > Cc: Yinan Liu > Cc: Ard Biesheuvel > Cc: Kees Cook > Cc: linuxppc-dev@lists.ozlabs.org > Reported-by: Sachin Sant > Tested-by: Sachin Sant > Fixes: 72b3942a173c ("scripts: ftrace - move the sort-processing in ftrace_init") > Signed-off-by: Steven Rostedt (Google) > --- > arch/arm/Kconfig | 1 + > arch/x86/Kconfig | 1 + > kernel/trace/Kconfig | 8 +++++++- > scripts/Makefile | 2 +- > 4 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index c2724d986fa0..5256ebe57451 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -82,6 +82,7 @@ config ARM > select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 > select HAVE_CONTEXT_TRACKING > select HAVE_C_RECORDMCOUNT > + select HAVE_BUILDTIME_MCOUNT_SORT > select HAVE_DEBUG_KMEMLEAK if !XIP_KERNEL > select HAVE_DMA_CONTIGUOUS if MMU > select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > index 7399327d1eff..46080dea5dba 100644 > --- a/arch/x86/Kconfig > +++ b/arch/x86/Kconfig > @@ -186,6 +186,7 @@ config X86 > select HAVE_CONTEXT_TRACKING_OFFSTACK if HAVE_CONTEXT_TRACKING > select HAVE_C_RECORDMCOUNT > select HAVE_OBJTOOL_MCOUNT if STACK_VALIDATION > + select HAVE_BUILDTIME_MCOUNT_SORT > select HAVE_DEBUG_KMEMLEAK > select HAVE_DMA_CONTIGUOUS > select HAVE_DYNAMIC_FTRACE > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > index 752ed89a293b..7e5b92090faa 100644 > --- a/kernel/trace/Kconfig > +++ b/kernel/trace/Kconfig > @@ -70,10 +70,16 @@ config HAVE_C_RECORDMCOUNT > help > C version of recordmcount available? > > +config HAVE_BUILDTIME_MCOUNT_SORT > + bool > + help > + An architecture selects this if it sorts the mcount_loc section > + at build time. > + > config BUILDTIME_MCOUNT_SORT > bool > default y > - depends on BUILDTIME_TABLE_SORT && !S390 > + depends on HAVE_BUILDTIME_MCOUNT_SORT > help > Sort the mcount_loc section at build time. > > diff --git a/scripts/Makefile b/scripts/Makefile > index b082d2f93357..cedc1f0e21d8 100644 > --- a/scripts/Makefile > +++ b/scripts/Makefile > @@ -32,7 +32,7 @@ HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/x86/include > HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED > endif > > -ifdef CONFIG_DYNAMIC_FTRACE > +ifdef CONFIG_BUILDTIME_MCOUNT_SORT > HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED > endif > > -- > 2.33.0 > Hi Steve, I just finished bisecting what is probably the same problem... when running the livepatch selftests for 5.17-rc1, x86_64 passes, but I kept getting errors like this on ppc64le: kernel: livepatch: enabling patch 'test_klp_livepatch' kernel: livepatch: failed to find location for function 'cmdline_proc_show' kernel: livepatch: failed to patch object 'vmlinux' kernel: livepatch: failed to enable patch 'test_klp_livepatch' kernel: livepatch: 'test_klp_livepatch': unpatching complete which means klp_get_ftrace_location() / ftrace_location_range() hit a problem with that function. The bisect finally landed on: 72b3942a173c387b27860ba1069636726e208777 is the first bad commit commit 72b3942a173c387b27860ba1069636726e208777 Author: Yinan Liu Date: Sun Dec 12 19:33:58 2021 +0800 scripts: ftrace - move the sort-processing in ftrace_init and I can confirm that your updates today in "[for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1" fix or avoid the issue. I just wanted to add my report in case this adds any future complications for mcount build time sorting. Let me know if any additional tests would be helpful. Regards, -- Joe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel