[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200304092105.11934-1-adrian.hunter@intel.com>
Date: Wed, 4 Mar 2020 11:21:05 +0200
From: Adrian Hunter <adrian.hunter@...el.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Steven Rostedt <rostedt@...dmis.org>,
Borislav Petkov <bp@...en8.de>,
"H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] x86/ftrace: Tidy create_trampoline()
create_trampoline() returns 2 values that the (only) caller simply
assigns to ops members. Amend create_trampoline() to make the
assignments instead, which simplifies the code.
Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
---
arch/x86/kernel/ftrace.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 108ee96f8b66..ee777c76a1c8 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -307,8 +307,7 @@ union ftrace_op_code_union {
#define RET_SIZE 1
-static unsigned long
-create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
+static void create_trampoline(struct ftrace_ops *ops)
{
unsigned long start_offset;
unsigned long end_offset;
@@ -319,6 +318,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
unsigned long size;
unsigned long retq;
unsigned long *ptr;
+ unsigned int tramp_size;
void *trampoline;
void *ip;
/* 48 8b 15 <offset> is movq <offset>(%rip), %rdx */
@@ -347,10 +347,10 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
*/
trampoline = alloc_tramp(size + RET_SIZE + sizeof(void *));
if (!trampoline)
- return 0;
+ return;
- *tramp_size = size + RET_SIZE + sizeof(void *);
- npages = DIV_ROUND_UP(*tramp_size, PAGE_SIZE);
+ tramp_size = size + RET_SIZE + sizeof(void *);
+ npages = DIV_ROUND_UP(tramp_size, PAGE_SIZE);
/* Copy ftrace_caller onto the trampoline memory */
ret = probe_kernel_read(trampoline, (void *)start_offset, size);
@@ -403,15 +403,16 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
/* ALLOC_TRAMP flags lets us know we created it */
ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP;
+ ops->trampoline = (unsigned long)trampoline;
+ ops->trampoline_size = tramp_size;
set_vm_flush_reset_perms(trampoline);
set_memory_ro((unsigned long)trampoline, npages);
set_memory_x((unsigned long)trampoline, npages);
- return (unsigned long)trampoline;
+ return;
fail:
tramp_free(trampoline);
- return 0;
}
static unsigned long calc_trampoline_call_offset(bool save_regs)
@@ -435,14 +436,10 @@ void arch_ftrace_update_trampoline(struct ftrace_ops *ops)
ftrace_func_t func;
unsigned long offset;
unsigned long ip;
- unsigned int size;
const char *new;
if (!ops->trampoline) {
- ops->trampoline = create_trampoline(ops, &size);
- if (!ops->trampoline)
- return;
- ops->trampoline_size = size;
+ create_trampoline(ops);
return;
}
--
2.17.1
Powered by blists - more mailing lists