lib: sbi: Fix typo CSR_CYCLE -> CSR_TIME
PATCH 1/1 lib: sbi: Fix typo CSR_CYCLE -> CSR_TIME
When emulating CSR_TIME, the hpm_allowed check should be for CSR_TIME, not for CSR_CYCLE.
time CSR")
--- lib/sbi/sbi_emulate_csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/sbi/sbi_emulate_csr.c +0 -0
@@ -62,7 +62,7 @@ int sbi_emulate_csr_read(int csr_num, struct
sbi_trap_regs *regs,
*csr_val = csr_read(CSR_MCYCLE);
break;
case CSR_TIME:
- if (!hpm_allowed(csr_num - CSR_CYCLE, prev_mode, virt))
+ if (!hpm_allowed(csr_num - CSR_TIME, prev_mode, virt))
return SBI_ENOTSUPP;
/*
* We emulate TIME CSR for both Host (HS/U-mode) and
Signature · 1 line
2.47.2
Xiang W
NAKPATCH 1/1 lib: sbi: Fix typo CSR_CYCLE -> CSR_TIME
? 2025-02-26?? 17:02 +0800?dramforever???
Quoted 6 lines
When emulating
CSR_TIME, thehpm_allowedcheck should be forCSR_TIME, not forCSR_CYCLE.Fixes beef2f693785 ("lib: sbi: Respect scounteren when emulating thetime CSR")
Signed-off-by Vivian Wang <[email protected]>
The counter enable is controlled by the bits in MCOUNTEREN/HCOUNTEREN/SCOUNTEREN.
MCOUNTEREN/HCOUNTEREN/SCOUNTEREN as shown below
+-------+-------+-------+---------------+------+----+----+----+ | HPM31 | HPM30 | HPM29 | ... | HPM3 | IR | TM | CY | +-------+-------+-------+---------------+------+----+----+----+
The counters address is as follows:0xc00 cycle0xc01 time0xc02 instret0xc03 hpmcounter3
...0xc1d hpmcounter290xc1e hpmcounter300xc1f hpmcounter31
The value obtained by subtracting the address of the cycle from the address of the counter is the offset in xCOUNTER that corresponds to this counter enable bit.
NACK
Regards,
Xiang W
Quoted 22 lines
---
?lib/sbi/sbi_emulate_csr.c | 2 +-
?1 file changed, 1 insertion(+), 1 deletion(-)lib/sbi/sbi_emulate_csr.c +0
-0@@ -62,7 +62,7 @@ int sbi_emulate_csr_read(int csr_num, structsbi_trap_regs *regs, ? *csr_val = csr_read(CSR_MCYCLE); ? break;? case
CSR_TIME:lib/sbi/sbi_emulate_csr.c +1
-1-if (!hpm_allowed (csr_num -CSR_CYCLE , prev_mode, virt)) +if (!hpm_allowed (csr_num -CSR_TIME , prev_mode, virt))? return
SBI_ENOTSUPP;
? /*
? * We emulate TIME CSR for both Host (HS/U-mode) andSignature · 1 line
2.47.2
PATCH 1/1 lib: sbi: Fix typo CSR_CYCLE -> CSR_TIME
Quoted 24 lines · Xiang W
? 2025-02-26?? 17:02 +0800?dramforever???
Quoted 6 lines
When emulating
CSR_TIME, thehpm_allowedcheck should be forCSR_TIME, not forCSR_CYCLE.Fixes beef2f693785 ("lib: sbi: Respect scounteren when emulating thetime CSR")
Signed-off-by Vivian Wang <[email protected]>The counter enable is controlled by the bits in MCOUNTEREN/HCOUNTEREN/SCOUNTEREN.
MCOUNTEREN/HCOUNTEREN/SCOUNTEREN as shown below
+-------+-------+-------+---------------+------+----+----+----+ | HPM31 | HPM30 | HPM29 | ... | HPM3 | IR | TM | CY | +-------+-------+-------+---------------+------+----+----+----+The counters address is as follows:
0xc00cycle0xc01time0xc02instret0xc03hpmcounter3
...0xc1dhpmcounter290xc1ehpmcounter300xc1fhpmcounter31
Quoted 3 lines
The value obtained by subtracting the address of the cycle from the address of the counter is the offset in xCOUNTER that corresponds to this counter enable bit.
Oops, sorry, thanks for the catch
dram
Quoted 28 lines
NACK
Regards,
Xiang WQuoted 22 lines
---
?lib/sbi/sbi_emulate_csr.c | 2 +-
?1 file changed, 1 insertion(+), 1 deletion(-)lib/sbi/sbi_emulate_csr.c +0
-0@@ -62,7 +62,7 @@ int sbi_emulate_csr_read(int csr_num, structsbi_trap_regs *regs, ? *csr_val = csr_read(CSR_MCYCLE); ? break;? case
CSR_TIME:lib/sbi/sbi_emulate_csr.c +1
-1-if (!hpm_allowed (csr_num -CSR_CYCLE , prev_mode, virt)) +if (!hpm_allowed (csr_num -CSR_TIME , prev_mode, virt))? return
SBI_ENOTSUPP;
? /*
? * We emulate TIME CSR for both Host (HS/U-mode) andSignature · 1 line
2.47.2