From patchwork Sat Mar 13 06:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Pei X-Patchwork-Id: 12136543 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 624CFC433E0 for ; Sat, 13 Mar 2021 06:42:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F09564F1B for ; Sat, 13 Mar 2021 06:42:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F09564F1B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 426746B0074; Sat, 13 Mar 2021 01:42:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 33A6D6B0075; Sat, 13 Mar 2021 01:42:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F5256B0078; Sat, 13 Mar 2021 01:42:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id DDD176B0074 for ; Sat, 13 Mar 2021 01:42:31 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 99BF3A2A4 for ; Sat, 13 Mar 2021 06:42:31 +0000 (UTC) X-FDA: 77913907302.24.5DDD2BD Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by imf03.hostedemail.com (Postfix) with ESMTP id D4BD4C0007D5 for ; Sat, 13 Mar 2021 06:42:27 +0000 (UTC) Received: from localhost.localdomain (unknown [222.209.9.50]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxGda4XkxgjLUYAA--.9506S7; Sat, 13 Mar 2021 14:42:16 +0800 (CST) From: Huang Pei To: Thomas Bogendoerfer , ambrosehua@gmail.com Cc: Bibo Mao , linux-mips@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, Jiaxun Yang , Paul Burton , Li Xuefeng , Yang Tiezhu , Gao Juxin , Huacai Chen , Jinyang He , "Maciej W . Rozycki" , Steven Rostedt , Jisheng Zhang , Masami Hiramatsu Subject: [PATCH 5/6] ftrace: introduce FTRACE_IP_EXTENSION Date: Sat, 13 Mar 2021 14:41:48 +0800 Message-Id: <20210313064149.29276-6-huangpei@loongson.cn> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210313064149.29276-1-huangpei@loongson.cn> References: <20210313064149.29276-1-huangpei@loongson.cn> X-CM-TRANSID: AQAAf9AxGda4XkxgjLUYAA--.9506S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw43Xw4rWFyrtFyfur45Jrb_yoW8AF15pF 9rC3WkGFWxJFWqkryv93s5Gr9rCw4kZrW7Ga9rGw4Yqr9xtF1vgrnFvrs2vr1xJrZ7GFWa vFyj9ryUCw4UZFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4U JVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x0262 8vn2kIc2xKxwCY02Avz4vE14v_GF1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1V AY17CE14v26r4a6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAI cVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnI WIevJa73UjIFyTuYvjfUn5l8UUUUU X-CM-SenderInfo: xkxd0whshlqz5rrqw2lrqou0/ X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D4BD4C0007D5 X-Stat-Signature: byukhpt5nb4zztfxdteh9imc65mon58e Received-SPF: none (loongson.cn>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=loongson.cn; client-ip=114.242.206.163 X-HE-DKIM-Result: none/none X-HE-Tag: 1615617747-118878 X-Bogosity: Ham, tests=bogofilter, spamicity=0.025231, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Jisheng Zhang On some architectures, the DYNAMIC_FTRACE_WITH_REGS is implemented by gcc's -fpatchable-function-entry option. Take arm64 for example, arm64 makes use of GCC -fpatchable-function-entry=2 option to insert two nops. When the function is traced, the first nop will be modified to the LR saver, then the second nop to "bl ". we need to update ftrace_location() to recognise these two instructions as being part of ftrace. To do this, we introduce FTRACE_IP_EXTENSION to let ftrace_location search IP, IP + FTRACE_IP_EXTENSION range. Signed-off-by: Jisheng Zhang Suggested-by: Steven Rostedt (VMware) --- include/linux/ftrace.h | 4 ++++ kernel/trace/ftrace.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 1bd3a0356ae4..c1e1fbde8a04 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -20,6 +20,10 @@ #include +#ifndef FTRACE_IP_EXTENSION +#define FTRACE_IP_EXTENSION 0 +#endif + /* * If the arch supports passing the variable contents of * function_trace_op as the third parameter back from the diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 9c1bba8cc51b..a6f0e3db2479 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1583,7 +1583,7 @@ unsigned long ftrace_location_range(unsigned long start, unsigned long end) */ unsigned long ftrace_location(unsigned long ip) { - return ftrace_location_range(ip, ip); + return ftrace_location_range(ip, ip + FTRACE_IP_EXTENSION); } /**