x86: Add tests for Guest Last Branch Recording (LBR)

This unit-test is intended to test the KVM's support for the
Last Branch Recording (LBR) which is a performance monitor
unit (PMU) feature on Intel processors.

If the LBR bit is set to 1 in the DEBUGCTLMSR, the processor
will record a running trace of the most recent branches guest
taken in the LBR entries for guest to read.

This is a basic check that looks for the MSR LBR (via #GP check),
does some branches, and checks that the FROM_IP/TO_IP are good.
To run this test, use the QEMU option "-cpu host,migratable=no".

Signed-off-by: Like Xu <like.xu@linux.intel.com>
Message-Id: <20210201045751.243231-1-like.xu@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 90e370f..d0d46c7 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -174,6 +174,12 @@
 extra_params = -cpu max
 check = /proc/sys/kernel/nmi_watchdog=0
 
+[pmu_lbr]
+file = pmu_lbr.flat
+extra_params = -cpu host,migratable=no
+check = /sys/module/kvm/parameters/ignore_msrs=N
+check = /proc/sys/kernel/nmi_watchdog=0
+
 [vmware_backdoors]
 file = vmware_backdoors.flat
 extra_params = -machine vmport=on -cpu max