Skip to content

Commit e27e5be

Browse files
jpoimboebonzini
authored andcommitted
x86/ibt, objtool: Add IBT_NOSEAL()
Add a macro which prevents a function from getting sealed if there are no compile-time references to it. Signed-off-by: Josh Poimboeuf <[email protected]> Message-Id: <20220818213927.e44fmxkoq4yj6ybn@treble> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 20ec3eb commit e27e5be

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

arch/x86/include/asm/ibt.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131

3232
#define __noendbr __attribute__((nocf_check))
3333

34+
/*
35+
* Create a dummy function pointer reference to prevent objtool from marking
36+
* the function as needing to be "sealed" (i.e. ENDBR converted to NOP by
37+
* apply_ibt_endbr()).
38+
*/
39+
#define IBT_NOSEAL(fname) \
40+
".pushsection .discard.ibt_endbr_noseal\n\t" \
41+
_ASM_PTR fname "\n\t" \
42+
".popsection\n\t"
43+
3444
static inline __attribute_const__ u32 gen_endbr(void)
3545
{
3646
u32 endbr;
@@ -84,6 +94,7 @@ extern __noendbr void ibt_restore(u64 save);
8494
#ifndef __ASSEMBLY__
8595

8696
#define ASM_ENDBR
97+
#define IBT_NOSEAL(name)
8798

8899
#define __noendbr
89100

tools/objtool/check.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4096,7 +4096,8 @@ static int validate_ibt(struct objtool_file *file)
40964096
* These sections can reference text addresses, but not with
40974097
* the intent to indirect branch to them.
40984098
*/
4099-
if (!strncmp(sec->name, ".discard", 8) ||
4099+
if ((!strncmp(sec->name, ".discard", 8) &&
4100+
strcmp(sec->name, ".discard.ibt_endbr_noseal")) ||
41004101
!strncmp(sec->name, ".debug", 6) ||
41014102
!strcmp(sec->name, ".altinstructions") ||
41024103
!strcmp(sec->name, ".ibt_endbr_seal") ||

0 commit comments

Comments
 (0)