diff options
author | Anup Patel <apatel@ventanamicro.com> | 2023-12-27 12:25:09 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-12-27 12:25:09 +0530 |
commit | bbd065d903c8cafdcdc01aea5ccf280e17137013 (patch) | |
tree | 1c270c21d401d85f1b4e8726861b7b284597b341 /lib/sbi/sbi_hart.c | |
parent | ba29293dc947e13fa2e63de7ed289d7bb9b540f4 (diff) | |
download | opensbi-bbd065d903c8cafdcdc01aea5ccf280e17137013.zip opensbi-bbd065d903c8cafdcdc01aea5ccf280e17137013.tar.gz opensbi-bbd065d903c8cafdcdc01aea5ccf280e17137013.tar.bz2 |
lib: sbi: Detect Zicntr extension only based on traps
OpenSBI uses time CSR if Zicntr extension present which causes
it to crash on an older QEMU because QEMU generates Zicntr in
the ISA string for unleashed machine which only has CYCLE and
INSTRET counters.
Fixes: 776770d2adbf ("lib: sbi: Using one array to define the
name of extensions")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib/sbi/sbi_hart.c')
-rw-r--r-- | lib/sbi/sbi_hart.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index e2b93e6..770fee0 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -748,6 +748,7 @@ static int hart_detect_features(struct sbi_scratch *scratch) struct sbi_hart_features *hfeatures = sbi_scratch_offset_ptr(scratch, hart_features_offset); unsigned long val, oldval; + bool has_zicntr = false; int rc; /* If hart features already detected then do nothing */ @@ -900,12 +901,19 @@ __pmp_skip: #undef __check_ext_csr + /* Save trap based detection of Zicntr */ + has_zicntr = sbi_hart_has_extension(scratch, SBI_HART_EXT_ZICNTR); + /* Let platform populate extensions */ rc = sbi_platform_extensions_init(sbi_platform_thishart_ptr(), hfeatures); if (rc) return rc; + /* Zicntr should only be detected using traps */ + __sbi_hart_update_extension(hfeatures, SBI_HART_EXT_ZICNTR, + has_zicntr); + /* Extensions implied by other extensions and features */ if (hfeatures->mhpm_mask) __sbi_hart_update_extension(hfeatures, |