git: 4e679d8aeaa8 - main - hwpmc: Avoid touching MSR_DEBUGCTLMSR inside VMs.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Thu, 01 Sep 2022 17:23:23 UTC
The branch main has been updated by mav:

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

commit 4e679d8aeaa86ce061b15c51fe9a5eae1eff7470
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2022-09-01 17:18:04 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-09-01 17:23:11 +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
---
 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);
 	}