All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Liu <zhao1.liu@intel.com>
To: Dongli Zhang <dongli.zhang@oracle.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, pbonzini@redhat.com,
	mtosatti@redhat.com, sandipan.das@amd.com, babu.moger@amd.com,
	likexu@tencent.com, like.xu.linux@gmail.com, groug@kaod.org,
	khorenko@virtuozzo.com, alexander.ivanov@virtuozzo.com,
	den@virtuozzo.com, davydov-max@yandex-team.ru,
	xiaoyao.li@intel.com, dapeng1.mi@linux.intel.com,
	joe.jin@oracle.com, ewanhai-oc@zhaoxin.com, ewanhai@zhaoxin.com
Subject: Re: [PATCH v7 0/9] target/i386/kvm/pmu: PMU Enhancement, Bugfix and Cleanup
Date: Tue, 16 Dec 2025 16:25:52 +0800	[thread overview]
Message-ID: <aUEXkDDOba+oZ4v+@intel.com> (raw)
In-Reply-To: <20251111061532.36702-1-dongli.zhang@oracle.com>

On Mon, Nov 10, 2025 at 10:14:49PM -0800, Dongli Zhang wrote:
> Date: Mon, 10 Nov 2025 22:14:49 -0800
> From: Dongli Zhang <dongli.zhang@oracle.com>
> Subject: [PATCH v7 0/9] target/i386/kvm/pmu: PMU Enhancement, Bugfix and
>  Cleanup
> X-Mailer: git-send-email 2.43.5
> 
> This patchset addresses four bugs related to AMD PMU virtualization.
> 
> 1. The PerfMonV2 is still available if PERCORE if disabled via
> "-cpu host,-perfctr-core".
> 
> 2. The VM 'cpuid' command still returns PERFCORE although "-pmu" is
> configured.
> 
> 3. The third issue is that using "-cpu host,-pmu" does not disable AMD PMU
> virtualization. When using "-cpu EPYC" or "-cpu host,-pmu", AMD PMU
> virtualization remains enabled. On the VM's Linux side, you might still
> see:
> 
> [    0.510611] Performance Events: Fam17h+ core perfctr, AMD PMU driver.
> 
> instead of:
> 
> [    0.596381] Performance Events: PMU not available due to virtualization, using software events only.
> [    0.600972] NMI watchdog: Perf NMI watchdog permanently disabled
> 
> To address this, KVM_CAP_PMU_CAPABILITY is used to set KVM_PMU_CAP_DISABLE
> when "-pmu" is configured.
> 
> 4. The fourth issue is that unreclaimed performance events (after a QEMU
> system_reset) in KVM may cause random, unwanted, or unknown NMIs to be
> injected into the VM.
> 
> The AMD PMU registers are not reset during QEMU system_reset.
> 
> (1) If the VM is reset (e.g., via QEMU system_reset or VM kdump/kexec) while
> running "perf top", the PMU registers are not disabled properly.
> 
> (2) Despite x86_cpu_reset() resetting many registers to zero, kvm_put_msrs()
> does not handle AMD PMU registers, causing some PMU events to remain
> enabled in KVM.
> 
> (3) The KVM kvm_pmc_speculative_in_use() function consistently returns true,
> preventing the reclamation of these events. Consequently, the
> kvm_pmc->perf_event remains active.
> 
> (4) After a reboot, the VM kernel may report the following error:
> 
> [    0.092011] Performance Events: Fam17h+ core perfctr, Broken BIOS detected, complain to your hardware vendor.
> [    0.092023] [Firmware Bug]: the BIOS has corrupted hw-PMU resources (MSR c0010200 is 530076)
> 
> (5) In the worst case, the active kvm_pmc->perf_event may inject unknown
> NMIs randomly into the VM kernel:
> 
> [...] Uhhuh. NMI received for unknown reason 30 on CPU 0.
> 
> To resolve these issues, we propose resetting AMD PMU registers during the
> VM reset process
 
Hi Dongli,

Except for Patch 1 & 2 which need compatibility options (if you think
it's okay, I could help take these 2 and fix them when v11.0's compat
array is ready).

The other patches still LGTM. Maybe it's better to have a v8 excluding
patch 1 & 2?

Regards,
Zhao


  parent reply	other threads:[~2025-12-16  8:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11  6:14 [PATCH v7 0/9] target/i386/kvm/pmu: PMU Enhancement, Bugfix and Cleanup Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 1/9] target/i386: disable PerfMonV2 when PERFCORE unavailable Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 2/9] target/i386: disable PERFCORE when "-pmu" is configured Dongli Zhang
2025-11-19 11:06   ` Zhao Liu
2025-11-20  0:22     ` Dongli Zhang
2025-11-25  3:47       ` Zhao Liu
2025-11-11  6:14 ` [PATCH v7 3/9] target/i386/kvm: set KVM_PMU_CAP_DISABLE if " Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 4/9] target/i386/kvm: extract unrelated code out of kvm_x86_build_cpuid() Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 5/9] target/i386/kvm: rename architectural PMU variables Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 6/9] target/i386/kvm: query kvm.enable_pmu parameter Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 7/9] target/i386/kvm: reset AMD PMU registers during VM reset Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 8/9] target/i386/kvm: support perfmon-v2 for reset Dongli Zhang
2025-11-11  6:14 ` [PATCH v7 9/9] target/i386/kvm: don't stop Intel PMU counters Dongli Zhang
2025-11-19  2:07 ` [PATCH v7 0/9] target/i386/kvm/pmu: PMU Enhancement, Bugfix and Cleanup Dongli Zhang
2025-12-16  8:25 ` Zhao Liu [this message]
2025-12-18  6:36   ` Dongli Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aUEXkDDOba+oZ4v+@intel.com \
    --to=zhao1.liu@intel.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=babu.moger@amd.com \
    --cc=dapeng1.mi@linux.intel.com \
    --cc=davydov-max@yandex-team.ru \
    --cc=den@virtuozzo.com \
    --cc=dongli.zhang@oracle.com \
    --cc=ewanhai-oc@zhaoxin.com \
    --cc=ewanhai@zhaoxin.com \
    --cc=groug@kaod.org \
    --cc=joe.jin@oracle.com \
    --cc=khorenko@virtuozzo.com \
    --cc=kvm@vger.kernel.org \
    --cc=like.xu.linux@gmail.com \
    --cc=likexu@tencent.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sandipan.das@amd.com \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.