On 3/1/22 15:36, Maxim Levitsky wrote:
@@ -565,8 +565,19 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12
vmcb_mark_dirty(svm->vmcb, VMCB_DR);
}
- if (unlikely(svm->vmcb01.ptr->control.virt_ext & LBR_CTL_ENABLE_MASK))
+ if (unlikely(svm->lbrv_enabled && (svm->nested.ctl.virt_ext & LBR_CTL_ENABLE_MASK))) {
+
+ /* Copy LBR related registers from vmcb12,
+ * but make sure that we only pick LBR enable bit from the guest.
+ */
+
+ svm_copy_lbrs(vmcb12, svm->vmcb);
+ svm->vmcb->save.dbgctl &= LBR_CTL_ENABLE_MASK;
This should be checked against DEBUGCTL_RESERVED_BITS instead in
__nested_vmcb_check_save; remember to add dbgctl to struct
vmcb_save_area_cached too.
Paolo
+ svm_update_lbrv(&svm->vcpu);
+
+ } else if (unlikely(svm->vmcb01.ptr->control.virt_ext & LBR_CTL_ENABLE_MASK)) {
svm_copy_lbrs(svm->vmcb01.ptr, svm->vmcb);
+ }
}