git: d62f7b1fb113 - stable/13 - hwpmc: Avoid touching MSR_DEBUGCTLMSR inside VMs.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Thu, 08 Sep 2022 00:30:37 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=d62f7b1fb113b61ab6677772080fc4437935c41b

commit d62f7b1fb113b61ab6677772080fc4437935c41b
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-09-01 17:18:04 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-09-08 00:30:30 +0000

    hwpmc: Avoid touching MSR_DEBUGCTLMSR inside VMs.
    
    At least KVM in Proxmox seems not happy about it.  Just to be safe
    block it for all VMs, since it should just improve profile accuracy.
    
    MFC after:      1 week
    
    (cherry picked from commit 4e679d8aeaa86ce061b15c51fe9a5eae1eff7470)
---
 sys/dev/hwpmc/hwpmc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c
index 7ec22c36019c..ff6bfbd4322f 100644
--- a/sys/dev/hwpmc/hwpmc_core.c
+++ b/sys/dev/hwpmc/hwpmc_core.c
@@ -151,7 +151,7 @@ core_pcpu_init(struct pmc_mdep *md, int cpu)
 		pc->pc_hwpmcs[n + core_ri]  = phw;
 	}
 
-	if (core_version >= 2) {
+	if (core_version >= 2 && vm_guest == VM_GUEST_NO) {
 		/* Enable Freezing PMCs on PMI. */
 		wrmsr(MSR_DEBUGCTLMSR, rdmsr(MSR_DEBUGCTLMSR) | 0x1000);
 	}