2010-09-17 23:09:00 +08:00
|
|
|
#ifndef _LINUX_JUMP_LABEL_H
|
|
|
|
#define _LINUX_JUMP_LABEL_H
|
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
|
2010-10-30 00:33:43 +08:00
|
|
|
#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
|
2011-03-17 05:29:47 +08:00
|
|
|
|
|
|
|
struct jump_label_key {
|
|
|
|
atomic_t enabled;
|
|
|
|
struct jump_entry *entries;
|
|
|
|
#ifdef CONFIG_MODULES
|
|
|
|
struct jump_label_mod *next;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2010-09-17 23:09:00 +08:00
|
|
|
# include <asm/jump_label.h>
|
|
|
|
# define HAVE_JUMP_LABEL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum jump_label_type {
|
2011-03-17 05:29:47 +08:00
|
|
|
JUMP_LABEL_DISABLE = 0,
|
2010-09-17 23:09:00 +08:00
|
|
|
JUMP_LABEL_ENABLE,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct module;
|
|
|
|
|
|
|
|
#ifdef HAVE_JUMP_LABEL
|
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
#ifdef CONFIG_MODULES
|
|
|
|
#define JUMP_LABEL_INIT {{ 0 }, NULL, NULL}
|
|
|
|
#else
|
|
|
|
#define JUMP_LABEL_INIT {{ 0 }, NULL}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static __always_inline bool static_branch(struct jump_label_key *key)
|
|
|
|
{
|
|
|
|
return arch_static_branch(key);
|
|
|
|
}
|
|
|
|
|
2010-09-17 23:09:00 +08:00
|
|
|
extern struct jump_entry __start___jump_table[];
|
|
|
|
extern struct jump_entry __stop___jump_table[];
|
|
|
|
|
2010-10-02 05:23:48 +08:00
|
|
|
extern void jump_label_lock(void);
|
|
|
|
extern void jump_label_unlock(void);
|
2010-09-17 23:09:00 +08:00
|
|
|
extern void arch_jump_label_transform(struct jump_entry *entry,
|
|
|
|
enum jump_label_type type);
|
2010-09-17 23:09:08 +08:00
|
|
|
extern void arch_jump_label_text_poke_early(jump_label_t addr);
|
|
|
|
extern int jump_label_text_reserved(void *start, void *end);
|
2011-03-17 05:29:47 +08:00
|
|
|
extern void jump_label_inc(struct jump_label_key *key);
|
|
|
|
extern void jump_label_dec(struct jump_label_key *key);
|
|
|
|
extern bool jump_label_enabled(struct jump_label_key *key);
|
|
|
|
extern void jump_label_apply_nops(struct module *mod);
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
#else
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-07-27 07:09:06 +08:00
|
|
|
#include <linux/atomic.h>
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
#define JUMP_LABEL_INIT {ATOMIC_INIT(0)}
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
struct jump_label_key {
|
|
|
|
atomic_t enabled;
|
|
|
|
};
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
static __always_inline bool static_branch(struct jump_label_key *key)
|
|
|
|
{
|
|
|
|
if (unlikely(atomic_read(&key->enabled)))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
static inline void jump_label_inc(struct jump_label_key *key)
|
|
|
|
{
|
|
|
|
atomic_inc(&key->enabled);
|
|
|
|
}
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
static inline void jump_label_dec(struct jump_label_key *key)
|
2010-09-17 23:09:00 +08:00
|
|
|
{
|
2011-03-17 05:29:47 +08:00
|
|
|
atomic_dec(&key->enabled);
|
2010-09-17 23:09:00 +08:00
|
|
|
}
|
|
|
|
|
2010-09-17 23:09:08 +08:00
|
|
|
static inline int jump_label_text_reserved(void *start, void *end)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-02 05:23:48 +08:00
|
|
|
static inline void jump_label_lock(void) {}
|
|
|
|
static inline void jump_label_unlock(void) {}
|
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
static inline bool jump_label_enabled(struct jump_label_key *key)
|
|
|
|
{
|
|
|
|
return !!atomic_read(&key->enabled);
|
|
|
|
}
|
2010-09-17 23:09:00 +08:00
|
|
|
|
2011-03-17 05:29:47 +08:00
|
|
|
static inline int jump_label_apply_nops(struct module *mod)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2010-10-17 18:15:00 +08:00
|
|
|
|
2010-09-17 23:09:00 +08:00
|
|
|
#endif
|