From: Like Xu <like.xu.linux@gmail.com>
To: pbonzini@redhat.com
Cc: jmattson@google.com, like.xu.linux@gmail.com, joro@8bytes.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com
Subject: [PATCH v2] KVM: x86/pmu: Don't pre-set the pmu->global_ctrl when refreshing
Date: Tue, 10 May 2022 12:44:07 +0800 [thread overview]
Message-ID: <20220510044407.26445-1-likexu@tencent.com> (raw)
In-Reply-To: <20220509102204.62389-2-likexu@tencent.com>
From: Like Xu <likexu@tencent.com>
Assigning a value to pmu->global_ctrl just to set the value of
pmu->global_ctrl_mask in a more readable way leaves a side effect of
not conforming to the specification. The value is reset to zero on
Power up and Reset but keeps unchanged on INIT, like an ordinary MSR.
Signed-off-by: Like Xu <likexu@tencent.com>
---
v1 -> v2 Changelog:
- Explicitly add parentheses around;
arch/x86/kvm/vmx/pmu_intel.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index b82b6709d7a8..7829ec457b28 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -522,9 +522,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
setup_fixed_pmc_eventsel(pmu);
}
- pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) |
- (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
- pmu->global_ctrl_mask = ~pmu->global_ctrl;
+ pmu->global_ctrl_mask = ~(((1ull << pmu->nr_arch_gp_counters) - 1) |
+ (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED));
pmu->global_ovf_ctrl_mask = pmu->global_ctrl_mask
& ~(MSR_CORE_PERF_GLOBAL_OVF_CTRL_OVF_BUF |
MSR_CORE_PERF_GLOBAL_OVF_CTRL_COND_CHGD);
--
2.36.1
next prev parent reply other threads:[~2022-05-10 4:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-09 10:22 [PATCH 1/3] KVM: x86/pmu: Ignore pmu->global_ctrl check if vPMU doesn't support global_ctrl Like Xu
2022-05-09 10:22 ` [PATCH 2/3] KVM: x86/pmu: Don't pre-set the pmu->global_ctrl when refreshing Like Xu
2022-05-10 4:37 ` [PATCH V2 " Like Xu
2022-05-10 4:44 ` Like Xu [this message]
2022-05-20 14:25 ` [PATCH v2] " Paolo Bonzini
2022-05-15 9:22 ` [KVM] db16e9b28b: kvm-unit-tests.pmu.fail kernel test robot
2022-05-15 9:25 ` Like Xu
2022-05-24 13:36 ` Oliver Sang
2022-05-09 10:22 ` [PATCH 3/3] KVM: x86/pmu: Drop redundant-clumsy-asymmetric PERFCTR_CORE MSRs handling Like Xu
2022-05-20 14:32 ` Paolo Bonzini
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=20220510044407.26445-1-likexu@tencent.com \
--to=like.xu.linux@gmail.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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
all inboxes | Powered by JetHome®