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

Add ACPI support for x86_64 #4428

Merged
merged 9 commits into from
Mar 25, 2024
Merged

Conversation

bchalios
Copy link
Contributor

@bchalios bchalios commented Feb 6, 2024

Changes

Add minimal ACPI support for x86. We implement ACPI in Hardware Reduced mode. For the time being we support FADT, MADT for interrupt controllers and DSDT for passing info about VirtIO and legacy devices. This changes the way that we expose vCPUs, interrupt controllers and devices to the guest.

We pass information about vCPUs and interrupt controllers via MADT table. As a result, we do not need MPTable any more. We deprecate support for MPTable; it will be removed in a future release.

We pass information about VirtIO devices as AML bytecode in the DSDT table. As a result, we do not need to pass VirtIO devices as command line parameters any more.

Reason

We want to implement ACPI in order to support the Virtual Machine Generation ID device 1. Support for this device will come as a follow up PR.

1 https://learn.microsoft.com/en-us/windows/win32/hyperv_v2/virtual-machine-generation-identifier

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • If a specific issue led to this PR, this PR closes the issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this
    PR.
  • API changes follow the Runbook for Firecracker API changes.
  • User-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.
  • New TODOs link to an issue.
  • Commits meet
    contribution quality standards.

  • This functionality cannot be added in rust-vmm.

@bchalios bchalios force-pushed the acpi_x86_64 branch 4 times, most recently from 7bf45b1 to 563824e Compare February 12, 2024 15:45
Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: Patch coverage is 94.20168% with 69 lines in your changes are missing coverage. Please review.

Project coverage is 82.01%. Comparing base (138a189) to head (a2663cc).

❗ Current head a2663cc differs from pull request most recent head df09c5d. Consider uploading reports for the commit df09c5d to get more accurate results

Files Patch % Lines
src/acpi-tables/src/aml.rs 95.04% 29 Missing ⚠️
src/acpi-tables/src/lib.rs 60.41% 19 Missing ⚠️
src/vmm/src/acpi/mod.rs 94.11% 5 Missing ⚠️
src/acpi-tables/src/madt.rs 93.93% 4 Missing ⚠️
src/acpi-tables/src/rsdp.rs 84.61% 4 Missing ⚠️
src/vmm/src/device_manager/mmio.rs 95.31% 3 Missing ⚠️
src/acpi-tables/src/dsdt.rs 97.36% 1 Missing ⚠️
src/acpi-tables/src/xsdt.rs 97.67% 1 Missing ⚠️
src/vmm/src/arch/x86_64/mptable.rs 90.90% 1 Missing ⚠️
src/vmm/src/builder.rs 95.65% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4428      +/-   ##
==========================================
+ Coverage   81.56%   82.01%   +0.45%     
==========================================
  Files         243      253      +10     
  Lines       29899    31026    +1127     
==========================================
+ Hits        24387    25447    +1060     
- Misses       5512     5579      +67     
Flag Coverage Δ
4.14-c5n.metal 79.47% <94.42%> (+0.60%) ⬆️
4.14-c7g.metal ?
4.14-m5d.metal ?
4.14-m5n.metal 79.46% <94.42%> (+0.60%) ⬆️
4.14-m6a.metal 78.68% <94.42%> (+0.65%) ⬆️
4.14-m6g.metal 76.65% <68.91%> (-0.32%) ⬇️
4.14-m6i.metal 79.46% <94.42%> (+0.60%) ⬆️
4.14-m7g.metal 76.65% <68.91%> (-0.32%) ⬇️
5.10-c5n.metal 82.01% <94.42%> (+0.49%) ⬆️
5.10-c7g.metal ?
5.10-m5d.metal ?
5.10-m5n.metal 82.00% <94.42%> (+0.49%) ⬆️
5.10-m6a.metal 81.30% <94.42%> (+0.54%) ⬆️
5.10-m6g.metal 79.43% <68.91%> (-0.41%) ⬇️
5.10-m6i.metal 82.00% <94.42%> (+0.49%) ⬆️
5.10-m7g.metal 79.43% <68.91%> (-0.41%) ⬇️
6.1-c5n.metal 82.01% <94.42%> (+0.49%) ⬆️
6.1-c7g.metal ?
6.1-m5d.metal ?
6.1-m5n.metal 82.00% <94.42%> (+0.49%) ⬆️
6.1-m6a.metal 81.30% <94.42%> (+0.54%) ⬆️
6.1-m6g.metal 79.43% <68.91%> (-0.41%) ⬇️
6.1-m6i.metal 82.00% <94.42%> (+0.49%) ⬆️
6.1-m7g.metal 79.43% <68.91%> (-0.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bchalios bchalios force-pushed the acpi_x86_64 branch 17 times, most recently from 4c33fb5 to 9348abd Compare February 16, 2024 15:44
@bchalios bchalios force-pushed the acpi_x86_64 branch 8 times, most recently from 7b66f75 to 743c14e Compare February 27, 2024 17:19
Right now we handle guest interrupt lines (GSIs) and physical memory
inside the MMIO device manager.

With ACPI we will add a new device type for which we will need to
allocate GSIs and memory. With the current way we do things, this means
that we would need an extra pair of GSI and memory allocators.

This commit introduces a resource manager at the VMM level for handling
GSIs and guest physical memory allocations. Each device manager will get
a reference to this object for handling resources globally.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Add a lib crate for handling ACPI tables. The crate exports types
representing the various tables we handle and methods for creating
them, modifying them and writing them in guest memory.

The crate is based on the cloudhypervisor implementation:
https://github.com/rust-vmm/acpi_tables. We reuse the logic for creating
AML bytecode but we diverge from the way they create and manipulate the
tables. They rely mainly on the SdtHeader type and work with byte
offsets, whereas we define concrete types for each table and use those.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Initial ACPI setup for x86.

We have FADT in Hardware Reduced mode. This means that we declare to the
guest that we don't implement in "hardware" some features, such as
control and event registers.

We also have MADT, which essentially replaces the functionality of
MPTable; we define on IO-APIC and one LocalAPIC structure per vCPU. All
vCPUs are marked as online by default.

Finally, we have an empty DSDT. This will be populated with info about
VirtIO, legacy and ACPI devices in future commits.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Use AML bytecode in DSDT ACPI table to define VirtIO devices as well as
passing them as kernel command line arguments. Also, pass AML for legacy
devices, as the kernel doesn't pick up the console or i8042 unless we
do.

For the time being, we are keeping the old way of booting, i.e. MPTable
plus VirtIO devices via command line arguments to allow for some sort of
backwards compatibility with kernels that are not built with ACPI
support.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
This test is looking for the MMIO address range of virtio-net devices
and then uses it to update the MAC address of the devices by writing
under `/dev/mem`.

The test was using the kernel command line to find the address range.
With ACPI we don't pass this range via kernel command line any more, so
adapt the test to look for this information under /proc/iomem.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Configurations for 4.14, 5.10 and 6.1 guest kernels with ACPI support.
This, also updates other configuration options that are enabled
automatically while building the kernels. These options were taken from
the saved config files from built kernels for our CI.

ACPI configuration increases kernel image files size. 4.14 kernel goes
from 19MB to 19.4MB. 5.10 goes from 26.3MB to 28.9MB. 6.1 goes from
26.5MB to 29.1MB.

Also, add a configuration for guest 5.10 without ACPI so that we keep
testing MPTable and passing VirtIO devices via kernel command line
paramters, for as long as these are in the deprecation period. Once we
drop support for these two, we can remove this from our test matrix.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Starting from 5.10.211 the 5.10 guest kernels don't build neither for
x86_64 nor Aarch64 with our kernel configs. There is a missing header
file in arch/x86/kernel/paravirt.c, so when we build with
CONFIG_PARAVIRT on, the build fails.

Pin the 5.10 guest kernel version to the latest one working for us
(5.10.210) until this issue is fixed upstream.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Mention the kernel requirements for booting with ACPI support. Also
mention how users can disable the legacy way of booting (via MPTable and
command line parameters for VirtIO devices).

Signed-off-by: Babis Chalios <bchalios@amazon.es>
Mention that we now support ACPI on x86_64 microVMs. Also, announce the
deprecation of MPTable and suggest that Firecracker users should migrate
to using kernels with ACPI support.

Signed-off-by: Babis Chalios <bchalios@amazon.es>
pb8o
pb8o previously approved these changes Mar 25, 2024
@bchalios bchalios marked this pull request as draft March 25, 2024 11:00
@bchalios bchalios marked this pull request as ready for review March 25, 2024 11:24
@bchalios bchalios merged commit 39f0187 into firecracker-microvm:main Mar 25, 2024
5 of 7 checks passed
@sudanl0
Copy link
Contributor

sudanl0 commented Mar 25, 2024

Thanks for posting CHANGELOG for each version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants