Re: Adding a new interrupt handler to the IDT



Martin Feeney wrote:

I have a system which will be creating CPU interrupts via a user-supplied IDT value. I have a kernel module which will handle the interrupt - I just need to hook this code into the interrupt handler mechanism. I cannot find any documentation on how to create an entry in the IDT or to identify the linkage protocol (assuming I can create an IDT entry).

Note: These are NOT IRQs and, therefore, the request_irq() services cannot be used. This would be equivalent to creating a handler for the INT instruction.


Are you intending to create a back-door to the kernel via
an int instruction?

Where are the non-irq interrupts coming from, and how do
the get onto the CPU chip?


No, this is not a kernel backdoor. I will be running Linux under a custom hipervisor. The hipervisor can signal the guest (i.e. Linux) via an interrupt to handle certain events. I want to insert a handler into the IDT to handle these events. I want my device driver code to use Linux services if they are available rather than writing my custom code to tweak the IDT. I just haven't found these services...

I don't have 2.6 sources available just now, but in kernel 2.4
the interrupt gates are set up in the interrupt controller
driver function init_IRQ(). The setup function is set_intr_gate().

Probably the easiest place to find the vector setup is at
/usr/src/linux/arch/i386/kernel/i8259.c.

The gate setup routines are in
/usr/src/linux/arch/i386/kernel/traps.c

You'll probably like to have a trap handler instead of an
interrupt handler in this case. The handler may need some
assembly code to work properly.

HTH

--

Tauno Voipio
tauno voipio (at) iki fi
.



Relevant Pages

  • Q: wait queue weirdness in A/D device driver - 2.4.18 or 20, RH 8.0
    ... "master buffer" at interrupt time and wake up any ... it should be because the int handler has now placed data into the master ... I'm using gcc 2.95.3 for both kernel and module (due to a suggestion on ... into the queue. ...
    (comp.os.linux.development.system)
  • Re: PROBLEM: Interrupt Handling Code (handle_IRQ_event)
    ... > checking each action handler to disable/enable ... > interrupt line ... but then can you tell me the use of telling kernel ... Moreover as explained in Interrupt handling chapter of Linux Device ...
    (Linux-Kernel)
  • Re: Sleeping thread not receive signal until it wakes up
    ... of the thread will keep calling IOCTL to get information from the ... kernel and will be blocked if there is no new information. ... and register a SIGALRM handler in the thread by using sigaction. ... the ISR routine when interrupt happens, ...
    (Linux-Kernel)
  • Re: Installable ISR - general questions
    ... The ISR (Interrupt Service Routine) is called by the interrupt ... handler installed by the OS. ... SYSINTR_RESCHEDULE tells the kernel that it should check if a thread ...
    (microsoft.public.windowsce.platbuilder)
  • PROBLEM: Interrupt Handling Code (handle_IRQ_event)
    ... I found a bug in interrupt handling code of Kernel. ... checking the flag of only the first handler for IRQ ...
    (Linux-Kernel)