Linux 中 APIC 函数的帮助
我正在尝试使用 2.6.32.40 Linux 内核中的本地 APIC 函数,但遇到了一些问题。我想尝试向系统上的所有处理器发送不可屏蔽中断 (NMI)(我使用的是 Intel i7 Q740)。首先我阅读了英特尔软件开发人员手册第3卷中与APIC功能相关的文档。它指出可以通过使用位于地址 0xFEE00300 的中断命令寄存器 (ICR) 将中断广播到所有处理器。因此,我编写了一个具有以下 init 函数的内核模块,以尝试写入该寄存器:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
MODULE_LICENSE("GPL");
#define SUCCESS 0
#define ICR_ADDRESS 0xFEE00300
#define ICR_PROGRAM 0x000C4C89
static int icr_init(void){
int * ICR = (int *)ICR_ADDRESS;
printk(KERN_ALERT "Programing ICR\n");
*ICR = ICR_PROGRAM;
return SUCCESS;
}
static void icr_exit(void){
printk(KERN_ALERT "Removing ICR Programing module removed");
}
module_init(icr_init);
module_exit(icr_exit);
但是,当我 insmod 该模块时,内核崩溃并抱怨无法处理地址 00000000fee00300 的分页请求。查看 /proc/iomem 下,我发现该地址位于标记为“保留”的范围内,
fee00000-fee00fff : reserved
我也尝试使用 : 下的函数,
static inline void __default_local_send_IPI_allbutself(int vector)
但内核仍然抛出“无法处理分页请求”消息并崩溃。有人有什么建议吗?为什么这个内存范围被标记为“保留”,而不被标记为被本地 APIC 使用?提前致谢。
I'm trying to play around with the local APIC functions in the 2.6.32.40 linux kernel, but I am having some issues. I want to try to send a Non-Maskable Interrupts (NMI) to all of the processors on my system (I am using a Intel i7 Q740). First I read the documentation in Intel's Software Developer's Manual Volume 3 related to the APIC functions. It states that interrupts can be broadcast to all processors through the use of the Interrupt Command Register (ICR) located at address 0xFEE00300. So I wrote a kernel module with the following init function to try to write to this register:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
MODULE_LICENSE("GPL");
#define SUCCESS 0
#define ICR_ADDRESS 0xFEE00300
#define ICR_PROGRAM 0x000C4C89
static int icr_init(void){
int * ICR = (int *)ICR_ADDRESS;
printk(KERN_ALERT "Programing ICR\n");
*ICR = ICR_PROGRAM;
return SUCCESS;
}
static void icr_exit(void){
printk(KERN_ALERT "Removing ICR Programing module removed");
}
module_init(icr_init);
module_exit(icr_exit);
However, when I insmod this module the kernel crashes and complains about being unable to handle the paging request @ address 00000000fee00300. Looking under /proc/iomem I see that this address is in a ranged marked as "reserved"
fee00000-fee00fff : reserved
I've also tried using the functions under :
static inline void __default_local_send_IPI_allbutself(int vector)
but the kernel is still throwing "unable to handle paging request" messages and crashing. Does anyone have any suggestions? Why is this memory range marked as "reserved" and not marked as being used by the local APIC? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
APIC 地址是一个物理内存地址,但您试图将其作为线性内存地址进行访问 - 这就是您的第一种方法不起作用的原因。内存被标记为“保留”正是因为它属于 APIC,而不是真正的内存。
您应该使用内部内核函数。为此,您应该包含
并使用:The APIC address is a physical memory address, but you are trying to access it as a linear memory address - that's why your first approach doesn't work. The memory is marked as "reserved" precisely because it belongs to the APIC, rather than real memory.
You should use the internal kernel functions. To do so, you should include
<asm/apic.h>
and use: