Re: [PATCH v2 06/15] KVM: vmx/pmu: Emulate MSR_ARCH_LBR_CTL for guest Arch LBR

From: Yang, Weijiang
Date: Sat Dec 24 2022 - 23:28:11 EST



On 12/22/2022 7:09 PM, Like Xu wrote:
On 25/11/2022 12:05 pm, Yang Weijiang wrote:
  static int intel_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
  {
      struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
@@ -377,6 +402,14 @@ static int intel_pmu_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
      case MSR_ARCH_LBR_DEPTH:
          msr_info->data = lbr_desc->records.nr;
          return 0;
+    case MSR_ARCH_LBR_CTL:
+        if (!kvm_cpu_cap_has(X86_FEATURE_ARCH_LBR)) {
+            WARN_ON_ONCE(!msr_info->host_initiated);

Why we need this warning even in the format of WARN_ON_ONCE() ?
And why not for MSR_ARCH_LBR_DEPTH msr ?


IMO, this is just to give some informative message. Not necessary for every

arch-lbr MSRs as MSR_ARCH_LBR_CTL is the master control msr.




+            msr_info->data = 0;
+        } else {
+            msr_info->data = vmcs_read64(GUEST_IA32_LBR_CTL);
+        }
+        return 0;