Commit 78d9af4c authored by Oleg Nesterov's avatar Oleg Nesterov

uprobes/x86: Cleanup the usage of arch_uprobe->def.fixups, make it u8

handle_riprel_insn() assumes that nobody else could modify ->fixups
before. This is correct but fragile, change it to use "|=".

Also make ->fixups u8, we are going to add the new members into the
union. It is not clear why UPROBE_FIX_RIP_.X lived in the upper byte,
redefine them so that they can fit into u8.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
parent 97aa5cdd
...@@ -53,7 +53,7 @@ struct arch_uprobe { ...@@ -53,7 +53,7 @@ struct arch_uprobe {
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
long riprel_target; long riprel_target;
#endif #endif
u16 fixups; u8 fixups;
} def; } def;
}; };
}; };
......
...@@ -33,16 +33,16 @@ ...@@ -33,16 +33,16 @@
/* Post-execution fixups. */ /* Post-execution fixups. */
/* Adjust IP back to vicinity of actual insn */ /* Adjust IP back to vicinity of actual insn */
#define UPROBE_FIX_IP 0x1 #define UPROBE_FIX_IP 0x01
/* Adjust the return address of a call insn */ /* Adjust the return address of a call insn */
#define UPROBE_FIX_CALL 0x2 #define UPROBE_FIX_CALL 0x02
/* Instruction will modify TF, don't change it */ /* Instruction will modify TF, don't change it */
#define UPROBE_FIX_SETF 0x4 #define UPROBE_FIX_SETF 0x04
#define UPROBE_FIX_RIP_AX 0x8000 #define UPROBE_FIX_RIP_AX 0x08
#define UPROBE_FIX_RIP_CX 0x4000 #define UPROBE_FIX_RIP_CX 0x10
#define UPROBE_TRAP_NR UINT_MAX #define UPROBE_TRAP_NR UINT_MAX
...@@ -307,12 +307,12 @@ handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn) ...@@ -307,12 +307,12 @@ handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn)
* is NOT the register operand, so we use %rcx (register * is NOT the register operand, so we use %rcx (register
* #1) for the scratch register. * #1) for the scratch register.
*/ */
auprobe->def.fixups = UPROBE_FIX_RIP_CX; auprobe->def.fixups |= UPROBE_FIX_RIP_CX;
/* Change modrm from 00 000 101 to 00 000 001. */ /* Change modrm from 00 000 101 to 00 000 001. */
*cursor = 0x1; *cursor = 0x1;
} else { } else {
/* Use %rax (register #0) for the scratch register. */ /* Use %rax (register #0) for the scratch register. */
auprobe->def.fixups = UPROBE_FIX_RIP_AX; auprobe->def.fixups |= UPROBE_FIX_RIP_AX;
/* Change modrm from 00 xxx 101 to 00 xxx 000 */ /* Change modrm from 00 xxx 101 to 00 xxx 000 */
*cursor = (reg << 3); *cursor = (reg << 3);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment