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

Refactor put_csr to direct write #1563

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

demin-han
Copy link
Contributor

  1. put_csr needs search
  2. MSTATUS_MPV not written back for RV32

1. put_csr needs search
2. MSTATUS_MPV not written back for RV32

Signed-off-by: demin.han <demin.han@starfivetech.com>
Copy link
Contributor

@scottj97 scottj97 left a comment

Choose a reason for hiding this comment

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

I agree this is an improvement -- no reason to require a lookup into csrmap -- but I don't understand the part about "MSTATUS_MPV not written back for RV32".

Is there a bug that this fixes? If so we need a lot more explanation of the case.

I can't see how this change would affect MPV on RV32, but maybe I'm missing something.

@demin-han
Copy link
Contributor Author

@scottj97
MPV located in mstatush when RV32.

if (xlen == 32) {
csrmap[CSR_MSTATUS] = std::make_shared<rv32_low_csr_t>(proc, CSR_MSTATUS, mstatus);
csrmap[CSR_MSTATUSH] = mstatush = std::make_shared<rv32_high_csr_t>(proc, CSR_MSTATUSH, mstatus);
} else {
csrmap[CSR_MSTATUS] = mstatus;
}

CSR_MSTUTUS is associated with lower part of mstatus when RV32.
so put_csr(CSR_MSTATUS, s) only update lower part of mstatus, MPV in mstatush not updated.

Copy link
Contributor

@scottj97 scottj97 left a comment

Choose a reason for hiding this comment

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

Yes. I see the problem now.

I think RV32 Hypervisor has seen very limited usage (or none at all) because I suspect this has been broken all along, since MPV was first added.

I've confirmed that this PR doesn't change any RV64 Hypervisor behavior, but I don't have any test coverage of RV32 Hypervisor.

Copy link
Collaborator

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

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

Ah, that's subtle.

@aswaterman aswaterman merged commit f80fc52 into riscv-software-src:master Jan 12, 2024
3 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.

3 participants