diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-26 12:39:01 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-27 16:59:00 -0400 |
commit | 3fa5e8fd0a0e4ccc03c91df225be2e9b7100800c (patch) | |
tree | 888237497c59d17c1420de8384ffd7b43e4a0a93 /arch/x86/kvm/svm/svm_onhyperv.h | |
parent | c33e05d9b067433252b1008d2f37bf64e11151f1 (diff) | |
download | lwn-3fa5e8fd0a0e4ccc03c91df225be2e9b7100800c.tar.gz lwn-3fa5e8fd0a0e4ccc03c91df225be2e9b7100800c.zip |
KVM: SVM: delay svm_vcpu_init_msrpm after svm->vmcb is initialized
Right now, svm_hv_vmcb_dirty_nested_enlightenments has an incorrect
dereference of vmcb->control.reserved_sw before the vmcb is checked
for being non-NULL. The compiler is usually sinking the dereference
after the check; instead of doing this ourselves in the source,
ensure that svm_hv_vmcb_dirty_nested_enlightenments is only called
with a non-NULL VMCB.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Vineeth Pillai <viremana@linux.microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[Untested for now due to issues with my AMD machine. - Paolo]
Diffstat (limited to 'arch/x86/kvm/svm/svm_onhyperv.h')
-rw-r--r-- | arch/x86/kvm/svm/svm_onhyperv.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/svm/svm_onhyperv.h b/arch/x86/kvm/svm/svm_onhyperv.h index 9b9a55abc29f..c53b8bf8d013 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.h +++ b/arch/x86/kvm/svm/svm_onhyperv.h @@ -89,7 +89,7 @@ static inline void svm_hv_vmcb_dirty_nested_enlightenments( * as we mark it dirty unconditionally towards end of vcpu * init phase. */ - if (vmcb && vmcb_is_clean(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS) && + if (vmcb_is_clean(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS) && hve->hv_enlightenments_control.msr_bitmap) vmcb_mark_dirty(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS); } |