From: Dan Carpenter <dan.carpenter@oracle.com>
To: wehuang@redhat.com
Cc: kvm@vger.kernel.org
Subject: [bug report] KVM: x86/vPMU: Define kvm_pmu_ops to support vPMU function dispatch
Date: Thu, 18 May 2017 10:40:41 +0300 [thread overview]
Message-ID: <20170518074041.56rezj4wnpzrrhk7@mwanda> (raw)
Hello Wei Huang,
The patch 25462f7f5295: "KVM: x86/vPMU: Define kvm_pmu_ops to support
vPMU function dispatch" from Jun 19, 2015, leads to the following
static checker warning:
arch/x86/kvm/pmu_intel.c:297 intel_pmu_refresh()
warn: potential left shift more than type allows '0-32'
arch/x86/kvm/pmu_intel.c
277 pmu->version = eax.split.version_id;
278 if (!pmu->version)
279 return;
280
281 pmu->nr_arch_gp_counters = min_t(int, eax.split.num_counters,
282 INTEL_PMC_MAX_GENERIC);
^^^^^^^^^^^^^^^^^^^^^
We cap ->nr_arch_gp_counters at 32.
283 pmu->counter_bitmask[KVM_PMC_GP] = ((u64)1 << eax.split.bit_width) - 1;
284 pmu->available_event_types = ~entry->ebx &
285 ((1ull << eax.split.mask_length) - 1);
286
287 if (pmu->version == 1) {
288 pmu->nr_arch_fixed_counters = 0;
289 } else {
290 pmu->nr_arch_fixed_counters =
291 min_t(int, edx.split.num_counters_fixed,
292 INTEL_PMC_MAX_FIXED);
293 pmu->counter_bitmask[KVM_PMC_FIXED] =
294 ((u64)1 << edx.split.bit_width_fixed) - 1;
295 }
296
297 pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Potential shift wrapping bug.
298 (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
299 pmu->global_ctrl_mask = ~pmu->global_ctrl;
300
301 entry = kvm_find_cpuid_entry(vcpu, 7, 0);
302 if (entry &&
303 (boot_cpu_has(X86_FEATURE_HLE) || boot_cpu_has(X86_FEATURE_RTM)) &&
304 (entry->ebx & (X86_FEATURE_HLE|X86_FEATURE_RTM)))
305 pmu->reserved_bits ^= HSW_IN_TX|HSW_IN_TX_CHECKPOINTED;
regards,
dan carpenter
reply other threads:[~2017-05-18 7:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20170518074041.56rezj4wnpzrrhk7@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=wehuang@redhat.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.