Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4631055ybg; Tue, 29 Oct 2019 10:01:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwufYZ/nDyleJc49YCO7iGD9NLMcYQr6ZBbL8rae4A4EUxByDMrmvv7L+9UZd2YbFEyUSWg X-Received: by 2002:aa7:cd64:: with SMTP id ca4mr19423743edb.121.1572368490220; Tue, 29 Oct 2019 10:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572368490; cv=none; d=google.com; s=arc-20160816; b=zwtrurUoXatNzKmIJFHGtqcyny00zGsAufxF/czYRpQ5y0q3iAGI4JDsAGHx+mFiI3 rfLLhS6iCN3wqRmMs4r+0Dhc8kJmz6+K1OEn1Rq/R89bhkS1SJ+GRocD7d89aEN6kLNW DXq0UAOTe9iFbjuWMM6UQcNjQqdt7ZXK38PZv2MCWwKoa+FfWzt7TGKkTPB2DwoG7BXl YhvEa24hI58yWr4d8ezF2k0JXm09qlEK7JhlFPKkDDxjPw81/4rRH+SB3oWg84/mA2+z b7LHpkEQoY3ZZzGGdMRgdfHPdAAOoE/1FdLjTvsZwZn1i4FLy9I0kbCmcSxXY4L4miAa wVfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=38ZImR0bc2gO1AuEhd4HyZN5wcTOmBsJrMsK6iG3DY8=; b=jTKT3iNIZSY3ejR212HEAeOHP3vASrXNu7/pomr5oNLMGNrciib3F/cqxdCky9Fu8f NUlE9BO5g5yzDGhMlgGE6YxIFzEtDjiWeZfXl0KhuoPKc/NzFYsGYdH/vGK3BSRre4IU h5EGAUKUVK61djHDPnSwgTACtN7ml9ckg4Q7OT2ZTXVK+mkDVTjTMGQuIwE3vZ5pDoiH i0zhqe9s2qKqY71EyQOar1kAipbOfZR5BnoAM7sCn2o9wsqV+geJ4VS29lMbXB/CYaAJ UluSwvj15GCR1nNcrWCoPBMkq7kQysXWG7WR7RQYP2I9KAskjOws5VSDsHwhd+StLI1c f+zA== 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 v16si8749440ejx.96.2019.10.29.10.01.04; Tue, 29 Oct 2019 10:01:30 -0700 (PDT) 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 S2403772AbfJ2Q72 (ORCPT + 99 others); Tue, 29 Oct 2019 12:59:28 -0400 Received: from foss.arm.com ([217.140.110.172]:54760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390802AbfJ2Q72 (ORCPT ); Tue, 29 Oct 2019 12:59:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5F8347AD; Tue, 29 Oct 2019 09:59:27 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0B57C3F71F; Tue, 29 Oct 2019 09:59:24 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, amit.kachhap@arm.com, catalin.marinas@arm.com, deller@gmx.de, duwe@suse.de, James.Bottomley@HansenPartnership.com, james.morse@arm.com, jeyu@kernel.org, jpoimboe@redhat.com, jthierry@redhat.com, linux-parisc@vger.kernel.org, mark.rutland@arm.com, mingo@redhat.com, peterz@infradead.org, rostedt@goodmis.org, svens@stackframe.org, takahiro.akashi@linaro.org, will@kernel.org Subject: [PATCHv2 8/8] arm64: ftrace: minimize ifdeffery Date: Tue, 29 Oct 2019 16:58:32 +0000 Message-Id: <20191029165832.33606-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191029165832.33606-1-mark.rutland@arm.com> References: <20191029165832.33606-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we no longer refer to mod->arch.ftrace_trampolines in the body of ftrace_make_call(), we can use IS_ENABLED() rather than ifdeffery, and make the code easier to follow. Likewise in ftrace_make_nop(). Let's do so. Signed-off-by: Mark Rutland Reviewed-by: Ard Biesheuvel Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/ftrace.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index aea652c33a38..8618faa82e6d 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -62,18 +62,18 @@ int ftrace_update_ftrace_func(ftrace_func_t func) return ftrace_modify_code(pc, 0, new, false); } -#ifdef CONFIG_ARM64_MODULE_PLTS static struct plt_entry *get_ftrace_plt(struct module *mod, unsigned long addr) { +#ifdef CONFIG_ARM64_MODULE_PLTS struct plt_entry *plt = mod->arch.ftrace_trampolines; if (addr == FTRACE_ADDR) return &plt[FTRACE_PLT_IDX]; if (addr == FTRACE_REGS_ADDR && IS_ENABLED(CONFIG_FTRACE_WITH_REGS)) return &plt[FTRACE_REGS_PLT_IDX]; +#endif return NULL; } -#endif /* * Turn on the call to ftrace_caller() in instrumented function @@ -85,10 +85,12 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) long offset = (long)pc - (long)addr; if (offset < -SZ_128M || offset >= SZ_128M) { -#ifdef CONFIG_ARM64_MODULE_PLTS struct module *mod; struct plt_entry *plt; + if (!IS_ENABLED(CONFIG_ARM64_MODULE_PLTS)) + return -EINVAL; + /* * On kernels that support module PLTs, the offset between the * branch instruction and its target may legally exceed the @@ -113,9 +115,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) } addr = (unsigned long)plt; -#else /* CONFIG_ARM64_MODULE_PLTS */ - return -EINVAL; -#endif /* CONFIG_ARM64_MODULE_PLTS */ } old = aarch64_insn_gen_nop(); @@ -185,9 +184,11 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, long offset = (long)pc - (long)addr; if (offset < -SZ_128M || offset >= SZ_128M) { -#ifdef CONFIG_ARM64_MODULE_PLTS u32 replaced; + if (!IS_ENABLED(CONFIG_ARM64_MODULE_PLTS)) + return -EINVAL; + /* * 'mod' is only set at module load time, but if we end up * dealing with an out-of-range condition, we can assume it @@ -218,9 +219,6 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, return -EINVAL; validate = false; -#else /* CONFIG_ARM64_MODULE_PLTS */ - return -EINVAL; -#endif /* CONFIG_ARM64_MODULE_PLTS */ } else { old = aarch64_insn_gen_branch_imm(pc, addr, AARCH64_INSN_BRANCH_LINK); -- 2.11.0