-
Notifications
You must be signed in to change notification settings - Fork 36
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
base: main
Are you sure you want to change the base?
Conversation
vmm-reference-interrupts.md
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing
There was a problem hiding this 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.
There was a problem hiding this 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. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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?
```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) | ||
} | ||
``` |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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?
imported from codenet/vmm-reference#3