Skip to content

Commit 30c0267

Browse files
Dapeng Misean-jc
authored andcommitted
KVM: x86/pmu: Use BIT_ULL() instead of open coded equivalents
Replace a variety of "1ull << N" and "(u64)1 << N" snippets with BIT_ULL() in the PMU code. No functional change intended. Signed-off-by: Dapeng Mi <[email protected]> [sean: split to separate patch, write changelog] Tested-by: Xudong Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 2bff2ed commit 30c0267

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

arch/x86/kvm/svm/pmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ static void amd_pmu_refresh(struct kvm_vcpu *vcpu)
200200
kvm_pmu_cap.num_counters_gp);
201201

202202
if (pmu->version > 1) {
203-
pmu->global_ctrl_rsvd = ~((1ull << pmu->nr_arch_gp_counters) - 1);
203+
pmu->global_ctrl_rsvd = ~(BIT_ULL(pmu->nr_arch_gp_counters) - 1);
204204
pmu->global_status_rsvd = pmu->global_ctrl_rsvd;
205205
}
206206

207-
pmu->counter_bitmask[KVM_PMC_GP] = ((u64)1 << 48) - 1;
207+
pmu->counter_bitmask[KVM_PMC_GP] = BIT_ULL(48) - 1;
208208
pmu->reserved_bits = 0xfffffff000280000ull;
209209
pmu->raw_event_mask = AMD64_RAW_EVENT_MASK;
210210
/* not applicable to AMD; but clean them to prevent any fall out */

arch/x86/kvm/vmx/pmu_intel.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,10 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
536536
kvm_pmu_cap.num_counters_gp);
537537
eax.split.bit_width = min_t(int, eax.split.bit_width,
538538
kvm_pmu_cap.bit_width_gp);
539-
pmu->counter_bitmask[KVM_PMC_GP] = ((u64)1 << eax.split.bit_width) - 1;
539+
pmu->counter_bitmask[KVM_PMC_GP] = BIT_ULL(eax.split.bit_width) - 1;
540540
eax.split.mask_length = min_t(int, eax.split.mask_length,
541541
kvm_pmu_cap.events_mask_len);
542-
pmu->available_event_types = ~entry->ebx &
543-
((1ull << eax.split.mask_length) - 1);
542+
pmu->available_event_types = ~entry->ebx & (BIT_ULL(eax.split.mask_length) - 1);
544543

545544
if (pmu->version == 1) {
546545
pmu->nr_arch_fixed_counters = 0;
@@ -549,16 +548,15 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
549548
kvm_pmu_cap.num_counters_fixed);
550549
edx.split.bit_width_fixed = min_t(int, edx.split.bit_width_fixed,
551550
kvm_pmu_cap.bit_width_fixed);
552-
pmu->counter_bitmask[KVM_PMC_FIXED] =
553-
((u64)1 << edx.split.bit_width_fixed) - 1;
551+
pmu->counter_bitmask[KVM_PMC_FIXED] = BIT_ULL(edx.split.bit_width_fixed) - 1;
554552
}
555553

556554
intel_pmu_enable_fixed_counter_bits(pmu, INTEL_FIXED_0_KERNEL |
557555
INTEL_FIXED_0_USER |
558556
INTEL_FIXED_0_ENABLE_PMI);
559557

560-
counter_rsvd = ~(((1ull << pmu->nr_arch_gp_counters) - 1) |
561-
(((1ull << pmu->nr_arch_fixed_counters) - 1) << KVM_FIXED_PMC_BASE_IDX));
558+
counter_rsvd = ~((BIT_ULL(pmu->nr_arch_gp_counters) - 1) |
559+
((BIT_ULL(pmu->nr_arch_fixed_counters) - 1) << KVM_FIXED_PMC_BASE_IDX));
562560
pmu->global_ctrl_rsvd = counter_rsvd;
563561

564562
/*
@@ -603,8 +601,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
603601
pmu->pebs_data_cfg_rsvd = ~0xff00000full;
604602
intel_pmu_enable_fixed_counter_bits(pmu, ICL_FIXED_0_ADAPTIVE);
605603
} else {
606-
pmu->pebs_enable_rsvd =
607-
~((1ull << pmu->nr_arch_gp_counters) - 1);
604+
pmu->pebs_enable_rsvd = ~(BIT_ULL(pmu->nr_arch_gp_counters) - 1);
608605
}
609606
}
610607
}

0 commit comments

Comments
 (0)