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

Functional support of Intel Sapphire Rapids #5084

Merged
merged 20 commits into from
Mar 14, 2025

Conversation

zulinx86
Copy link
Contributor

@zulinx86 zulinx86 commented Mar 13, 2025

Changes

  • Do refactoring of the existing CPUID normalization in the first 11 commits (not related to Intel Sapphire Rapids support, so I can open another PR for this but this PR touches the same doc.)
  • Add CPUID leaf 0x1F normalization
  • Make functional integration tests support Intel Sapphire Rapids

Reason

Intel Sapphire Rapids reports more CPUID leaves (0x1C - 0x1F) than Intel Ice Lake:

  • 0x1C: Last Branch Records Information Leaf (filled with 0 since not supported in guest)
  • 0x1D: Tile Information Main Leaf (passed through since it's for Intel AMX)
  • 0x1E: TMUL Information Main Leaf (passed through since it's for Intel AMX)
  • 0x1F: V2 Extended Topology Enumeration Leaf (same contents with leaf 0xB since leaf 0x1F is a preferred superset to leaf 0xB)

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

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • [ ] I have mentioned all user-facing changes in CHANGELOG.md.
  • [ ] If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • [ ] I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@zulinx86 zulinx86 marked this pull request as draft March 13, 2025 16:00
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

Attention: Patch coverage is 98.11321% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.18%. Comparing base (e7f6051) to head (4dd97bb).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
src/vmm/src/cpu_config/x86_64/cpuid/normalize.rs 97.14% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5084      +/-   ##
==========================================
+ Coverage   83.15%   83.18%   +0.02%     
==========================================
  Files         248      248              
  Lines       26910    26910              
==========================================
+ Hits        22377    22384       +7     
+ Misses       4533     4526       -7     
Flag Coverage Δ
5.10-c5n.metal 83.57% <96.66%> (+0.03%) ⬆️
5.10-m5n.metal 83.56% <96.66%> (+0.04%) ⬆️
5.10-m6a.metal 82.74% <97.67%> (+0.02%) ⬆️
5.10-m6g.metal 79.60% <ø> (ø)
5.10-m6i.metal 83.55% <96.66%> (+0.04%) ⬆️
5.10-m7g.metal 79.60% <ø> (ø)
6.1-c5n.metal 83.61% <96.66%> (+0.03%) ⬆️
6.1-m5n.metal 83.59% <96.66%> (+0.03%) ⬆️
6.1-m6a.metal 82.79% <97.67%> (+0.01%) ⬆️
6.1-m6g.metal 79.60% <ø> (+<0.01%) ⬆️
6.1-m6i.metal 83.59% <96.66%> (+0.03%) ⬆️
6.1-m7g.metal 79.60% <ø> (ø)

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.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zulinx86 zulinx86 force-pushed the sapphire_rapids branch 2 times, most recently from 6ea568e to 9eddd33 Compare March 13, 2025 16:40
@zulinx86 zulinx86 marked this pull request as ready for review March 13, 2025 16:42
@zulinx86 zulinx86 added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Mar 13, 2025
kalyazin
kalyazin previously approved these changes Mar 13, 2025
roypat
roypat previously approved these changes Mar 13, 2025
@zulinx86 zulinx86 dismissed stale reviews from roypat and kalyazin via da1e9b1 March 13, 2025 20:41
Reorder normalization from lower bits to higher and from EAX to EDX. No
functional change.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The CPUID notation is widely used in various Intel docs including SDM.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The CPUID notation is widely used in various AMD docs including APM.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
There is no benefit defining constants that are used only once. Rather
it makes harder to read code since the definition and usage are far
apart.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
As mentioned in [1], Intel 64 Architecture x2APIC Specification has been
merged into Volumes 2 and 3 of Intel 64 and IA-32 architectures software
developer's manual.

[1]: https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The last commit updates quotes of Intel specification from x2APIC spec
to Intel SDM. In accrodance with the change, update variable names and
comments (e.g. level => domain) and correct some comments appropriately.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Our supported kernels no longer return any subleaves >= 1. We inserted
subleaf 1 intentionally but subleaves >= 2 are not expected there.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The number of bits that the x2APIC ID must be shifted to the right to
address instances of the socket domain, which is next higher-scoped
domain to the core domain, was hardcoded as 7. That means up to 128
vcpus support. Currently the max vcpu count is hardcoded as 32, so it
is enough but we might want to increase it in the future. To avoid
unexpected issues when increasing the max vcpu count, calculate the
value based on the max vCPU count.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Show which combination of subleaf, register and bit(s) failed to set,
remove unused error variant and reorder error variants in alphabetical
order.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Since CPUID notation uses the upper bound inclusive, use RangeInclusive
instead of Range. Also, make set_range() and get_range() more readable
and reliable by always validating that `y` fits within the given range
and by asserting `end` is less than 32.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
EAX, EBX, ECX and EDX are the all registers returned.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Intel Sapphire Rapids has CPUID leaf 0x1F that is a preferred superset
to leaf 0xB. Intel recommends using leaf 0x1F when available rather than
leaf 0xB. We don't use any other domains than ones supported leaf 0xB,
so just copy leaf 0xB to leaf 0x1F.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Some structs are imported in the last commit. Let's remove turbo fish!

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Intel Sapphire Rapids does not report its frequency in the model name
string on host ("Intel(R) Xeon(R) Platinum 8488C").

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
CPUID leaf 1FH is a preferred superset to CPUID leaf 0BH. For the same
reason as CPUID leaf 0BH, the subleaf 2 should be skipped if guest
userspace cpuid command enumerates it.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
The MSR is R/W and guest OS modifies it after boot to control UMWAIT
feature.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
MSR_IA32_XFD is R/W MSR for guest OS to control which XSAVE-enabled
features are temporarily disabled. Guest OS disables TILEDATA by default
using the MSR.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
CPU features that guest kernel can vary depending on its kernel version.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Intel Sapphire Rapids has some new features compared to older Intel
processors. Some of them are just not virtualized by KVM, others started
to be passed through to guests since specific kernel versions, and the
others can be emulated but now supported by hardware.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
REPTAR is reported "vulnerable" inside guest on Intel Sapphire Rapids
for the same reason as Intel Ice Lake (microcode versio not exposed to
guests).

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
@zulinx86 zulinx86 requested review from kalyazin and roypat March 13, 2025 22:59
Copy link
Contributor

@Manciukic Manciukic left a comment

Choose a reason for hiding this comment

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

Great work!

@zulinx86 zulinx86 merged commit 983a20a into firecracker-microvm:main Mar 14, 2025
6 of 7 checks passed
@zulinx86 zulinx86 deleted the sapphire_rapids branch March 14, 2025 10:28
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.

4 participants