idt_table未定义!编译内核模块时发出警告 [英] idt_table undefined! warning when compiling kernel module

查看:153
本文介绍了idt_table未定义!编译内核模块时发出警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在内核模块中使用gate_desc *idt_table. desc.h中定义的set_trap_gate()函数使用此指针.在desc.h中也是一个定义:extern gate_desc idt_table[].

我尝试了不同的事情:

  • 在模块中使用idt_table不受定义或影响
  • 用我的(有效)idt_table地址影响idt_table 我在编译过程中收到id_table未定义的警告,或者idt_table的类型不完整.

  • 创建一个以实例gate_desc *it = (gate_desc *)@;命名的新var,并将set_trap_gateset_gatewrite_idt_entrypack_gate函数从sched.h复制到我的模块文件中(重命名它们并使用它)而不是idt_table).这样编译可以,但是在插入我的模块时,我在模块(ret -1)中得到了一个未知符号错误. (我的模块中没有对idt_table的引用,而我从sched使用的功能确实使用了我的变量).

我试图查看sched.h包含的文件中定义了idt_table的位置,但是找不到它!

有人知道我该如何使用sched.h中的idt_table指针(用正确的地址影响它)还是创建一个新的指针?

解决方案

从理论上讲,您可以通过以下方式实现非初始化节set_trap_gate():

void set_trap_gate(int n, void *addr)
{
    struct { uint16_t lim; struct desc_struct *idt_table; }
        __attribute__((packed)) idt;
    __asm__ ("sidt %0" : : "m"(idt) : "memory");
    _set_gate(idt.idt_table + n, 15, 0, addr);
}

但这将是CPU本地的,即,不能保证修改任何其他IDT,而是保证它正在运行的CPU之一.另外,它可能会受到写保护存储器的攻击.<​​/p>

您要实现的目标到底是什么?

I'm trying to use gate_desc *idt_table in a kernel module. The set_trap_gate() function defined in desc.h uses this pointer. In desc.h is also a definition : extern gate_desc idt_table[].

I tried different things:

  • use idt_table in my module without definition or affectation
  • affect idt_table with my (valid) idt_table address I get either an id_table undefined warning during compilation or incomplete type for idt_table.

  • creating a new var named for instance gate_desc *it = (gate_desc *)@; And copy the set_trap_gate, set_gate, write_idt_entry, pack_gate functions from sched.h to my module file (renaming them, and using it instead of idt_table). This compiles fine but when inserting my module I get an unknown symbol in module (ret -1) error. (there is no reference in my module to idt_table, and the functions I use from sched do use my variable).

I tried to see where in the files included by sched.h was defined idt_table, but couldn't find it!

Does someone know how I could use, the idt_table pointer from sched.h (affecting it with the corrct address) or create a new pointer?

解决方案

Theoretically, you could implement a non-init-section set_trap_gate() via:

void set_trap_gate(int n, void *addr)
{
    struct { uint16_t lim; struct desc_struct *idt_table; }
        __attribute__((packed)) idt;
    __asm__ ("sidt %0" : : "m"(idt) : "memory");
    _set_gate(idt.idt_table + n, 15, 0, addr);
}

But that'd be CPU-local, i.e. it's not guaranteed to modify any other IDT but the one of the CPU it's running on. Also, it might fall foul of writeprotected memory.

What exactly is it you're trying to achieve ?

这篇关于idt_table未定义!编译内核模块时发出警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆