Skip to content

Commit e8efa4f

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: nSVM: mark vmcb01 as dirty when restoring SMM saved state
While usually, restoring the smm state makes the KVM enter the nested guest thus a different vmcb (vmcb02 vs vmcb01), KVM should still mark it as dirty, since hardware can in theory cache multiple vmcbs. Failure to do so, combined with lack of setting the nested_run_pending (which is fixed in the next patch), might make KVM re-enter vmcb01, which was just exited from, with completely different set of guest state registers (SMM vs non SMM) and without proper dirty bits set, which results in the CPU reusing stale IDTR pointer which leads to a guest shutdown on any interrupt. On the real hardware this usually doesn't happen, but when running nested, L0's KVM does check and honour few dirty bits, causing this issue to happen. This patch fixes boot of hyperv and SMM enabled windows VM running nested on KVM. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Cc: stable@vger.kernel.org Message-Id: <20220207155447.840194-4-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent e1779c2 commit e8efa4f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4256,6 +4256,8 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
42564256
* Enter the nested guest now
42574257
*/
42584258

4259+
vmcb_mark_all_dirty(svm->vmcb01.ptr);
4260+
42594261
vmcb12 = map.hva;
42604262
nested_copy_vmcb_control_to_cache(svm, &vmcb12->control);
42614263
nested_copy_vmcb_save_to_cache(svm, &vmcb12->save);

0 commit comments

Comments
 (0)