4

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.

4

1 回答 1

3

APIC 地址是物理内存地址,但您试图将其作为线性内存地址进行访问——这就是您的第一种方法不起作用的原因。内存被标记为“保留”正是因为它属于 APIC,而不是真正的内存。

您应该使用内部内核函数。为此,您应该包括<asm/apic.h>并使用:

apic->send_IPI_allbutself(vector);
于 2011-08-11T07:13:45.747 回答