未知符号flush_tlb_all(错误0)

时间:2018-08-29 16:56:34

标签: linux linux-kernel kernel linux-device-driver kernel-module

我试图制作一个简单的内核模块,通过用户级ioctl使所有tlb条目无效。

下面是我的示例代码[flush_tlb.c]

/*
 * flush_tlb.c
 */
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <asm/tlbflush.h>
#include <asm/tlb.h>

#include "flush_tlb.h"

MODULE_LICENSE("GPL");


static long flush_tlb_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
    int ret = 0;
    unsigned int size = _IOC_SIZE(cmd);
    void __user *ubuf = (void __user *)arg;
    struct flush_tlb_parv_t flush_tlb_parv;

    // copy an argument from user-level
    if (size != sizeof(struct flush_tlb_parv_t)) {
        ret = -EINVAL;
        goto out;
    }
    if (copy_from_user(&flush_tlb_parv, ubuf, sizeof(flush_tlb_parv))) {
        ret = -EFAULT;
        goto out;
    }

    if (flush_tlb_parv.addr) {
        // Not Implemented
        flush_tlb_all(); 
    } else {
        flush_tlb_all(); 
    }
out:
    return ret;
}

static const struct file_operations flush_tlb_fops = {
    .owner = THIS_MODULE,
    .unlocked_ioctl = flush_tlb_ioctl,
    .compat_ioctl = flush_tlb_ioctl,
};

static struct miscdevice binder_miscdev = {
    .minor = MISC_DYNAMIC_MINOR,
    .name = "flush_tlb",
    .fops = &flush_tlb_fops
};

static int __init flush_tlb_init(void)
{
    int ret;

    ret = misc_register(&binder_miscdev);

    return ret;
}
module_init(flush_tlb_init)


static void __exit flush_tlb_exit(void)
{
    misc_deregister(&binder_miscdev);
}
module_exit(flush_tlb_exit)

这是我的[Makefile]

obj-m += flush_tlb.o

all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

它已成功编译,但是当我通过insmod插入模块时,它失败并显示以下内核日志。 “ flush_tlb:未知符号flush_tlb_all(错误0)”

此外,我检查了/ proc / kallsyms符号表中是否存在flush_tlb_all。

$cat /proc/kallsyms | grep flush_tlb_all
ffffffff81022f90 T xen_flush_tlb_all
ffffffff810274a0 t trace_raw_output_xen_mmu_flush_tlb_all
ffffffff81027af0 t trace_event_raw_event_xen_mmu_flush_tlb_all
ffffffff81028c20 t perf_trace_xen_mmu_flush_tlb_all
ffffffff81072670 t do_flush_tlb_all
ffffffff81072bf0 T flush_tlb_all
ffffffff810792c0 t __flush_tlb_all
ffffffff8107d7cf t __flush_tlb_all
ffffffff81d76570 r __tracepoint_ptr_xen_mmu_flush_tlb_all
ffffffff81d77630 r __tpstrtab_xen_mmu_flush_tlb_all
ffffffff81e231f8 d print_fmt_xen_mmu_flush_tlb_all
ffffffff81e23f20 d trace_event_type_funcs_xen_mmu_flush_tlb_all
ffffffff81e24780 d event_xen_mmu_flush_tlb_all
ffffffff81f04720 d event_class_xen_mmu_flush_tlb_all
ffffffff81f103a0 D __tracepoint_xen_mmu_flush_tlb_all
ffffffff81f6772c t trace_event_define_fields_xen_mmu_flush_tlb_all
ffffffff8208c080 t __event_xen_mmu_flush_tlb_all

我该如何解决? 谢谢。

0 个答案:

没有答案