Skip to contentSkip to conversation

x86: Use helper in kprobes{32|64}.c

PATCH In review Harvey Harrison 2 participants 3 messages Dec 15, 2007 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Use helper in kprobes{32|64}.c

---
 arch/x86/kernel/kprobes_32.c |   18 +++++++++++-------
 arch/x86/kernel/kprobes_64.c |   14 ++++++++++++--
 2 files changed, 23 insertions(+), 9 deletions(-)
arch/x86/kernel/kprobes_32.c +11 -7
index 2a8acd6..878b0c4 100644
@@ -239,13 +239,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	if (!p->ainsn.insn)
 		return -ENOMEM;
 
-	memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
-	p->opcode = *p->addr;
-	if (can_boost(p->addr)) {
-		p->ainsn.boostable = 0;
-	} else {
-		p->ainsn.boostable = -1;
-	}
+	arch_copy_kprobe(p);
 	return 0;
 }
 
@@ -303,6 +297,15 @@ static s32 __kprobes *is_riprel(u8 *insn)
 
 static void __kprobes arch_copy_kprobe(struct kprobe *p)
 {
+#ifdef CONFIG_X86_32
+	memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
+	p->opcode = *p->addr;
+	if (can_boost(p->addr)) {
+		p->ainsn.boostable = 0;
+	} else {
+		p->ainsn.boostable = -1;
+	}
+#else
 	s32 *ripdisp;
 	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
 	ripdisp = is_riprel(p->ainsn.insn);
@@ -325,6 +328,7 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 		*ripdisp = disp;
 	}
 	p->opcode = *p->addr;
+#endif
 }
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)
arch/x86/kernel/kprobes_64.c +12 -2
index 5f02e75..b437f7a 100644
@@ -245,9 +245,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
 	/* insn: must be on special executable page on x86_32|64. */
 	p->ainsn.insn = get_insn_slot();
-	if (!p->ainsn.insn) {
+	if (!p->ainsn.insn)
 		return -ENOMEM;
-	}
+
 	arch_copy_kprobe(p);
 	return 0;
 }
@@ -306,6 +306,15 @@ static s32 __kprobes *is_riprel(u8 *insn)
 
 static void __kprobes arch_copy_kprobe(struct kprobe *p)
 {
+#ifdef CONFIG_X86_32
+	memcpy(p->ainsn.insn, p->addr, (MAX_INSN_SIZE + 1) * sizeof(kprobe_opcode_t));
+	p->opcode = *p->addr;
+	if (can_boost(p->addr)) {
+		p->ainsn.boostable = 0;
+	} else {
+		p->ainsn.boostable = -1;
+	}
+#else
 	s32 *ripdisp;
 	memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE);
 	ripdisp = is_riprel(p->ainsn.insn);
@@ -328,6 +337,7 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
 		*ripdisp = disp;
 	}
 	p->opcode = *p->addr;
+#endif
 }
 
 void __kprobes arch_arm_kprobe(struct kprobe *p)
Signature · 1 line
1.5.4.rc0.1083.gf568
#1 lore raw
Quoted 1 line · Harvey Harrison

x86: Use helper in kprobes{32|64}.c

thanks, i've applied your kprobes pre-unification patches to x86.git.

While we are at it, it might be nice to reduce the numbers of checkpatch warnings:

 $ scripts/checkpatch.pl --file arch/x86/kernel/kprobes*.c  | grep total
 total: 10 errors, 9 warnings, 959 lines checked
 total: 10 errors, 8 warnings, 923 lines checked

to 0/0 ? :-) (but that can happen after the unification too)

Ingo

#2 lore raw
Quoted 6 lines · Ingo Molnar
Quoted 1 line · Harvey Harrison

x86: Use helper in kprobes{32|64}.c

thanks, i've applied your kprobes pre-unification patches to x86.git.

Quoted 9 lines

While we are at it, it might be nice to reduce the numbers of checkpatch warnings:

 $ scripts/checkpatch.pl --file arch/x86/kernel/kprobes*.c  | grep total
 total: 10 errors, 9 warnings, 959 lines checked
 total: 10 errors, 8 warnings, 923 lines checked

to 0/0 ? :-) (but that can happen after the unification too)

That was my plan...you'll notice I already cut ~200 from each file though, so the lion's share is done. I'll have the final few in the series shortly.

Harvey