* [PATCH] perf/x86/amd: Don't touch the Host-only bit inside the guest hypervisor
@ 2022-02-27 13:26 Dongli Si
0 siblings, 0 replies; only message in thread
From: Dongli Si @ 2022-02-27 13:26 UTC (permalink / raw)
To: peterz, joerg.roedel
Cc: liam.merwick, kim.phillips, mingo, acme, mark.rutland,
alexander.shishkin, jolsa, namhyung, tglx, bp, dave.hansen, x86,
hpa, linux-perf-users, linux-kernel
From: Dongli Si <sidongli1997@gmail.com>
When using nested virtualization and if use "perf record" in an AMD Rome
and Milan guest hypervisor (L1), dmesg report an error message like this:
[ ] unchecked MSR access error: WRMSR to 0xc0010200 (tried to write 0x0000020000510076) at rIP: 0xffffffff81003a50 (x86_pmu_enable_all+0x60/0x100)
The AMD64_EVENTSEL_HOSTONLY bit is defined and used on the host, while
the guest hypervisor (L1) performance monitor unit should avoid such use.
Fixes: 1018faa6cf23 ("perf/x86/kvm: Fix Host-Only/Guest-Only counting with SVM disabled")
Signed-off-by: Dongli Si <sidongli1997@gmail.com>
---
arch/x86/events/amd/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 9687a8aef01c..3fafd1e46ada 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -8,6 +8,7 @@
#include <linux/jiffies.h>
#include <asm/apicdef.h>
#include <asm/nmi.h>
+#include <asm/hypervisor.h>
#include "../perf_event.h"
@@ -1027,7 +1028,8 @@ void amd_pmu_enable_virt(void)
{
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
- cpuc->perf_ctr_virt_mask = 0;
+ if (hypervisor_is_type(X86_HYPER_NATIVE))
+ cpuc->perf_ctr_virt_mask = 0;
/* Reload all events */
amd_pmu_disable_all();
--
2.32.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-27 13:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-27 13:26 [PATCH] perf/x86/amd: Don't touch the Host-only bit inside the guest hypervisor Dongli Si
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).