feat: reset KVM_REG_ARM_PTIMER_CNT on VM boot#4987
Merged
ShadowCurse merged 5 commits intofirecracker-microvm:mainfrom Jan 17, 2025
Merged
feat: reset KVM_REG_ARM_PTIMER_CNT on VM boot#4987ShadowCurse merged 5 commits intofirecracker-microvm:mainfrom
ShadowCurse merged 5 commits intofirecracker-microvm:mainfrom
Conversation
b34d97d to
b459ae3
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4987 +/- ##
==========================================
+ Coverage 83.06% 83.10% +0.04%
==========================================
Files 244 245 +1
Lines 26658 26723 +65
==========================================
+ Hits 22144 22209 +65
Misses 4514 4514
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
1bd3f94 to
5ea2f4a
Compare
75a7ec1 to
053f265
Compare
roypat
reviewed
Jan 10, 2025
kalyazin
reviewed
Jan 10, 2025
d3abf67 to
57b458b
Compare
pb8o
reviewed
Jan 10, 2025
f553778 to
0ab122a
Compare
pb8o
reviewed
Jan 14, 2025
e7d282b to
98592f7
Compare
roypat
reviewed
Jan 15, 2025
Contributor
roypat
left a comment
There was a problem hiding this comment.
feel free to ignore the nits, the changelog comment is the only one preventing me from hitting approve xP
d767541 to
1801a5f
Compare
roypat
previously approved these changes
Jan 16, 2025
caf5d9d to
bfc5a84
Compare
2b0aa20 to
406c2c4
Compare
roypat
previously approved these changes
Jan 17, 2025
kalyazin
reviewed
Jan 17, 2025
406c2c4 to
759d750
Compare
`Vm` constructor was the only place where the `/dev/kvm` was open and only there we could do any KVM (not VM) specific checks. By moving this KVM logic into a separate struct we can can do KVM specific actions (like checking optional KVM capabilities) without needing to reopen the `/dev/kvm` again. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
649235d to
13b30a2
Compare
kalyazin
reviewed
Jan 17, 2025
355cc54 to
82afe20
Compare
Reset KVM_REG_ARM_PTIMER_CNT physical counter register on VM boot to avoid passing through host physical counter. Note that resetting the register on VM boot does not guarantee that VM will see the counter value 0 at startup because there is a delta in time between register reset and VM boot during which counter continues to advance. In order to check if the kernel supports the counter reset we query KVM_CAP_COUNTER_OFFSET capability and only reset the KVM_REG_ARM_PTIMER_CNT if it is present. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Update a note about physical counter on ARM being reset instead of directly passed through on kernels with `KVM_CAP_COUNTER_OFFSET` capability. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add an entry about physical counter reset to the CHANGELOG. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Add a test to verify the reset of the physical counter on aarch64 VMs. To do this we check registers saved in the snapshot and verify the counter value is less than some reasonably small number we choose. The value is based on the observation of how much cycles it takes for a VM to boot and be snapshotted. The idea is that this value will always be smaller than the actual physical counter on the host. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
82afe20 to
d59728f
Compare
kalyazin
approved these changes
Jan 17, 2025
JackThomson2
approved these changes
Jan 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reset KVM_REG_ARM_PTIMER_CNT physical counter register on VM boot to avoid passing through host physical counter. Note that resetting the register on VM boot does not guarantee that VM will see the counter value 0 at startup because there is a delta in time between register reset and VM boot during which counter continues to advance.
Reason
Prevent guest from reading host performance counter.
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
tools/devtool checkstyleto verify that the PR passes theautomated style checks.
how they are solving the problem in a clear and encompassing way.
in the PR.
CHANGELOG.md.Runbook for Firecracker API changes.
integration tests.
TODO.rust-vmm.