From: sashiko-bot@kernel.org
To: "Zide Chen" <zide.chen@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH V4 4/4] KVM: selftests: Add perf_metrics and fixed counter 3 tests
Date: Tue, 23 Jun 2026 04:43:06 +0000 [thread overview]
Message-ID: <20260623044306.BD8341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260623041927.178256-5-zide.chen@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] KVM's emulator unconditionally injects a #GP on guest accesses to MSR_PERF_METRICS, breaking instruction emulation and nested virtualization. The selftest omits forced emulation coverage that would expose this.
--
commit f588cce382d8777ebda7951bd3447ee7ba4c18ff
Author: Zide Chen <zide.chen@intel.com>
KVM: selftests: Add perf_metrics and fixed counter 3 tests
Add a selftest to exercise IA32_PERF_METRICS, i.e. architectural
support for Topdown (TMA) Level 1 metrics, enumerated by
IA32_PERF_CAPABILITIES[15].
> diff --git a/tools/testing/selftests/kvm/x86/pmu_counters_test.c b/tools/testing/selftests/kvm/x86/pmu_counters_test.c
> index dc6afac3aa919..d4688a7d1e556 100644
> --- a/tools/testing/selftests/kvm/x86/pmu_counters_test.c
> +++ b/tools/testing/selftests/kvm/x86/pmu_counters_test.c
[ ... ]
> @@ -318,6 +322,56 @@ static void guest_test_arch_event(u8 idx)
> FIXED_PMC_GLOBAL_CTRL_ENABLE(i));
> }
>
> +static void guest_test_perf_metrics(void)
> +{
[ ... ]
> + /* Sanity check after PERF_METRICS disabled. */
> + __asm__ __volatile__("loop ." : "+c"((int){NUM_LOOPS}));
> + GUEST_ASSERT_EQ(rdmsr(MSR_PERF_METRICS), metrics);
> + wrmsr(MSR_PERF_METRICS, 0xdeaddead);
> +
> + GUEST_ASSERT_EQ(rdmsr(MSR_PERF_METRICS), 0xdeaddead);
> +}
[Severity: High]
Should this test include forced emulation (e.g., using KVM_FEP) coverage for
these MSR_PERF_METRICS accesses?
Currently, the selftest relies purely on native rdmsr/wrmsr execution.
If these instructions were emulated, it would expose an issue in
intel_pmu_get_msr() and intel_pmu_set_msr() where KVM's emulator
unconditionally injects a #GP on guest accesses because they return 1
when !msr_info->host_initiated.
Could we add forced emulation coverage to catch emulator issues that break
instruction emulation and nested virtualization?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260623041927.178256-1-zide.chen@intel.com?part=4
prev parent reply other threads:[~2026-06-23 4:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 4:19 [PATCH V4 0/4] KVM: x86/pmu: Add hardware Topdown metrics support Zide Chen
2026-06-23 4:19 ` [PATCH V4 1/4] KVM: x86/pmu: Do not map fixed counters >= 3 to generic perf events Zide Chen
2026-06-23 4:19 ` [PATCH V4 2/4] KVM: x86/pmu: Support Intel fixed counter 3 on mediated vPMU Zide Chen
2026-06-23 4:19 ` [PATCH V4 3/4] KVM: x86/pmu: Support PERF_METRICS MSR in " Zide Chen
2026-06-23 4:48 ` sashiko-bot
2026-06-23 7:04 ` Mi, Dapeng
2026-06-23 4:19 ` [PATCH V4 4/4] KVM: selftests: Add perf_metrics and fixed counter 3 tests Zide Chen
2026-06-23 4:43 ` sashiko-bot [this message]
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=20260623044306.BD8341F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zide.chen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox