I am trying to use the performance counters in the Rocket core which runs Linux and has 15 performance counters (nPerfCounters is set to 15 in Rocket.scala) on Firesim. I have tried using perf, but it seems like it cannot see any {m}hpmcounters (but instruction and cycle counters work). Also, I tried using the commands in [1] which do work when running in a bare-metal setting on VCS. However, an illegal instruction exception is raised on Linux which should be due to some privilege problem. I also tried adding the write_csr command in the iceblk kernel module as well, so that the command is run inside the kernel space, but got the same exception.
What should be the right way to use the performance counters in the Rocket core?
[1]
https://docs.boom-core.org/en/latest/sections/uarch-counters.htmlHere is the illegal instruction exception from the iceblk module
[ 0.273600] disk [iceblk] of loaded; 798000 sectors, 1 tags, 16 max request length
[ 0.273683] Oops - illegal instruction [#1]
[ 0.273727] Modules linked in: iceblk(O+) icenet(O)
[ 0.273789] CPU: 0 PID: 71 Comm: modprobe Tainted: G O 5.7.0-rc3-58539-g5f5fd87b36e2-dirty #28
[ 0.273884] epc: ffffffdf8110a5b0 ra : ffffffdf8110a5ae sp : ffffffe3eee399d0
[ 0.273985] gp : ffffffe00106e428 tp : ffffffe3eff94600 t0 : ffffffe001081fe0
[ 0.274213] t1 : 0000000000042cc0 t2 : 0000000000000000 s0 : ffffffe3eee39a70
[ 0.274442] s1 : ffffffe3ef4a3a18 a0 : 0000000000000046 a1 : 0000000200000020
[ 0.274670] a2 : 0000000000000000 a3 : 0000000000000000 a4 : ffffffe001012a10
[ 0.274898] a5 : ffffffffffffffff a6 : 0000000000000000 a7 : 0000000000000088
[ 0.275127] s2 : 0000000000000010 s3 : 00000000000c2d30 s4 : ffffffe3eff61810
[ 0.275356] s5 : 0000000000000000 s6 : 0000000000000001 s7 : 00000000000c2d30
[ 0.275585] s8 : ffffffe3eff61810 s9 : ffffffe3ef4a3a40 s10: ffffffdf8110af18
[ 0.275813] s11: ffffffdf8110add0 t3 : 0000000000000000 t4 : 000000000001dce8
[ 0.276040] t5 : 0000000000000000 t6 : ffffffe00107d4e5
[ 0.276210] status: 0000000200000120 badaddr: 0000000030679073 cause: 0000000000000002
[ 0.276507] ---[ end trace 6ea5ece27fbfc49b ]---
Segmentation fault
Mounting /dev/iceblk as root device