Introduction to Xen Guest interrupts

Source: Internet
Author: User

In Xen 3.4.2, Xen Guest interrupts include both hardware interrupts and soft interrupts (Soft IRQ), in which the distribution of the former is held accountable after the Xen hypervisor, which is actually calling some functions in the Xen hypervisor. Can only be counted as simulations

The file associated with the former function is the Vmx_vmexit_handler function in the arch\x86\vmx\vmx.c file, and the latter is the DO_IRQ function of the arch\x86\irq.c file, which can be seen in the Xen, Timer Some interrupts of interrupt and UART are software outages.

Xen Guest interrupt interception test

In the context switch related experiments to note that for interrupts, both the external interrupt processing and exception handling, the effect is that the entire IDT table to hook.

Attach some code key point

In the Vmx_vmexit_handler function

switch (Exit_reason)
{
Case Exit_reason_exception_nmi:
{
/*
* We don ' t set the Software-interrupt exiting (INT N).         
* (1) We can get a exception (e.g. #PG) in the guest, or
* (2) NMI
*/
unsigned int intr_info, vector;
Intr_info = __vmread (Vm_exit_intr_info);
bug_on (!) ( Intr_info & Intr_info_valid_mask));
Vector = intr_info & intr_info_vector_mask;
//[superymk] Add hook_idt//<---------------------------Key Point
if (Hook_idt)
{
JOAN_DPR INTK ("int:%d\n", vector);
}
//[superymk] Add finished
/*
* re-set the NMI shadow if Vmexit caused by a GUE           St IRET Fault (3 b
* 25.7.1.2, "resuming Guest Software after handling a Exception").
 * (NB. If we emulate this IRET to any reason, we should re-clear!)
*/

In the DO_IRQ function

Spin_lock (&desc->lock);
Desc->handler->ack (vector);
if (Likely (Desc->status & irq_guest))
{
//[superymk] Add hook_idt//<------------   ---------------Key Point
if (Hook_idt)
{
Joan_dprintk ("int:%d\n", vector);
        
//[superymk] Add finished
Irq_enter ();
__do_irq_guest (vector);
Irq_exit ();
Spin_unlock (&desc->lock);
return;     
}
Desc->status &= ~irq_replay;
Desc->status |= irq_pending; 
/*
* Since We set PENDING, if another processor is handling a different
* instance of this Same IRQ, the other processor'll take care of it. 
*/
if (Desc->status & irq_disabled |      irq_inprogress))
Goto out;
Desc->status |= irq_inprogress;
Action = desc->action;
while (Desc->status & irq_pending)br> {
//[superymk] Add hook_idt//<---------------------------Key Point
if (Hook_idt)
{
JOAN_DPRINTK ("int:%d\n", vector);         
}
//[superymk] Add finished
desc->status &= ~irq_pending;
Irq_enter ();
Spin_unlock_irq (&desc->lock);
Action->handler (VECTOR_TO_IRQ (vector), action->dev_id, regs);
Spin_lock_irq (&desc->lock);
Irq_exit ();
}

The reason why all changes are made outside of Irq_enter () is that it minimizes the processing time of the IRQ. (They need to run at a high privilege level without verifying that irq_enter () will promote IRQL)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.