| Date | Thu, 3 Mar 2022 11:53:44 +0100 (CET) | From | Miroslav Benes <> | Subject | Re: [PATCH v2 33/39] objtool: Add IBT/ENDBR decoding |
| |
Hi,
On Thu, 24 Feb 2022, Peter Zijlstra wrote:
> Decode ENDBR instructions and WARN about NOTRACK prefixes.
I guess it has been already mentioned somewhere, but could you explain NOTRACK prefix here, please? If I understand it right, it disables IBT for the indirect branch instruction meaning that its target does not have to start with ENDBR?
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> > --- > tools/objtool/arch/x86/decode.c | 34 +++++++++++++++++++++++++++++----- > tools/objtool/include/objtool/arch.h | 1 + > 2 files changed, 30 insertions(+), 5 deletions(-) > > --- a/tools/objtool/arch/x86/decode.c > +++ b/tools/objtool/arch/x86/decode.c > @@ -103,6 +103,18 @@ unsigned long arch_jump_destination(stru > #define rm_is_mem(reg) (mod_is_mem() && !is_RIP() && rm_is(reg)) > #define rm_is_reg(reg) (mod_is_reg() && modrm_rm == (reg)) > > +static bool has_notrack_prefix(struct insn *insn) > +{ > + int i; > + > + for (i = 0; i < insn->prefixes.nbytes; i++) { > + if (insn->prefixes.bytes[i] == 0x3e) > + return true; > + } > + > + return false; > +} > +
...
> @@ -636,20 +656,24 @@ int arch_decode_instruction(struct objto > break; > > case 0xff: > - if (modrm_reg == 2 || modrm_reg == 3) > + if (modrm_reg == 2 || modrm_reg == 3) { > > *type = INSN_CALL_DYNAMIC; > + if (has_notrack_prefix(&insn)) > + WARN("notrack prefix found at %s:0x%lx", sec->name, offset); > > - else if (modrm_reg == 4) > + } else if (modrm_reg == 4) { > > *type = INSN_JUMP_DYNAMIC; > + if (has_notrack_prefix(&insn)) > + WARN("notrack prefix found at %s:0x%lx", sec->name, offset);
And we want to warn about it here so that we can have it all in the kernel control?
Miroslav
|