diff for duplicates of <555370B9.2070203@redhat.com> diff --git a/a/1.txt b/N1/1.txt index 8e2bffd..6c22d9e 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -47,11 +47,3 @@ fffffe00000b7b34 T do_fork The patch should look similar to the x86 code. The x86 code was used as a model. -Will - --------------- next part -------------- -A non-text attachment was scrubbed... -Name: kprobe_reentry_example.c -Type: text/x-csrc -Size: 2827 bytes -Desc: not available -URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150513/d4c30667/attachment.bin> diff --git a/N1/2.hdr b/N1/2.hdr new file mode 100644 index 0000000..7d75fae --- /dev/null +++ b/N1/2.hdr @@ -0,0 +1,5 @@ +Content-Type: text/x-csrc; + name="kprobe_reentry_example.c" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="kprobe_reentry_example.c" diff --git a/N1/2.txt b/N1/2.txt new file mode 100644 index 0000000..f5fc152 --- /dev/null +++ b/N1/2.txt @@ -0,0 +1,109 @@ +/* + * NOTE: This example is designed to check that the kprobe reentry work. + * + * For more information on theory of operation of kprobes, see + * Documentation/kprobes.txt + * + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/kprobes.h> + +/* For each probe you need to allocate a kprobe structure */ +static struct kprobe kp = { + .symbol_name = "do_fork", +}; + +static struct kprobe kp_re = { + .symbol_name = "int_sqrt", +}; + +static unsigned long y=0; +static unsigned long z=0; + +/* kprobe pre_handler: called just before the probed instruction is executed */ +static int handler_pre(struct kprobe *p, struct pt_regs *regs) +{ + /* call another function that is instrumented with a kprobe to + ensure that reentry works */ + unsigned long x=1764; + y = int_sqrt(x); + return 0; +} + +/* kprobe post_handler: called after the probed instruction is executed */ +static void handler_post(struct kprobe *p, struct pt_regs *regs, + unsigned long flags) +{ + return; +} + +/* kprobe pre_handler: called just before the probed instruction is executed */ +static int handler_pre_re(struct kprobe *p, struct pt_regs *regs) +{ + /* if reentry is working as expected this code may not be executed */ + z = 0xdeadbeef; + return 0; +} + +/* kprobe post_handler: called after the probed instruction is executed */ +static void handler_post_re(struct kprobe *p, struct pt_regs *regs, + unsigned long flags) +{ + return; +} + +/* + * fault_handler: this is called if an exception is generated for any + * instruction within the pre- or post-handler, or when Kprobes + * single-steps the probed instruction. + */ +static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr) +{ + printk(KERN_INFO "fault_handler: p->addr = 0x%p, trap #%dn", + p->addr, trapnr); + /* Return 0 because we don't handle the fault. */ + return 0; +} + +static int __init kprobe_init(void) +{ + int ret; + kp.pre_handler = handler_pre; + kp.post_handler = handler_post; + kp.fault_handler = handler_fault; + + ret = register_kprobe(&kp); + if (ret < 0) { + printk(KERN_INFO "register_kprobe failed, returned %d\n", ret); + return ret; + } + printk(KERN_INFO "Planted kprobe at %p\n", kp.addr); + + kp_re.pre_handler = handler_pre_re; + kp_re.post_handler = handler_post_re; + kp_re.fault_handler = handler_fault; + + ret = register_kprobe(&kp_re); + if (ret < 0) { + printk(KERN_INFO "register_kprobe failed, returned %d\n", ret); + return ret; + } + printk(KERN_INFO "Planted kprobe at %p\n", kp_re.addr); + return 0; +} + +static void __exit kprobe_exit(void) +{ + unregister_kprobe(&kp); + printk(KERN_INFO "kprobe at %p unregistered\n", kp.addr); + unregister_kprobe(&kp_re); + printk(KERN_INFO "kprobe at %p unregistered\n", kp_re.addr); + printk(KERN_INFO "y = %ld\n", y); + printk(KERN_INFO "z = %lx\n", z); +} + +module_init(kprobe_init) +module_exit(kprobe_exit) +MODULE_LICENSE("GPL"); diff --git a/a/content_digest b/N1/content_digest index 7c5902e..86c8df0 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -9,11 +9,23 @@ "ref\055519583.9020507@linaro.org\0" "ref\05551F693.8050100@redhat.com\0" "ref\0555317E8.2000502@hitachi.com\0" - "From\0wcohen@redhat.com (William Cohen)\0" - "Subject\0[PATCH v6 0/6] arm64: Add kernel probes (kprobes) support\0" + "From\0William Cohen <wcohen@redhat.com>\0" + "Subject\0Re: [PATCH v6 0/6] arm64: Add kernel probes (kprobes) support\0" "Date\0Wed, 13 May 2015 11:41:45 -0400\0" - "To\0linux-arm-kernel@lists.infradead.org\0" - "\00:1\0" + "To\0Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>" + David Long <dave.long@linaro.org> + " Will Deacon <will.deacon@arm.com>\0" + "Cc\0linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org>" + Russell King <linux@arm.linux.org.uk> + sandeepa.s.prabhu@gmail.com <sandeepa.s.prabhu@gmail.com> + Steve Capper <steve.capper@linaro.org> + Catalin Marinas <Catalin.Marinas@arm.com> + Jon Medhurst (Tixy) <tixy@linaro.org> + Ananth N Mavinakayanahalli <ananth@in.ibm.com> + Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> + davem@davemloft.net <davem@davemloft.net> + " linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>\0" + "\01:1\0" "b\0" "On 05/13/2015 05:22 AM, Masami Hiramatsu wrote:\n" "> On 2015/05/12 21:48, William Cohen wrote:\n" @@ -63,14 +75,118 @@ "\n" "The patch should look similar to the x86 code. The x86 code was used as a model.\n" "\n" - "-Will\n" + -Will + "\01:2\0" + "fn\0kprobe_reentry_example.c\0" + "b\0" + "/*\n" + " * NOTE: This example is designed to check that the kprobe reentry work.\n" + " *\n" + " * For more information on theory of operation of kprobes, see\n" + " * Documentation/kprobes.txt\n" + " *\n" + " */\n" + "\n" + "#include <linux/kernel.h>\n" + "#include <linux/module.h>\n" + "#include <linux/kprobes.h>\n" + "\n" + "/* For each probe you need to allocate a kprobe structure */\n" + "static struct kprobe kp = {\n" + "\t.symbol_name\t= \"do_fork\",\n" + "};\n" + "\n" + "static struct kprobe kp_re = {\n" + "\t.symbol_name\t= \"int_sqrt\",\n" + "};\n" + "\n" + "static unsigned long y=0;\n" + "static unsigned long z=0;\n" + "\n" + "/* kprobe pre_handler: called just before the probed instruction is executed */\n" + "static int handler_pre(struct kprobe *p, struct pt_regs *regs)\n" + "{\n" + " /* call another function that is instrumented with a kprobe to\n" + " ensure that reentry works */\n" + " unsigned long x=1764;\n" + " y = int_sqrt(x);\n" + " return 0;\n" + "}\n" + "\n" + "/* kprobe post_handler: called after the probed instruction is executed */\n" + "static void handler_post(struct kprobe *p, struct pt_regs *regs,\n" + "\t\t\t\tunsigned long flags)\n" + "{\n" + " return;\n" + "}\n" + "\n" + "/* kprobe pre_handler: called just before the probed instruction is executed */\n" + "static int handler_pre_re(struct kprobe *p, struct pt_regs *regs)\n" + "{\n" + " /* if reentry is working as expected this code may not be executed */\n" + " z = 0xdeadbeef;\n" + " return 0;\n" + "}\n" + "\n" + "/* kprobe post_handler: called after the probed instruction is executed */\n" + "static void handler_post_re(struct kprobe *p, struct pt_regs *regs,\n" + "\t\t\t\tunsigned long flags)\n" + "{\n" + " return;\n" + "}\n" + "\n" + "/*\n" + " * fault_handler: this is called if an exception is generated for any\n" + " * instruction within the pre- or post-handler, or when Kprobes\n" + " * single-steps the probed instruction.\n" + " */\n" + "static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr)\n" + "{\n" + "\tprintk(KERN_INFO \"fault_handler: p->addr = 0x%p, trap #%dn\",\n" + "\t\tp->addr, trapnr);\n" + "\t/* Return 0 because we don't handle the fault. */\n" + "\treturn 0;\n" + "}\n" + "\n" + "static int __init kprobe_init(void)\n" + "{\n" + "\tint ret;\n" + "\tkp.pre_handler = handler_pre;\n" + "\tkp.post_handler = handler_post;\n" + "\tkp.fault_handler = handler_fault;\n" + "\n" + "\tret = register_kprobe(&kp);\n" + "\tif (ret < 0) {\n" + "\t\tprintk(KERN_INFO \"register_kprobe failed, returned %d\\n\", ret);\n" + "\t\treturn ret;\n" + "\t}\n" + "\tprintk(KERN_INFO \"Planted kprobe at %p\\n\", kp.addr);\n" + "\n" + "\tkp_re.pre_handler = handler_pre_re;\n" + "\tkp_re.post_handler = handler_post_re;\n" + "\tkp_re.fault_handler = handler_fault;\n" + "\n" + "\tret = register_kprobe(&kp_re);\n" + "\tif (ret < 0) {\n" + "\t\tprintk(KERN_INFO \"register_kprobe failed, returned %d\\n\", ret);\n" + "\t\treturn ret;\n" + "\t}\n" + "\tprintk(KERN_INFO \"Planted kprobe at %p\\n\", kp_re.addr);\n" + "\treturn 0;\n" + "}\n" + "\n" + "static void __exit kprobe_exit(void)\n" + "{\n" + "\tunregister_kprobe(&kp);\n" + "\tprintk(KERN_INFO \"kprobe at %p unregistered\\n\", kp.addr);\n" + "\tunregister_kprobe(&kp_re);\n" + "\tprintk(KERN_INFO \"kprobe at %p unregistered\\n\", kp_re.addr);\n" + "\tprintk(KERN_INFO \"y = %ld\\n\", y);\n" + "\tprintk(KERN_INFO \"z = %lx\\n\", z);\n" + "}\n" "\n" - "-------------- next part --------------\n" - "A non-text attachment was scrubbed...\n" - "Name: kprobe_reentry_example.c\n" - "Type: text/x-csrc\n" - "Size: 2827 bytes\n" - "Desc: not available\n" - URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150513/d4c30667/attachment.bin> + "module_init(kprobe_init)\n" + "module_exit(kprobe_exit)\n" + "MODULE_LICENSE(\"GPL\");" -5b7ad5278889c226daf3668b25f483d4359af3f1a112b35a4e338b5e804c748f +4c5b16e71205a5c9f6ac1aa520e9ad85ce3332d904b88177bf5da88033c14e94
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.