Question

I installed XenServer 6.0.0 and DDK, and I want to develop a kernel module, so I code a basic kprobes program. It is running OK on normal linux like redhat and output "Before sys_ioctl", but on XenServer it just output "Hypercall FI kernel module: init", and can not output "Before sys_ioctl".

So, what is the reason? XenServer doesn't support Kprobes or my program have bugs?

Here is my simple code. kp.addr is different based on cat /proc/kallsyms | grep sys_ioctl, and I tried do_fork, question is also exist.

#include <linux/kprobes.h>
#include <linux/kallsyms.h>
#include <linux/module.h>

static struct kprobe kp;

int handler_pre_target(struct kprobe *p, struct pt_regs *regs)
{
    printk("Before sys_ioctl\n");
    return 0;
}

static int __init myinit(void)
{
    kp.addr = (kprobe_opcode_t *) 0xc048498d;
    kp.pre_handler = handler_pre_target;
    register_kprobe(&kp);
    printk("Hypercall FI kernel module: init\n");
    return 0;
}

static void __exit myexit(void)
{
    unregister_kprobe(&kp);
    printk("Hypercall FI kernel module: exit\n");
}

module_init(myinit);
module_exit(myexit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("fg");
MODULE_DESCRIPTION("Hypercall test");
Was it helpful?

Solution

Finally, I solved this problem. I used XenServer 6.1 and 6.1.0 ddk, and that's OK.

kernel version is:2.6.32.43-0.4.1.xs1.6.10.741.170752xen

I suspect it was a bug that can not use kprobes in XenServer 6.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top