mirror of https://github.com/torvalds/linux.git
objtool: Remove ANNOTATE_IGNORE_ALTERNATIVE from CLAC/STAC
ANNOTATE_IGNORE_ALTERNATIVE adds additional noise to the code generated by CLAC/STAC alternatives, hurting readability for those whose read uaccess-related code generation on a regular basis. Remove the annotation specifically for the "NOP patched with CLAC/STAC" case in favor of a manual check. Leave the other uses of that annotation in place as they're less common and more difficult to detect. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/fc972ba4995d826fcfb8d02733a14be8d670900b.1744098446.git.jpoimboe@kernel.org
This commit is contained in:
parent
2dbbca9be4
commit
2d12c6fb78
|
|
@ -16,23 +16,23 @@
|
||||||
#ifdef __ASSEMBLER__
|
#ifdef __ASSEMBLER__
|
||||||
|
|
||||||
#define ASM_CLAC \
|
#define ASM_CLAC \
|
||||||
ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "clac", X86_FEATURE_SMAP
|
ALTERNATIVE "", "clac", X86_FEATURE_SMAP
|
||||||
|
|
||||||
#define ASM_STAC \
|
#define ASM_STAC \
|
||||||
ALTERNATIVE __stringify(ANNOTATE_IGNORE_ALTERNATIVE), "stac", X86_FEATURE_SMAP
|
ALTERNATIVE "", "stac", X86_FEATURE_SMAP
|
||||||
|
|
||||||
#else /* __ASSEMBLER__ */
|
#else /* __ASSEMBLER__ */
|
||||||
|
|
||||||
static __always_inline void clac(void)
|
static __always_inline void clac(void)
|
||||||
{
|
{
|
||||||
/* Note: a barrier is implicit in alternative() */
|
/* Note: a barrier is implicit in alternative() */
|
||||||
alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP);
|
alternative("", "clac", X86_FEATURE_SMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __always_inline void stac(void)
|
static __always_inline void stac(void)
|
||||||
{
|
{
|
||||||
/* Note: a barrier is implicit in alternative() */
|
/* Note: a barrier is implicit in alternative() */
|
||||||
alternative(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP);
|
alternative("", "stac", X86_FEATURE_SMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __always_inline unsigned long smap_save(void)
|
static __always_inline unsigned long smap_save(void)
|
||||||
|
|
@ -59,9 +59,9 @@ static __always_inline void smap_restore(unsigned long flags)
|
||||||
|
|
||||||
/* These macros can be used in asm() statements */
|
/* These macros can be used in asm() statements */
|
||||||
#define ASM_CLAC \
|
#define ASM_CLAC \
|
||||||
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "clac", X86_FEATURE_SMAP)
|
ALTERNATIVE("", "clac", X86_FEATURE_SMAP)
|
||||||
#define ASM_STAC \
|
#define ASM_STAC \
|
||||||
ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "", "stac", X86_FEATURE_SMAP)
|
ALTERNATIVE("", "stac", X86_FEATURE_SMAP)
|
||||||
|
|
||||||
#define ASM_CLAC_UNSAFE \
|
#define ASM_CLAC_UNSAFE \
|
||||||
ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
|
ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
|
||||||
|
|
|
||||||
|
|
@ -3505,6 +3505,34 @@ static struct instruction *next_insn_to_validate(struct objtool_file *file,
|
||||||
return next_insn_same_sec(file, alt_group->orig_group->last_insn);
|
return next_insn_same_sec(file, alt_group->orig_group->last_insn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool skip_alt_group(struct instruction *insn)
|
||||||
|
{
|
||||||
|
struct instruction *alt_insn = insn->alts ? insn->alts->insn : NULL;
|
||||||
|
|
||||||
|
/* ANNOTATE_IGNORE_ALTERNATIVE */
|
||||||
|
if (insn->alt_group && insn->alt_group->ignore)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For NOP patched with CLAC/STAC, only follow the latter to avoid
|
||||||
|
* impossible code paths combining patched CLAC with unpatched STAC
|
||||||
|
* or vice versa.
|
||||||
|
*
|
||||||
|
* ANNOTATE_IGNORE_ALTERNATIVE could have been used here, but Linus
|
||||||
|
* requested not to do that to avoid hurting .s file readability
|
||||||
|
* around CLAC/STAC alternative sites.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!alt_insn)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Don't override ASM_{CLAC,STAC}_UNSAFE */
|
||||||
|
if (alt_insn->alt_group && alt_insn->alt_group->ignore)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return alt_insn->type == INSN_CLAC || alt_insn->type == INSN_STAC;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Follow the branch starting at the given instruction, and recursively follow
|
* Follow the branch starting at the given instruction, and recursively follow
|
||||||
* any other branches (jumps). Meanwhile, track the frame pointer state at
|
* any other branches (jumps). Meanwhile, track the frame pointer state at
|
||||||
|
|
@ -3625,7 +3653,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insn->alt_group && insn->alt_group->ignore)
|
if (skip_alt_group(insn))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (handle_insn_ops(insn, next_insn, &state))
|
if (handle_insn_ops(insn, next_insn, &state))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue