[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] KVM: x86/mmu: Check write tracking in all address spaces - #2136
Merged
opsiff merged 1 commit intoSep 11, 2026
Conversation
kvm_gfn_is_write_tracked() checks only the supplied memslot, but page tracking is per-address-space and shadow pages are shared across all address spaces. With SMM, a GFN can therefore be write-tracked in one address space and appear untracked through the other. Check the supplied slot first, then the slot for the other address space. This ensures all callers honor write tracking regardless of the active address space. In particular, it prevents mmu_try_to_unsync_pages() from marking an upper-level shadow page unsync and eventually triggering the BUG in pte_list_remove(). Fixes: 699023e ("KVM: x86: add SMM to the MMU role, support SMRAM address space") Assisted-by: Codex:GPT-5 Signed-off-by: Jinu Kim <kimjw04271234@gmail.com> Message-ID: <20260721103512.2136240-2-kimjw04271234@gmail.com> [invert direction of the conditional. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 0f38453) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's GuideUpdates KVM x86 write-tracking detection to search both address spaces, preventing SMM-related mismatches where shared shadow pages could be treated as untracked and later trigger pte_list_remove() failures. Flow diagram for KVM write-tracking lookup across address spacesflowchart TD
A[kvm_gfn_is_write_tracked] --> B{Write tracking enabled?}
B -- No --> C[Return false]
B -- Yes --> D[Check supplied memslot]
D -- Tracked --> E[Return true]
D -- Untracked --> F{Second address space exists?}
F -- No --> G[Return false]
F -- Yes --> H[Find other address-space memslot]
H --> I[Check other memslot]
I -- Tracked --> E
I -- Untracked --> G
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
stable 6.6.156 #2120
use mainline version.
kvm_gfn_is_write_tracked() checks only the supplied memslot, but page tracking is per-address-space and shadow pages are shared across all address spaces. With SMM, a GFN can therefore be write-tracked in one address space and appear untracked through the other.
Check the supplied slot first, then the slot for the other address space. This ensures all callers honor write tracking regardless of the active address space. In particular, it prevents mmu_try_to_unsync_pages() from marking an upper-level shadow page unsync and eventually triggering the BUG in pte_list_remove().
Fixes: 699023e ("KVM: x86: add SMM to the MMU role, support SMRAM address space")
Assisted-by: Codex:GPT-5
Message-ID: 20260721103512.2136240-2-kimjw04271234@gmail.com
[invert direction of the conditional. - Paolo]
(cherry picked from commit 0f38453)
Summary by Sourcery
Fix KVM x86 write-tracking checks so shared shadow pages honor tracking state across address spaces.
Bug Fixes:
Enhancements: