Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMU: Placeholder for future fix to match SBI start / stop counter implementation change... #59

Open
atulkharerivos opened this issue Aug 17, 2022 · 0 comments
Labels
pmu Issues related to PMU virtualization

Comments

@atulkharerivos
Copy link
Contributor

Presently, the implementation of the OpenSBI calls to start / stop counters is permissive, and the semantics of a specific combination of implemented platform counters, and the counter mask bits is loosely defined (see reference code below). Per the chat with @atishp04, this can be tightened by mandating sets bits only for valid counters, and so forth.

The current Salus implementation deliberately approximates the implementation in the interest of SW compatibility. When the SBI code is fixed, we should implement stricter checks in Salus.

Snippet from existing SBI Implementation:

int sbi_pmu_ctr_start(unsigned long cbase, unsigned long cmask,
                      unsigned long flags, uint64_t ival)
{
        int event_idx_type;
        uint32_t event_code;
        unsigned long ctr_mask = cmask << cbase;
        int ret = SBI_EINVAL;
        bool bUpdate = FALSE;

        if (sbi_fls(ctr_mask) >= total_ctrs)
                return ret;

        if (flags & SBI_PMU_START_FLAG_SET_INIT_VALUE)
                bUpdate = TRUE;

        for_each_set_bit_from(cbase, &ctr_mask, total_ctrs) {
                event_idx_type = pmu_ctr_validate(cbase, &event_code);
                if (event_idx_type < 0)
                        /* Continue the start operation for other counters */
                        continue;
                else if (event_idx_type == SBI_PMU_EVENT_TYPE_FW)
                        ret = pmu_ctr_start_fw(cbase, event_code, ival, bUpdate);
                else
                        ret = pmu_ctr_start_hw(cbase, ival, bUpdate);
        }

        return ret;
}

@abrestic-rivos abrestic-rivos added the pmu Issues related to PMU virtualization label Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pmu Issues related to PMU virtualization
Projects
None yet
Development

No branches or pull requests

2 participants