opensbi icon indicating copy to clipboard operation
opensbi copied to clipboard

Is there RISC-V privilege specification version detection SBI call?

Open nylon7 opened this issue 3 years ago • 0 comments

Hi @avpatel In my understanding, we use system register to check the privilege specification version.

        /* Detect if hart supports Priv v1.10 */
        val = csr_read_allowed(CSR_MCOUNTEREN, (unsigned long)&trap);
        if (!trap.cause)
                hfeatures->priv_version = SBI_HART_PRIV_VER_1_10;

        /* Detect if hart supports Priv v1.11 */
        val = csr_read_allowed(CSR_MCOUNTINHIBIT, (unsigned long)&trap);
        if (!trap.cause &&
            (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_10))
                hfeatures->priv_version = SBI_HART_PRIV_VER_1_11;

        /* Detect if hart supports Priv v1.12 */
        csr_read_allowed(CSR_MENVCFG, (unsigned long)&trap);
        if (!trap.cause &&
            (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_11))
                hfeatures->priv_version = SBI_HART_PRIV_VER_1_12;


But for riscv-state-enable feature, If we want to check in S-mode if it supports it, we haven't any function for this.

so maybe we need to add a new SBI call for privilege specification version detection?

nylon7 avatar Mar 13 '23 09:03 nylon7