diff options
| author | Yosry Ahmed <yosry.ahmed@linux.dev> | 2026-02-10 01:08:06 +0000 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-03-02 14:46:40 -0800 |
| commit | e63fb1379f4b9300a44739964e69549bebbcdca4 (patch) | |
| tree | 26e788a2cfdd7b04545ddfbf26520f7e065f65f3 | |
| parent | d0ad1b05bbe6f8da159a4dfb6692b3b7ce30ccc8 (diff) | |
KVM: nSVM: Mark all of vmcb02 dirty when restoring nested state
When restoring a vCPU in guest mode, any state restored before
KVM_SET_NESTED_STATE (e.g. KVM_SET_SREGS) will mark the corresponding
dirty bits in vmcb01, as it is the active VMCB before switching to
vmcb02 in svm_set_nested_state().
Hence, mark all fields in vmcb02 dirty in svm_set_nested_state() to
capture any previously restored fields.
Fixes: cc440cdad5b7 ("KVM: nSVM: implement KVM_GET_NESTED_STATE and KVM_SET_NESTED_STATE")
CC: stable@vger.kernel.org
Signed-off-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20260210010806.3204289-1-yosry.ahmed@linux.dev
Signed-off-by: Sean Christopherson <seanjc@google.com>
| -rw-r--r-- | arch/x86/kvm/svm/nested.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 99f8b8de8159..d5a8f5608f2d 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1910,6 +1910,12 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, nested_vmcb02_prepare_control(svm, svm->vmcb->save.rip, svm->vmcb->save.cs.base); /* + * Any previously restored state (e.g. KVM_SET_SREGS) would mark fields + * dirty in vmcb01 instead of vmcb02, so mark all of vmcb02 dirty here. + */ + vmcb_mark_all_dirty(svm->vmcb); + + /* * While the nested guest CR3 is already checked and set by * KVM_SET_SREGS, it was set when nested state was yet loaded, * thus MMU might not be initialized correctly. |
