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 X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0684C4727E for ; Wed, 30 Sep 2020 17:11:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80BDE20936 for ; Wed, 30 Sep 2020 17:11:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sE8WZ6lf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731217AbgI3RLB (ORCPT ); Wed, 30 Sep 2020 13:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbgI3RLB (ORCPT ); Wed, 30 Sep 2020 13:11:01 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBF6EC0613D0 for ; Wed, 30 Sep 2020 10:11:00 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id p9so3911232ejf.6 for ; Wed, 30 Sep 2020 10:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=sE8WZ6lfb33YbXSwicY08Buxu2+BclRjKlsf3vmfKYC0cOkGjIdkfWlcD3vKlvxBtD oJvOI0Me7W22ashUodxRg8si+zJpy2Cbj36q0/8yWyYhzL0LsEuNIm7mCi4bt0ydDxiP q2wgS9BmhahiQ+5AI274iqgwQFVzecBus9MZf563ErBkJT7H8HSacjGdi407Qm2FFScB UKBxyo4CmvhG4OhR92jBXUX4a8bOh0QyXvaZZAv6dW3JDWi42Xlo+4DGLRhZ05mHElhm akH0k3vLqe2e1OlNqWiJM/8E0bIvbsaLFvn/nLJrGgZiuIkxYeAIludqN2wsfPhdmkyE UahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=tnc4eN38o0PWUGbziD3/lu+YwwVyzc/tBEOEsc+voT1EXgE2wPwijktK70t+s33d1O YUdVJ9suXUEoJ/26x4mbEy7N5i0rubS6trfHfNs4aFSxPteQILO1F0zPPd1d/o+95Mxu bi3uebC7QErKf+urNKvKplzsR4GeZAZajmM5JQi8w13n8JizF9VNCkWakbKoLyxI+k/w SV80sAjTuE2wFaMNaeGU8bYAasdzAmYZN/4e8TuzP5DHR9dvItu+/nZuWbq2GhAgXf+u jG5A75NFoKq4KvOZoV0gA3NVA6npbA7vSdYJfKKYoB4vTXYwPUAA/798NOMvmNCY3V4y ErAQ== X-Gm-Message-State: AOAM532WI4NouzMPptvBS1HaH7NtaejiUwfGcilFDMNud5osYjGsuUe6 hcbtK9vczKppYTPToebIp+d6MI7izPv0HVElWSZrdA== X-Google-Smtp-Source: ABdhPJxx5zeY+5dc3dMhmlhIH9uf8zM/HMP0iLgIAwPYaEmmMHjXLZ0lmUCgiQV067mtUVMz2xbTNNo7KUcZkaJ7L2A= X-Received: by 2002:a17:906:a256:: with SMTP id bi22mr3767975ejb.375.1601485859067; Wed, 30 Sep 2020 10:10:59 -0700 (PDT) MIME-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> <20200929214631.3516445-10-samitolvanen@google.com> <20200930095850.GA68612@C02TD0UTHF1T.local> In-Reply-To: <20200930095850.GA68612@C02TD0UTHF1T.local> From: Sami Tolvanen Date: Wed, 30 Sep 2020 10:10:47 -0700 Message-ID: Subject: Re: [PATCH v4 09/29] arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS To: Mark Rutland Cc: Masahiro Yamada , Will Deacon , Steven Rostedt , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , linux-pci@vger.kernel.org, X86 ML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, On Wed, Sep 30, 2020 at 2:59 AM Mark Rutland wrote: > > Hi Sami, > > On Tue, Sep 29, 2020 at 02:46:11PM -0700, Sami Tolvanen wrote: > > Select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY to disable > > recordmcount when DYNAMIC_FTRACE_WITH_REGS is selected. > > Could you please add an explanation as to /why/ this is necessary in the > commit message? I couldn't figure this out form the commit message > alone, and reading the cover letter also didn't help. Sorry about that, I'll add a better explanation in the next version. Note that without LTO, this change is not strictly necessary as there's no harm in running recordmcount even if it's not needed. It might slow down the build slightly, but I suspect a few thousand invocations of the program won't take that long. However, with LTO we need to disable recordmcount because it doesn't understand LLVM bitcode. > If the minimum required GCC version supports patchable-function-entry > I'd be happy to make that a requirement for dynamic ftrace on arm64, as > then we'd only need to support one mechanism, and can get rid of some > redundant code. We already default to it when present anyhow. That would be great, but Documentation/process/changes.rst suggests the minimum gcc version is 4.9, and according to Godbolt we would need gcc >= 8 for -fpatchable-function-entry: https://godbolt.org/z/jdzcMW > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 6d232837cbee..ad522b021f35 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -155,6 +155,8 @@ config ARM64 > > select HAVE_DYNAMIC_FTRACE > > select HAVE_DYNAMIC_FTRACE_WITH_REGS \ > > if $(cc-option,-fpatchable-function-entry=2) > > + select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \ > > + if DYNAMIC_FTRACE_WITH_REGS > > This doesn't look quite right to me. Presumably we shouldn't allow > DYNAMIC_FTRACE_WITH_REGS to be selected if HAVE_DYNAMIC_FTRACE_WITH_REGS > isn't. This won't allow DYNAMIC_FTRACE_WITH_REGS to be selected without HAVE_DYNAMIC_FTRACE_WITH_REGS. Testing with a compiler that does support -fpatchable-function-entry, I get the following, as expected: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y And if the compiler doesn't support -fpatchable-function-entry, we would end up with the following: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE=y CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT=y Sami 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 X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9C48C4727C for ; Wed, 30 Sep 2020 17:12:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7DDE62076B for ; Wed, 30 Sep 2020 17:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q+rkDIow"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="sE8WZ6lf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7DDE62076B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=if8bYHidBD8t/VfYZzgl3fXr31EnG4d1r9SDWGQraNQ=; b=q+rkDIow/jnerxNsiKWYNYzAf 7yn2SlvwDqG2VAVLsilFmGlecWzfjy5Bm4XuXMq9XFjsgtSrF3+ItCYmFvbEXcIYby0dON4YFmNPf YFVOam+PNTCjgAEFuKPGQ/3aYhf2JXtq/FSSVU+q1J07rInEzJEpxrnIDkKCHVBv+3pbrxrwEz8zq ukkar3iiTnyEJMI0ELIhYW5P1s0XYeHaegFsuAnwxyKEMWYW6H8N1my6nsQi8TdYd0oWKW9QfHIiQ igUmQdV9W2/Jl22EUq5KmU4ppkg08McrxXCQpOlPS7WzMjUJFgeYxFCMcBciaPM4zojOscnao2YeR wf7y88dgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNfd9-0004XH-S5; Wed, 30 Sep 2020 17:11:04 +0000 Received: from mail-ej1-x641.google.com ([2a00:1450:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNfd7-0004WA-4i for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 17:11:02 +0000 Received: by mail-ej1-x641.google.com with SMTP id i26so3898072ejb.12 for ; Wed, 30 Sep 2020 10:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=sE8WZ6lfb33YbXSwicY08Buxu2+BclRjKlsf3vmfKYC0cOkGjIdkfWlcD3vKlvxBtD oJvOI0Me7W22ashUodxRg8si+zJpy2Cbj36q0/8yWyYhzL0LsEuNIm7mCi4bt0ydDxiP q2wgS9BmhahiQ+5AI274iqgwQFVzecBus9MZf563ErBkJT7H8HSacjGdi407Qm2FFScB UKBxyo4CmvhG4OhR92jBXUX4a8bOh0QyXvaZZAv6dW3JDWi42Xlo+4DGLRhZ05mHElhm akH0k3vLqe2e1OlNqWiJM/8E0bIvbsaLFvn/nLJrGgZiuIkxYeAIludqN2wsfPhdmkyE UahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=ildd2YPOnqjBKaT1YmXQ3RnhLZPiLI8OU2dkJI4T8slA3+9fR8Csy+si5Sj0RGtqMO +LfSFPg3UdL88X0+QbD4WCiZpb/ZaKt/WQquX5JVGTTmtqG8EAjAlIHRpa57h/2X+0bN 6pnKaLGTD6/6uRjQM5n9fUTANLjtcuD7sChWYC4KaGobvS+JdN9RVY/WrU3siLDZTBfy D7Ck1D9OpJO43nkUjzCa2x2CacTqyFFtW0gAMO9vAfZoool720U/SdAPsOA6tM1mHGPJ LWw4lsRpSMn6xN10S0sjAHwolwIP4PpLu/MXFZOxyu1bSDta/0Awd8uu7GuVt3wk3/HN zTRQ== X-Gm-Message-State: AOAM533AcTUFnlLG8WCtBMnsc/qH35VudCgfSH7aWBdEznhvU8/6+yLK FMjKfeOhJVdaP4TWerSxr2q/N1aPrUUx3UlvULfqsQ== X-Google-Smtp-Source: ABdhPJxx5zeY+5dc3dMhmlhIH9uf8zM/HMP0iLgIAwPYaEmmMHjXLZ0lmUCgiQV067mtUVMz2xbTNNo7KUcZkaJ7L2A= X-Received: by 2002:a17:906:a256:: with SMTP id bi22mr3767975ejb.375.1601485859067; Wed, 30 Sep 2020 10:10:59 -0700 (PDT) MIME-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> <20200929214631.3516445-10-samitolvanen@google.com> <20200930095850.GA68612@C02TD0UTHF1T.local> In-Reply-To: <20200930095850.GA68612@C02TD0UTHF1T.local> From: Sami Tolvanen Date: Wed, 30 Sep 2020 10:10:47 -0700 Message-ID: Subject: Re: [PATCH v4 09/29] arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS To: Mark Rutland X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_131101_253251_B4667EE0 X-CRM114-Status: GOOD ( 25.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , X86 ML , Kees Cook , "Paul E. McKenney" , Kernel Hardening , Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild , Nick Desaulniers , LKML , Steven Rostedt , clang-built-linux , linux-pci@vger.kernel.org, Will Deacon , linux-arm-kernel 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 Hi Mark, On Wed, Sep 30, 2020 at 2:59 AM Mark Rutland wrote: > > Hi Sami, > > On Tue, Sep 29, 2020 at 02:46:11PM -0700, Sami Tolvanen wrote: > > Select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY to disable > > recordmcount when DYNAMIC_FTRACE_WITH_REGS is selected. > > Could you please add an explanation as to /why/ this is necessary in the > commit message? I couldn't figure this out form the commit message > alone, and reading the cover letter also didn't help. Sorry about that, I'll add a better explanation in the next version. Note that without LTO, this change is not strictly necessary as there's no harm in running recordmcount even if it's not needed. It might slow down the build slightly, but I suspect a few thousand invocations of the program won't take that long. However, with LTO we need to disable recordmcount because it doesn't understand LLVM bitcode. > If the minimum required GCC version supports patchable-function-entry > I'd be happy to make that a requirement for dynamic ftrace on arm64, as > then we'd only need to support one mechanism, and can get rid of some > redundant code. We already default to it when present anyhow. That would be great, but Documentation/process/changes.rst suggests the minimum gcc version is 4.9, and according to Godbolt we would need gcc >= 8 for -fpatchable-function-entry: https://godbolt.org/z/jdzcMW > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 6d232837cbee..ad522b021f35 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -155,6 +155,8 @@ config ARM64 > > select HAVE_DYNAMIC_FTRACE > > select HAVE_DYNAMIC_FTRACE_WITH_REGS \ > > if $(cc-option,-fpatchable-function-entry=2) > > + select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \ > > + if DYNAMIC_FTRACE_WITH_REGS > > This doesn't look quite right to me. Presumably we shouldn't allow > DYNAMIC_FTRACE_WITH_REGS to be selected if HAVE_DYNAMIC_FTRACE_WITH_REGS > isn't. This won't allow DYNAMIC_FTRACE_WITH_REGS to be selected without HAVE_DYNAMIC_FTRACE_WITH_REGS. Testing with a compiler that does support -fpatchable-function-entry, I get the following, as expected: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y And if the compiler doesn't support -fpatchable-function-entry, we would end up with the following: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE=y CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT=y Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C6E9C4727E for ; Wed, 30 Sep 2020 17:11:20 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 584952076B for ; Wed, 30 Sep 2020 17:11:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sE8WZ6lf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 584952076B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20069-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 15811 invoked by uid 550); 30 Sep 2020 17:11:11 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 15779 invoked from network); 30 Sep 2020 17:11:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=sE8WZ6lfb33YbXSwicY08Buxu2+BclRjKlsf3vmfKYC0cOkGjIdkfWlcD3vKlvxBtD oJvOI0Me7W22ashUodxRg8si+zJpy2Cbj36q0/8yWyYhzL0LsEuNIm7mCi4bt0ydDxiP q2wgS9BmhahiQ+5AI274iqgwQFVzecBus9MZf563ErBkJT7H8HSacjGdi407Qm2FFScB UKBxyo4CmvhG4OhR92jBXUX4a8bOh0QyXvaZZAv6dW3JDWi42Xlo+4DGLRhZ05mHElhm akH0k3vLqe2e1OlNqWiJM/8E0bIvbsaLFvn/nLJrGgZiuIkxYeAIludqN2wsfPhdmkyE UahA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BqedzlGX8MsdvOmncyCbTeaSpoiIv6tQfCYOfAGCm1I=; b=llsQl3UdBwnb3eTqyrQMfcAMNuksbtbmkTws2dVHLZ1vilASY9rkQcGgwgX91MSisn z51fn4tcqhaRPzg0iw9BrF7rRmzkNPH6x4uR0dx7D36Gg0WvQ0K/BzwaQf1z9H4Tj/9R rCIaj9heVHlvs25P3Z33+4iGVOnXzZrAodgU/9exHi9QO6AHUxmJXeKjwoie4coCR4Ab ppJSR000wqcwHNPbyTlFusdCb5YL6iF0wCupkmB5r8hgtipxpALpIQbgRkvZddN6epdB Vc978dVPgxHGvxopsCDd/cIyKYNv9EKnexGXBuxwrz//NwY9WrCjIGiP8zAo6PJBjKor KjJA== X-Gm-Message-State: AOAM531F+01HZ9Fdkj8mIZmMhauN4l97gVOcrAbqRIFlu4u8IkDwMTwv kKGSG2hgGhduz+Gp/ETtUnfoUkfWc2XsDLaNSUV+tg== X-Google-Smtp-Source: ABdhPJxx5zeY+5dc3dMhmlhIH9uf8zM/HMP0iLgIAwPYaEmmMHjXLZ0lmUCgiQV067mtUVMz2xbTNNo7KUcZkaJ7L2A= X-Received: by 2002:a17:906:a256:: with SMTP id bi22mr3767975ejb.375.1601485859067; Wed, 30 Sep 2020 10:10:59 -0700 (PDT) MIME-Version: 1.0 References: <20200929214631.3516445-1-samitolvanen@google.com> <20200929214631.3516445-10-samitolvanen@google.com> <20200930095850.GA68612@C02TD0UTHF1T.local> In-Reply-To: <20200930095850.GA68612@C02TD0UTHF1T.local> From: Sami Tolvanen Date: Wed, 30 Sep 2020 10:10:47 -0700 Message-ID: Subject: Re: [PATCH v4 09/29] arm64: disable recordmcount with DYNAMIC_FTRACE_WITH_REGS To: Mark Rutland Cc: Masahiro Yamada , Will Deacon , Steven Rostedt , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , linux-pci@vger.kernel.org, X86 ML Content-Type: text/plain; charset="UTF-8" Hi Mark, On Wed, Sep 30, 2020 at 2:59 AM Mark Rutland wrote: > > Hi Sami, > > On Tue, Sep 29, 2020 at 02:46:11PM -0700, Sami Tolvanen wrote: > > Select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY to disable > > recordmcount when DYNAMIC_FTRACE_WITH_REGS is selected. > > Could you please add an explanation as to /why/ this is necessary in the > commit message? I couldn't figure this out form the commit message > alone, and reading the cover letter also didn't help. Sorry about that, I'll add a better explanation in the next version. Note that without LTO, this change is not strictly necessary as there's no harm in running recordmcount even if it's not needed. It might slow down the build slightly, but I suspect a few thousand invocations of the program won't take that long. However, with LTO we need to disable recordmcount because it doesn't understand LLVM bitcode. > If the minimum required GCC version supports patchable-function-entry > I'd be happy to make that a requirement for dynamic ftrace on arm64, as > then we'd only need to support one mechanism, and can get rid of some > redundant code. We already default to it when present anyhow. That would be great, but Documentation/process/changes.rst suggests the minimum gcc version is 4.9, and according to Godbolt we would need gcc >= 8 for -fpatchable-function-entry: https://godbolt.org/z/jdzcMW > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index 6d232837cbee..ad522b021f35 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -155,6 +155,8 @@ config ARM64 > > select HAVE_DYNAMIC_FTRACE > > select HAVE_DYNAMIC_FTRACE_WITH_REGS \ > > if $(cc-option,-fpatchable-function-entry=2) > > + select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY \ > > + if DYNAMIC_FTRACE_WITH_REGS > > This doesn't look quite right to me. Presumably we shouldn't allow > DYNAMIC_FTRACE_WITH_REGS to be selected if HAVE_DYNAMIC_FTRACE_WITH_REGS > isn't. This won't allow DYNAMIC_FTRACE_WITH_REGS to be selected without HAVE_DYNAMIC_FTRACE_WITH_REGS. Testing with a compiler that does support -fpatchable-function-entry, I get the following, as expected: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY=y And if the compiler doesn't support -fpatchable-function-entry, we would end up with the following: $ grep -E '(DYNAMIC_FTRACE|MCOUNT_USE)' .config CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_DYNAMIC_FTRACE=y CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT=y Sami