Skip to content
Snippets Groups Projects
Commit 5898671f authored by Like Xu's avatar Like Xu Committed by Zheng Zengkai
Browse files

KVM: x86/pmu: Update AMD PMC sample period to fix guest NMI-watchdog

mainline inclusion
from mainline-v5.18
commit 75189d1de1b377e580ebd2d2c55914631eac9c64
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5RD6Y


CVE: NA

-------------

NMI-watchdog is one of the favorite features of kernel developers,
but it does not work in AMD guest even with vPMU enabled and worse,
the system misrepresents this capability via /proc.

This is a PMC emulation error. KVM does not pass the latest valid
value to perf_event in time when guest NMI-watchdog is running, thus
the perf_event corresponding to the watchdog counter will enter the
old state at some point after the first guest NMI injection, forcing
the hardware register PMC0 to be constantly written to 0x800000000001.

Meanwhile, the running counter should accurately reflect its new value
based on the latest coordinated pmc->counter (from vPMC's point of view)
rather than the value written directly by the guest.

Fixes: 168d918f ("KVM: x86: Adjust counter sample period after a wrmsr")
Reported-by: default avatarDongli Cao <caodongli@kingsoft.com>
Signed-off-by: default avatarLike Xu <likexu@tencent.com>
Reviewed-by: default avatarYanan Wang <wangyanan55@huawei.com>
Tested-by: default avatarYanan Wang <wangyanan55@huawei.com>
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Message-Id: <20220409015226.38619-1-likexu@tencent.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: default avatarKeqian Zhu <zhukeqian1@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent e7815ebf
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment