* Fix Boolean logic in intel_guest_get_msrs

-----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmWWz4QUHHBib256aW5p
 QHJlZGhhdC5jb20ACgkQv/vSX3jHroNYSQgAjHhbUUUHqpkl4vO+zcJiPlQN3i14
 M/71Hgdvh+936UlyqBoEx9wrHcbzw0+vaxKsri/yIGLkieaU7ZtVtyeWfoc4DkDd
 0Al4OTIkyydPmaKjC3terRwlCxRWbut30yRlkz4LzC/oWb2NN19j3Yq6omwBBAOu
 vCqK2chNCIEetYBmX3G2CDG7DJ6mVvSLZx/vQXP3dj3jQWxT8eFxTH52eNtdIJXN
 0U4EVgp21hah+ur8U/VGNlqkc5govovSKtV3eAeE1WF0coBTLZcFadnHVjcG65lz
 QOKVCU9Aw31M7qddTAqztC9OpyaD8oDEhyRKZoVSkGhiP/2crK83AAf/7w==
 =J0fU
 -----END PGP SIGNATURE-----

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fix from Paolo Bonzini:

 - Fix boolean logic in intel_guest_get_msrs

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  KVM: x86/pmu: fix masking logic for MSR_CORE_PERF_GLOBAL_CTRL
This commit is contained in:
Linus Torvalds 2024-01-05 09:16:15 -08:00
commit 7987b8b75f

View File

@ -4051,12 +4051,17 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)
u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable;
int global_ctrl, pebs_enable;
/*
* In addition to obeying exclude_guest/exclude_host, remove bits being
* used for PEBS when running a guest, because PEBS writes to virtual
* addresses (not physical addresses).
*/
*nr = 0;
global_ctrl = (*nr)++;
arr[global_ctrl] = (struct perf_guest_switch_msr){
.msr = MSR_CORE_PERF_GLOBAL_CTRL,
.host = intel_ctrl & ~cpuc->intel_ctrl_guest_mask,
.guest = intel_ctrl & (~cpuc->intel_ctrl_host_mask | ~pebs_mask),
.guest = intel_ctrl & ~cpuc->intel_ctrl_host_mask & ~pebs_mask,
};
if (!x86_pmu.pebs)