Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch-riscv: fix hpmCounter logic #251

Merged
merged 1 commit into from
Jan 2, 2025
Merged

arch-riscv: fix hpmCounter logic #251

merged 1 commit into from
Jan 2, 2025

Conversation

happy-lx
Copy link
Contributor

0277c32e33b5ff3474a74f488b451ea
  • when privilege mode is U, corresponding hpm counter can be read only when corresponding bit of scounteren and mcounteren are both set.
  • make scounteren writeable

Change-Id: Ia8332471232db9a2b2ce732ea74dae6497428eef

@eastonman
Copy link
Member

I have met a very similar problem recently.
MCOUNTEREN is writable and NEMU riscv64-gem5-ref_defconfig sets Zihpm and Zictr off, resulting in difftest error.

After allowing {M,S,H}COUNTEREN to be writable and turning Zihpm Zictr on, no difftest error happens. However, some checkpoints print opensbi trap messages which indicates more problems.

Do you have any idea about this?

@happy-lx
Copy link
Contributor Author

I have met a very similar problem recently. MCOUNTEREN is writable and NEMU riscv64-gem5-ref_defconfig sets Zihpm and Zictr off, resulting in difftest error. After allowing {M,S,H}COUNTEREN to be writable and turning Zihpm Zictr on, no difftest error happens.

image

yes, I have met very similar things before, I think these options should be turned on in NEMU

However, some checkpoints print opensbi trap messages which indicates more problems.

Do you have any idea about this?

984bf07b27bbc95edfe384b577bdbb4

I also encountered an opensbi trap problem. Later I found out that it was because reading the time csr on gem5 would always trigger illegal Instruction fault. I’m not sure if you are in a similar situation.

case CSR_TIME: {
std::string error = csprintf(
"force accessing to time CSR generate fault\n");
olddata = 0;
return std::make_shared<IllegalInstFault>(error, machInst);
break;
}

@eastonman
Copy link
Member

@happy-lx Yes, my opensbi trap problem is the same as yours.

@happy-lx happy-lx force-pushed the fix-hpm branch 3 times, most recently from c0e2160 to 0d560d7 Compare December 31, 2024 04:33
when privilege mode is U, corresponding hpm counter can be read only
when corresponding bit of scounteren and mcounteren are both set.

make {M,S,H}counteren writeable

Change-Id: Ia8332471232db9a2b2ce732ea74dae6497428eef
Copy link
Member

@eastonman eastonman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the code LGTM

@happy-lx happy-lx merged commit 0b08af4 into xs-dev Jan 2, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants