Re: [PATCH 5/6] KVM: SVM: Add missing save/restore handling of LBR MSRs

From: Yosry Ahmed

Date: Sat Nov 08 2025 - 04:09:14 EST


November 7, 2025 at 4:45 PM, "Yosry Ahmed" <yosry.ahmed@xxxxxxxxx mailto:yosry.ahmed@xxxxxxxxx?to=%22Yosry%20Ahmed%22%20%3Cyosry.ahmed%40linux.dev%3E > wrote:
>
> MSR_IA32_DEBUGCTLMSR and LBR MSRs are currently not enumerated by
> KVM_GET_MSR_INDEX_LIST, and LBR MSRs cannot be set with KVM_SET_MSRS. So
> save/restore is completely broken.
>
> Fix it by adding the MSRs to msrs_to_save_base, and allowing writes to
> LBR MSRs from userspace only (as they are read-only MSRs). Additionally,
> to correctly restore L1's LBRs while L2 is running, make sure the LBRs
> are copied from the captured VMCB01 save area in svm_copy_vmrun_state().
>
> Fixes: 24e09cbf480a ("KVM: SVM: enable LBR virtualization")
> Cc: stable@xxxxxxxxxxxxxxx
>

Reported-by: Jim Mattson <jmattson@xxxxxxxxxx>

> Signed-off-by: Yosry Ahmed <yosry.ahmed@xxxxxxxxx>
[..]