riscv-software-src / opensbi

RISC-V Open Source Supervisor Binary Interface
Other
977 stars 493 forks source link

Detect extensions from $menvcfg #324

Open yong-xuan opened 1 year ago

yong-xuan commented 1 year ago

Hi @avpatel,

Currently "Boot HART ISA Extensions" only shows extensions which can be detected by test and set their CSR. Maybe we can detect more extensions from $menvcfg?

static int hart_detect_features(struct sbi_scratch *scratch)
{
    ...
    if (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {
        csr_write(CSR_MENVCFG, ~0);
        csr_read(CSR_MENVCFG, menvcfg_val);

        if (menvcfg_val | ENVCFG_CBZE)
            __sbi_hart_update_extension(hfeatures,
                    SBI_HART_EXT_ZICBOZ, true);
        ...
    }
    ...
}
atishp04 commented 11 months ago

Generally, we should move away from WARL based detection mechanism as it will be unmanageable in the future with more number of extensions.

yong-xuan commented 11 months ago

Hi @atishp04, Thank you! OpenSBI can detect extensions from the ISA string since https://github.com/riscv-software-src/opensbi/commit/d72f5f17478dfef3df817339a0f02cfdb77a1dc1. It appears that we can consider removing all extension detection within hart_detect_features()?