Lines Matching defs:kvpmu

157 static int kvm_pmu_get_programmable_pmc_index(struct kvm_pmu *kvpmu, unsigned long eidx,
166 min = kvpmu->num_hw_ctrs;
167 max = min + kvpmu->num_fw_ctrs;
171 max = kvpmu->num_hw_ctrs;
177 !test_bit(pmc_idx, kvpmu->pmc_in_use)) {
202 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
207 pmc = &kvpmu->pmc[cidx];
211 pmc->counter_val = kvpmu->fw_event[fevent_code].value;
222 static int kvm_pmu_validate_counter_mask(struct kvm_pmu *kvpmu, unsigned long ctr_base,
226 if (!ctr_mask || (ctr_base + __fls(ctr_mask) >= kvm_pmu_num_counters(kvpmu)))
265 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
268 if (!kvpmu || fid >= SBI_PMU_FW_MAX)
271 fevent = &kvpmu->fw_event[fid];
282 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
285 if (!kvpmu || !kvpmu->init_done) {
316 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
318 retdata->out_val = kvm_pmu_num_counters(kvpmu);
326 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
333 retdata->out_val = kvpmu->pmc[cidx].cinfo.value;
342 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
347 if (kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0) {
355 if (!test_bit(pmc_index, kvpmu->pmc_in_use))
357 pmc = &kvpmu->pmc[pmc_index];
368 if (kvpmu->fw_event[fevent_code].started) {
373 kvpmu->fw_event[fevent_code].started = true;
374 kvpmu->fw_event[fevent_code].value = pmc->counter_val;
398 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
404 if (kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0) {
412 if (!test_bit(pmc_index, kvpmu->pmc_in_use))
414 pmc = &kvpmu->pmc[pmc_index];
422 if (!kvpmu->fw_event[fevent_code].started)
425 kvpmu->fw_event[fevent_code].started = false;
446 clear_bit(pmc_index, kvpmu->pmc_in_use);
465 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
482 if (kvm_pmu_validate_counter_mask(kvpmu, ctr_base, ctr_mask) < 0) {
499 if (!test_bit(ctr_base + __ffs(ctr_mask), kvpmu->pmc_in_use)) {
505 ctr_idx = pmu_get_pmc_index(kvpmu, eidx, ctr_base, ctr_mask);
512 pmc = &kvpmu->pmc[ctr_idx];
517 kvpmu->fw_event[event_code].started = true;
524 set_bit(ctr_idx, kvpmu->pmc_in_use);
548 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
566 kvpmu->num_hw_ctrs = num_hw_ctrs + 1;
567 kvpmu->num_fw_ctrs = SBI_PMU_FW_MAX;
568 memset(&kvpmu->fw_event, 0, SBI_PMU_FW_MAX * sizeof(struct kvm_fw_event));
570 if (kvpmu->num_hw_ctrs > RISCV_KVM_MAX_HW_CTRS) {
572 kvpmu->num_hw_ctrs = RISCV_KVM_MAX_HW_CTRS;
581 for (i = 0; i < kvm_pmu_num_counters(kvpmu); i++) {
585 pmc = &kvpmu->pmc[i];
588 if (i < kvpmu->num_hw_ctrs) {
608 kvpmu->init_done = true;
613 struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
617 if (!kvpmu)
620 for_each_set_bit(i, kvpmu->pmc_in_use, RISCV_MAX_COUNTERS) {
621 pmc = &kvpmu->pmc[i];
626 bitmap_zero(kvpmu->pmc_in_use, RISCV_MAX_COUNTERS);
627 memset(&kvpmu->fw_event, 0, SBI_PMU_FW_MAX * sizeof(struct kvm_fw_event));