[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e582e4d4-32b1-260d-96d6-69267455788d@redhat.com>
Date: Tue, 11 Feb 2020 07:52:41 +0000
From: Julien Thierry <jthierry@...hat.com>
To: Josh Poimboeuf <jpoimboe@...hat.com>, x86@...nel.org
Cc: linux-kernel@...r.kernel.org, Borislav Petkov <bp@...e.de>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH 2/3] objtool: Add is_static_jump() helper
On 2/10/20 6:32 PM, Josh Poimboeuf wrote:
> There are several places where objtool tests for a non-dynamic (aka
> direct) jump. Move the check to a helper function.
>
Makes sense.
> Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
Reviewed-by: Julien Thierry <jthierry@...hat.com>
> ---
> tools/objtool/check.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 61d2d1877fd2..5ea2ce7ed8a3 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -97,14 +97,19 @@ static struct instruction *next_insn_same_func(struct objtool_file *file,
> for (insn = next_insn_same_sec(file, insn); insn; \
> insn = next_insn_same_sec(file, insn))
>
> +static bool is_static_jump(struct instruction *insn)
> +{
> + return insn->type == INSN_JUMP_CONDITIONAL ||
> + insn->type == INSN_JUMP_UNCONDITIONAL;
> +}
> +
> static bool is_sibling_call(struct instruction *insn)
> {
> /* An indirect jump is either a sibling call or a jump to a table. */
> if (insn->type == INSN_JUMP_DYNAMIC)
> return list_empty(&insn->alts);
>
> - if (insn->type != INSN_JUMP_CONDITIONAL &&
> - insn->type != INSN_JUMP_UNCONDITIONAL)
> + if (!is_static_jump(insn))
> return false;
>
> /* add_jump_destinations() sets insn->call_dest for sibling calls. */
> @@ -571,8 +576,7 @@ static int add_jump_destinations(struct objtool_file *file)
> unsigned long dest_off;
>
> for_each_insn(file, insn) {
> - if (insn->type != INSN_JUMP_CONDITIONAL &&
> - insn->type != INSN_JUMP_UNCONDITIONAL)
> + if (!is_static_jump(insn))
> continue;
>
> if (insn->ignore || insn->offset == FAKE_JUMP_OFFSET)
> @@ -782,8 +786,7 @@ static int handle_group_alt(struct objtool_file *file,
> insn->ignore = orig_insn->ignore_alts;
> insn->func = orig_insn->func;
>
> - if (insn->type != INSN_JUMP_CONDITIONAL &&
> - insn->type != INSN_JUMP_UNCONDITIONAL)
> + if (!is_static_jump(insn))
> continue;
>
> if (!insn->immediate)
>
--
Julien Thierry
Powered by blists - more mailing lists