@@ -825,6 +825,8 @@ struct kvm_arch {
bool mwait_in_guest;
bool hlt_in_guest;
bool pause_in_guest;
+ bool guest_lbr_enabled;
+ struct perf_lbr_stack lbr_stack;
unsigned long irq_sources_bitmap;
s64 kvmclock_offset;
@@ -2927,6 +2927,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_SPLIT_IRQCHIP:
case KVM_CAP_IMMEDIATE_EXIT:
case KVM_CAP_GET_MSR_FEATURES:
+ case KVM_CAP_X86_GUEST_LBR:
r = 1;
break;
case KVM_CAP_SYNC_REGS:
@@ -4350,6 +4351,15 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
kvm->arch.pause_in_guest = true;
r = 0;
break;
+ case KVM_CAP_X86_GUEST_LBR:
+ r = -EINVAL;
+ if (perf_get_lbr_stack(&kvm->arch.lbr_stack) < 0) {
+ pr_err("Failed to enable the guest lbr feature\n");
+ break;
+ }
+ kvm->arch.guest_lbr_enabled = true;
+ r = 0;
+ break;
default:
r = -EINVAL;
break;
@@ -952,6 +952,7 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_S390_HPAGE_1M 156
#define KVM_CAP_NESTED_STATE 157
#define KVM_CAP_ARM_INJECT_SERROR_ESR 158
+#define KVM_CAP_X86_GUEST_LBR 159
#ifdef KVM_CAP_IRQ_ROUTING