idt_table未定义!编译内核模块时发出警告 [英] idt_table undefined! warning when compiling kernel module
问题描述
我正在尝试在内核模块中使用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_gate
,set_gate
,write_idt_entry
,pack_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 anid_table
undefined warning during compilation or incomplete type foridt_table
.creating a new var named for instance
gate_desc *it = (gate_desc *)@;
And copy theset_trap_gate
,set_gate
,write_idt_entry
,pack_gate
functions from sched.h to my module file (renaming them, and using it instead ofidt_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屋!