Normally objtool will now follow indirect calls; there is no need.
However, this becomes a problem with noinstr validation; if there's an
indirect call from noinstr code, we very much need to know it is to
another noinstr function. Luckily there aren't many indirect calls in
entry code with the obvious exception of paravirt. As such, noinstr
validation didn't work with paravirt kernels.
In order to track pv_ops[] call targets, objtool reads the static
pv_ops[] tables as well as direct assignments to the pv_ops[] array,
provided the compiler makes them a single instruction like:
bf87: 48 c7 05 00 00 00 00 00 00 00 00 movq $0x0,0x0(%rip)
bf92 <xen_init_spinlocks+0x5f>
bf8a: R_X86_64_PC32 pv_ops+0x268
There are, as of yet, no warnings for when this goes wrong :/
Using the functions found with the above means, all pv_ops[] calls are
now subject to noinstr validation.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210624095149.118815755@infradead.org
46 lines
1008 B
C
46 lines
1008 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2020 Matt Helsley <mhelsley@vmware.com>
|
|
*/
|
|
|
|
#ifndef _OBJTOOL_H
|
|
#define _OBJTOOL_H
|
|
|
|
#include <stdbool.h>
|
|
#include <linux/list.h>
|
|
#include <linux/hashtable.h>
|
|
|
|
#include <objtool/elf.h>
|
|
|
|
#define __weak __attribute__((weak))
|
|
|
|
struct pv_state {
|
|
bool clean;
|
|
struct list_head targets;
|
|
};
|
|
|
|
struct objtool_file {
|
|
struct elf *elf;
|
|
struct list_head insn_list;
|
|
DECLARE_HASHTABLE(insn_hash, 20);
|
|
struct list_head retpoline_call_list;
|
|
struct list_head static_call_list;
|
|
struct list_head mcount_loc_list;
|
|
bool ignore_unreachables, c_file, hints, rodata;
|
|
|
|
unsigned long jl_short, jl_long;
|
|
unsigned long jl_nop_short, jl_nop_long;
|
|
|
|
struct pv_state *pv_ops;
|
|
};
|
|
|
|
struct objtool_file *objtool_open_read(const char *_objname);
|
|
|
|
void objtool_pv_add(struct objtool_file *file, int idx, struct symbol *func);
|
|
|
|
int check(struct objtool_file *file);
|
|
int orc_dump(const char *objname);
|
|
int orc_create(struct objtool_file *file);
|
|
|
|
#endif /* _OBJTOOL_H */
|