-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add ACPI support for x86_64 #3190
Conversation
2ed2409
to
28df0dd
Compare
src/vmm/src/device_manager/mmio.rs
Outdated
let irqs = (0..irq_count) | ||
.map(|_| self.irq_allocator.allocate_id()) | ||
.collect::<vm_allocator::Result<_>>() | ||
pub(crate) fn allocate_mmio_resources( |
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.
pub(crate) fn allocate_mmio_resources( | |
fn allocate_mmio_resources( |
As per review on #3124 , we don't need to make this public.
This associated function is used only inside this file.
Keeping this private can avoid misuse (e.g., only allocates MMIO resources, but not register them to KVM).
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.
You are right! Ty!
28df0dd
to
53b142e
Compare
Mostly a note to self, we need to update ci artifacts with kernels that include ACPI support. Otherwise we'll keep seeing the CI failing. |
99d81e3
to
f5b893d
Compare
Right now we have one pair of (IdAllocator, AddressAllocator) per device manager (mmio and legacy for x86, mmio for aarch64) and we separate the resources (GSIs and guest memory) these handle. With ACPI we will add new types of devices that will need as well GSIs and guest memory, which would mean that with the current way of things we would need to create yet another pair of allocators. This fragments the resources (we should divide the GSIs used by ACPI and MMIO devices for example) and keeps information about them fragmented. This commit introduces a global resource manager for GSIs and guest memory. Its scope is the whole VM rather than type of devices, so we can avoid the aforementioned fragmentation. Signed-off-by: Babis Chalios <[email protected]>
Introduce ACPI tables based on the Cloud-hypervisor implementation. Expose basic ACPI tables inside the guest VM. Currently, we do not expose devices through ACPI. Signed-off-by: Babis Chalios <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]>
Define devices in AML bytecode and include it in the DSDT table. This includes all virtio and legacy devices. This allows us to not define devices in the kernel command line any more. Signed-off-by: Babis Chalios <[email protected]>
We rely on the MADT (APIC) ACPI table to provide the related functionality. We will require ACPI-enabled systems. Signed-off-by: Babis Chalios <[email protected]>
At the moment, we pass devtool a kernel configuration when building. The script parses the kernel version from the configuration file in order to fetch the proper tarball with kernel source to build. However, at the moment it only parses up to major version so, for example, a configuration produced from 4.14.174 would result in 4.14 being built. This commit changes the regex used for parsing in order to parse the minor version as well. Signed-off-by: Babis Chalios <[email protected]>
When this commit is done it should include the minimum needed kernel configs for ACPI-enabled Firecracker to work. At the moment it includes changes for x86 which are not minimal. Signed-off-by: Babis Chalios <[email protected]>
Change the CI artifacts s3 bucket we use in our pytest framework to point to one which includes vmlinux images with ACPI support. This commit should be dropped once we are done testing and ready to merge to main. Signed-off-by: Babis Chalios <[email protected]>
f5b893d
to
4627248
Compare
// Disable VGA probing | ||
const IAPC_BOOT_ARG_FLAGS_VGA_NOT_PRESENT: u8 = 2; | ||
// Do not enable MSI | ||
const IAPC_BOOT_ARG_FLAGS_MSI_NOT_PRESENT: u8 = 3; | ||
// Do not enable ASPM control | ||
const IAPC_BOOT_ARG_FLAGS_PCI_ASPM: u8 = 4; |
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.
Would it not be easier to define them as their masks?
// Disable VGA probing | |
const IAPC_BOOT_ARG_FLAGS_VGA_NOT_PRESENT: u8 = 2; | |
// Do not enable MSI | |
const IAPC_BOOT_ARG_FLAGS_MSI_NOT_PRESENT: u8 = 3; | |
// Do not enable ASPM control | |
const IAPC_BOOT_ARG_FLAGS_PCI_ASPM: u8 = 4; | |
// Disable VGA probing | |
const IAPC_BOOT_ARG_FLAGS_VGA_NOT_PRESENT: u8 = 1 << 2; | |
// Do not enable MSI | |
const IAPC_BOOT_ARG_FLAGS_MSI_NOT_PRESENT: u8 = 1 << 3; | |
// Do not enable ASPM control | |
const IAPC_BOOT_ARG_FLAGS_PCI_ASPM: u8 = 1 << 4; |
pub(crate) fn create_apic_structures(num_cpus: usize) -> Vec<u8> { | ||
let mut interrupt_controllers = | ||
Vec::with_capacity(num_cpus * size_of::<LocalAPIC>() + size_of::<IoAPIC>()); | ||
|
||
(0..num_cpus).for_each(|cpu_id| { | ||
interrupt_controllers.extend(LocalAPIC::new(cpu_id as u8).as_slice()); | ||
}); | ||
|
||
interrupt_controllers.extend(IoAPIC::new(0).as_slice()); | ||
|
||
interrupt_controllers | ||
} |
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.
You can compress this a bit.
pub(crate) fn create_apic_structures(num_cpus: usize) -> Vec<u8> { | |
let mut interrupt_controllers = | |
Vec::with_capacity(num_cpus * size_of::<LocalAPIC>() + size_of::<IoAPIC>()); | |
(0..num_cpus).for_each(|cpu_id| { | |
interrupt_controllers.extend(LocalAPIC::new(cpu_id as u8).as_slice()); | |
}); | |
interrupt_controllers.extend(IoAPIC::new(0).as_slice()); | |
interrupt_controllers | |
} | |
pub(crate) fn create_apic_structures(num_cpus: usize) -> Vec<u8> { | |
let interrupt_controllers = (0..num_cpus) | |
.flat_map(|cpu_id| LocalAPIC::new(cpu_id as u8).as_slice()) | |
.extend(IoAPIC::new(0).as_slice()) | |
.collect(); | |
interrupt_controllers | |
} |
Closing this in favour of #4428. This other one is based on this one, but rebased on top of our current |
Changes
Introduce ACPI support for x86_64.
Reason
Introducing ACPI will let us do a couple of things:
Closes #2493
License Acceptance
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
PR Checklist
git commit -s
).unsafe
code is documented.CHANGELOG.md
.rust-vmm
.