@@ -28,16 +28,17 @@
static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
{
- asm goto("1: nop\n\t"
+ asm goto("1: b %l[l_no]\n\t"
".pushsection __jump_table, \"aw\"\n\t"
".align 3\n\t"
- ".quad 1b, %l[l_yes], %c0\n\t"
+ ".word %c0 - 1b\n\t"
+ "nop\n\t"
+ ".quad %c0\n\t"
".popsection\n\t"
- : : "i"(&((char *)key)[branch]) : : l_yes);
-
- return false;
-l_yes:
+ : : "i"(&((char *)key)[branch]) : : l_no);
return true;
+l_no:
+ return false;
}
static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
@@ -45,10 +46,11 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
asm goto("1: b %l[l_yes]\n\t"
".pushsection __jump_table, \"aw\"\n\t"
".align 3\n\t"
- ".quad 1b, %l[l_yes], %c0\n\t"
+ ".word %c0 - 1b\n\t"
+ "nop\n\t"
+ ".quad %c0\n\t"
".popsection\n\t"
: : "i"(&((char *)key)[branch]) : : l_yes);
-
return false;
l_yes:
return true;
@@ -57,8 +59,8 @@ l_yes:
typedef u64 jump_label_t;
struct jump_entry {
- jump_label_t code;
- jump_label_t target;
+ s32 offset;
+ u32 insn;
jump_label_t key;
...skipping...
@@ -45,10 +46,11 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool
asm goto("1: b %l[l_yes]\n\t"
".pushsection __jump_table, \"aw\"\n\t"
".align 3\n\t"
- ".quad 1b, %l[l_yes], %c0\n\t"
+ ".word %c0 - 1b\n\t"
+ "nop\n\t"
+ ".quad %c0\n\t"
".popsection\n\t"
: : "i"(&((char *)key)[branch]) : : l_yes);
-
return false;
l_yes:
return true;
@@ -57,8 +59,8 @@ l_yes:
typedef u64 jump_label_t;
struct jump_entry {
- jump_label_t code;
- jump_label_t target;
+ s32 offset;
+ u32 insn;
jump_label_t key;
};
@@ -25,17 +25,10 @@
void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
{
- void *addr = (void *)entry->code;
- u32 insn;
-
- if (type == JUMP_LABEL_JMP) {
- insn = aarch64_insn_gen_branch_imm(entry->code,
- entry->target,
- AARCH64_INSN_BRANCH_NOLINK);
- } else {
- insn = aarch64_insn_gen_nop();
- }
-
+ void *addr = (void *)entry->key - entry->offset;
+ u32 old = *(u32*)addr;
+ u32 insn = entry->insn;
+ entry->insn = old;
aarch64_insn_patch_text(&addr, &insn, 1);
}
---