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 exceptions to the check of CPU feature diff between host and guest on ubuntu #4900

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zulinx86
Copy link
Contributor

@zulinx86 zulinx86 commented Nov 7, 2024

Reason

PR #4884 introduced a test that ensures CPU feature diff between host and guest hasn't been changed.

However, the expected diff can vary depending on a combination of host kernel version and guest kernel version.

The current our setting is as follows:

  • Host
    • Amazon Linux 2 (v5.10)
    • Amazon Linux 2023 (v6.1)
    • Ubuntu 24.04 (v6.8)
  • Guest
    • Amazon Linux microvm kernel (v5.10)
    • Amazon Linux microvm kernel (v6.1)

Changes

  • aarch64
    • Add "ssbs" to the expected diff if needed.
  • x86_64
    • Remove "flush_l1d" from the expected diff if the host passes through it.
    • Add "invpcd_single" to the expected diff if needed.

Note that I implemented it in a general way as possible because we might want to support more host and guest kernels in the future.

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.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.10%. Comparing base (8c712d2) to head (a54a2cc).

Current head a54a2cc differs from pull request most recent head b276fc1

Please upload reports for the commit b276fc1 to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4900   +/-   ##
=======================================
  Coverage   84.10%   84.10%           
=======================================
  Files         251      251           
  Lines       28080    28080           
=======================================
  Hits        23616    23616           
  Misses       4464     4464           
Flag Coverage Δ
5.10-c5n.metal 84.67% <ø> (ø)
5.10-m5n.metal 84.65% <ø> (ø)
5.10-m6a.metal 83.96% <ø> (ø)
5.10-m6g.metal 80.78% <ø> (ø)
5.10-m6i.metal 84.65% <ø> (ø)
5.10-m7g.metal 80.78% <ø> (ø)
6.1-c5n.metal 84.67% <ø> (+<0.01%) ⬆️
6.1-m5n.metal 84.65% <ø> (ø)
6.1-m6a.metal 83.96% <ø> (ø)
6.1-m6g.metal 80.78% <ø> (ø)
6.1-m6i.metal 84.65% <ø> (ø)
6.1-m7g.metal 80.78% <ø> (ø)
6.8-m5n.metal 84.65% <ø> (?)
6.8-m6g.metal 80.78% <ø> (?)

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.

@zulinx86 zulinx86 force-pushed the ssbs_on_ubuntu branch 4 times, most recently from f05347d to 46ce60d Compare November 7, 2024 13:22
# through the "flush_l1d" CPUID bit to guests.
# https://github.com/torvalds/linux/commit/45cf86f26148e549c5ba4a8ab32a390e4bde216e
# See also https://github.com/firecracker-microvm/firecracker/issues/4899
if "Ubuntu" in global_props.os:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the commit in the Ubuntu host kernel there by virtue of Ubuntu backporting it, or because it is v6.8?

Copy link
Contributor Author

@zulinx86 zulinx86 Nov 7, 2024

Choose a reason for hiding this comment

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

The latter. See #4899 for more details.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we then make the check:

if global_props.linux_version_tpl >= (6, 8)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. We might want to add newer Amazon Linux kernel later (like AL2025 or something).

@zulinx86 zulinx86 force-pushed the ssbs_on_ubuntu branch 4 times, most recently from 66139a4 to a54a2cc Compare November 7, 2024 16:22
Linux kernel should hide "ssbs" since Neoverse-N1 and Neoverse-V1 have
an errata whereby an MSR to the SSBS special-purpose register does not
affect subsequent speculative instructions, permitting speculative store
bypassing for a window of time. Although Amazon Linux host kernels
(v5.10 and v6.1) backported it, the guest kernels (v5.10 and v6.1) and
the ubuntu host kernel (currently v6.8) lack the change.

Fixes: 2babc80 ("test(aarch64): add host vs guest cpu feature test")
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Linux kernel v6.4+ passes through the "l1d_flush" CPUID bit to guests.
While the ubuntu host kernel (v6.8) has the change, the latest Amazon
Linux 2 and Amazon Linux 2023 doesn't.

Fixes: 4e014a1 ("test(x86_64): add host vs guest cpu feature test")
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
Linux kernel v6.6+ drops the synthetic feature flag. While the ubuntu
host kernel (v6.8) has the change, the Amazon Linux kernels (v5.10 and
v6.1) and the guest kernels (v5.10 and v6.1) don't.

Fixes: 4e014a1 ("test(x86_64): add host vs guest cpu feature test")
Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
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.

2 participants