Skip to content

[Backport 1.16] Gate clidr overwrite - #6181

Merged
ShadowCurse merged 5 commits into
firecracker-microvm:firecracker-v1.16from
ShadowCurse:gate_clidr_overwrite_1_16
Sep 3, 2026
Merged

[Backport 1.16] Gate clidr overwrite#6181
ShadowCurse merged 5 commits into
firecracker-microvm:firecracker-v1.16from
ShadowCurse:gate_clidr_overwrite_1_16

Conversation

@ShadowCurse

Copy link
Copy Markdown
Contributor

Changes

Backport of #6172

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 checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • 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.

Add a simple `u32` backed `Version` type with standard
`major`/`minor`/`patch` fileds. The `u32` backing allows for trivial
comparison. This type will be used in the next commit for host kernel
version reporting.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Use `uname` syscall to obtain information about the host kernel
including it's release string which can be converted to the kernel
version.
If this fails for some reason, default to 0.0.0 (the oldest we can
represent).

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse changed the title [Backport 1.16] Gate clidr overwrite - #6172 [Backport 1.16] Gate clidr overwrite Sep 2, 2026
@ShadowCurse ShadowCurse self-assigned this Sep 2, 2026
Original CLIDR_EL1 overwrite was done in Firecracker in the
"b5ac3a6ee7bc0828596c386c9def1bf228f1234c"("fix(aarch64): override
fabricated CLIDR_EL1 to match host cache topology") commit to fix the
change in behavior in the kernel 6.3 from the commit "7af0c2534f4c"
("KVM: arm64: Normalize cache configuration") which started fabricating
CLIDR_EL1 register.

The issue here is that for secondary vcpus on aarch64 the PSCI boot up
process resets vcpu registers (including ID registers like CLIDR_EL1).
This in creates a situation where the vcpu0 has correct CLIDR_EL1 while
all secondary vcpus have KVM default CLIDR_EL1. This combination affects
guest kernel scheduling behavior significantly affecting the
performance.

6.10 kernel contains a fix for this issue
"e016333745c70c960e02b4a9b123c807669d2b22"("KVM: arm64: Only reset
vCPU-scoped feature ID regs once"). This commit (as the title suggests)
prevents resetting of ID registers for already initialized vcpus (all
vcpus are initialized by Firecracker before VM starts). This fixes the
issue of CLIDR_EL1.

All of this creates an unfortunate situation where [6.3..6.10) range of
kernels is affected and have a degraded performance. Even though this
range of kernels does not contain any officially supported kernels by
Firecracker, it would be nice to mediate the impact.

One fix for it is to make secondary vcpu threads to wait until they are
booted by the vcpu0 and only then enter the `KVM_RUN` syscall. This way
there is a window of time where CLIDR_EL1 can be set again to the
correct value. We decide to not use this option since it can potentially
introduce boot time regression and in general adds unwanted complexity.

This leaves the option of gating the CLIDR_EL1 overwrite to only kernels
past 6.10 release. This is not ideal either since cache topology in
affected range of kernels will encounter the original problem the
CLIDR_EL1 override was solving, but at least it does not introduce
performance regressions in the guest.

In the future we will investigate if removing CLIRD_EL1 overwrite and
any cache information from the DT is reasonable to alleviate this
problem once and for all.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
The test will fail on those kernels since the KVM does fabricate
CLIDR_EL1, but we skip overwriting CLIDR_EL1 with correct version. This
causes guest to not provide info about L1$, and so the test fails.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add entry about CLIRD_EL1 override gate

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse
ShadowCurse force-pushed the gate_clidr_overwrite_1_16 branch from 7cf7e54 to 4e57549 Compare September 2, 2026 16:33
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.04%. Comparing base (1eb39a6) to head (4e57549).

Files with missing lines Patch % Lines
src/vmm/src/arch/mod.rs 93.33% 2 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           firecracker-v1.16    #6181      +/-   ##
=====================================================
+ Coverage              83.02%   83.04%   +0.01%     
=====================================================
  Files                    277      277              
  Lines                  30149    30196      +47     
=====================================================
+ Hits                   25032    25075      +43     
- Misses                  5117     5121       +4     
Flag Coverage Δ
5.10-m5n.metal 83.28% <68.88%> (-0.02%) ⬇️
5.10-m6a.metal 82.63% <68.88%> (-0.03%) ⬇️
5.10-m6g.metal 79.91% <93.75%> (-0.07%) ⬇️
5.10-m6i.metal 83.28% <68.88%> (-0.04%) ⬇️
5.10-m7a.metal-48xl 82.62% <68.88%> (-0.02%) ⬇️
5.10-m7g.metal 79.91% <93.75%> (-0.07%) ⬇️
5.10-m7i.metal-24xl 83.25% <68.88%> (-0.03%) ⬇️
5.10-m7i.metal-48xl 83.26% <68.88%> (-0.03%) ⬇️
5.10-m8g.metal-24xl 79.90% <93.75%> (-0.07%) ⬇️
5.10-m8g.metal-48xl 79.91% <93.75%> (-0.07%) ⬇️
5.10-m8i.metal-48xl 83.25% <68.88%> (-0.03%) ⬇️
5.10-m8i.metal-96xl 83.25% <68.88%> (-0.03%) ⬇️
6.1-m5n.metal 83.30% <68.88%> (-0.03%) ⬇️
6.1-m6a.metal 82.65% <68.88%> (-0.03%) ⬇️
6.1-m6g.metal 79.91% <93.75%> (-0.07%) ⬇️
6.1-m6i.metal 83.30% <68.88%> (-0.03%) ⬇️
6.1-m7a.metal-48xl 82.64% <68.88%> (-0.03%) ⬇️
6.1-m7g.metal 79.91% <93.75%> (-0.06%) ⬇️
6.1-m7i.metal-24xl 83.31% <68.88%> (-0.04%) ⬇️
6.1-m7i.metal-48xl 83.32% <68.88%> (-0.03%) ⬇️
6.1-m8g.metal-24xl 79.90% <93.75%> (-0.08%) ⬇️
6.1-m8g.metal-48xl 79.90% <93.75%> (-0.08%) ⬇️
6.1-m8i.metal-48xl 83.32% <68.88%> (-0.03%) ⬇️
6.1-m8i.metal-96xl 83.32% <68.88%> (-0.03%) ⬇️
6.18-m5n.metal 83.31% <68.88%> (-0.02%) ⬇️
6.18-m6a.metal 82.66% <68.88%> (-0.02%) ⬇️
6.18-m6g.metal 79.99% <93.75%> (+0.02%) ⬆️
6.18-m6i.metal 83.30% <68.88%> (-0.04%) ⬇️
6.18-m7a.metal-48xl 82.64% <68.88%> (-0.02%) ⬇️
6.18-m7g.metal 80.00% <93.75%> (+0.02%) ⬆️
6.18-m7i.metal-24xl 83.31% <68.88%> (-0.03%) ⬇️
6.18-m7i.metal-48xl 83.32% <68.88%> (-0.03%) ⬇️
6.18-m8g.metal-24xl 79.99% <93.75%> (+0.02%) ⬆️
6.18-m8g.metal-48xl 79.99% <93.75%> (+0.02%) ⬆️
6.18-m8i.metal-48xl 83.32% <68.88%> (-0.04%) ⬇️
6.18-m8i.metal-96xl 83.33% <68.88%> (-0.02%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@ShadowCurse
ShadowCurse marked this pull request as ready for review September 2, 2026 16:42
@ShadowCurse ShadowCurse added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Sep 2, 2026
@ShadowCurse
ShadowCurse enabled auto-merge (rebase) September 2, 2026 17:00
@ShadowCurse
ShadowCurse disabled auto-merge September 3, 2026 08:59
@ShadowCurse
ShadowCurse enabled auto-merge (rebase) September 3, 2026 08:59
@ShadowCurse
ShadowCurse disabled auto-merge September 3, 2026 09:31
@ShadowCurse
ShadowCurse merged commit eec3484 into firecracker-microvm:firecracker-v1.16 Sep 3, 2026
8 checks passed
@ShadowCurse
ShadowCurse deleted the gate_clidr_overwrite_1_16 branch September 3, 2026 09:31
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.

5 participants