Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description of interrupts module in x86_64 #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anirudhakulkarni
Copy link

imported from codenet/vmm-reference#3

@anirudhakulkarni anirudhakulkarni changed the title Create vmm-reference-interrupts.md Description of interrupts module in x86_64 Sep 12, 2022
@@ -0,0 +1,116 @@
# Interrupts (x86_64 architecture)
* source file: vmm-reference/src/vm-vcpu/src/x86_64/interrupts.rs
* Note: This document only covers the x86_64 architecture. For aarch64, the interrupt controller is called GIC (Generic Interrupt Controller). Refer to vmm-reference/src/vm-vcpu/src/aarch64/interrupts.rs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing

@anirudhakulkarni
Copy link
Author

@arch1902 @Intact01 updated. Kindly review

Copy link

@SatyamModi SatyamModi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Owner

@codenet codenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decent PR. Well done!

* source file: vmm-reference/src/vm-vcpu-ref/src/x86_64/interrupts.rs
* Note: This document only covers the x86_64 architecture. For aarch64, the interrupt controller is called GIC (Generic Interrupt Controller). Refer to vmm-reference/src/vm-vcpu-ref/src/aarch64/interrupts.rs
## Local Advanced Programmable Interrupt Controller (LAPIC)
LAPIC is a memory-mapped device that is used to send interrupts to the VCPUs. It is used to send interrupts to the VCPUs and to receive interrupts from the VCPUs. It is also used to send inter-processor interrupts (IPIs) to the VCPUs.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant first two sentences. You can change to :

LAPIC is a memory-mapped device that is used to send/receive interrupts to/from the VCPUs.

## Local Advanced Programmable Interrupt Controller (LAPIC)
LAPIC is a memory-mapped device that is used to send interrupts to the VCPUs. It is used to send interrupts to the VCPUs and to receive interrupts from the VCPUs. It is also used to send inter-processor interrupts (IPIs) to the VCPUs.

There are five delivery modes for interrupts:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be good to know the source of this information. Example "According to the Section xyz from Intel Manual volume abc".


## Usage in code

While creating a new ```kvmVcpu```, LAPICs for the vcpu is created and initialized with ```configure_lapic``` function. The function ```configure_lapic``` initializes the LAPICs with the following values:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which file exactly is this in?

Comment on lines +92 to +99
```rust
fn configure_lapic(&self) -> Result<()> {
let mut klapic: kvm_lapic_state = self.vcpu_fd.get_lapic().map_err(Error::KvmIoctl)?;
set_klapic_delivery_mode(&mut klapic, APIC_LVT0_REG_OFFSET, DeliveryMode::ExtINT).unwrap();
set_klapic_delivery_mode(&mut klapic, APIC_LVT1_REG_OFFSET, DeliveryMode::NMI).unwrap();
self.vcpu_fd.set_lapic(&klapic).map_err(Error::KvmIoctl)
}
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved to the markdown file that explains the parent rust file that holds configure_lapic. configure_lapic explanation in the other file can keep a pointer to this file to know more about LAPICs.

self.vcpu_fd.set_lapic(&klapic).map_err(Error::KvmIoctl)
}
```
Here `APIC_LVT0_REG_OFFSET` is the register offset corresponding to the APIC Local Vector Table for LINT0 and set to `0x350` and `APIC_LVT1_REG_OFFSET` is the register offset corresponding to the APIC Local Vector Table for LINT1 and set to `0x360`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the significance of 0x350 and 0x360?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants