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

Fix read value of CSR mip. #1869

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NewPaulWalker
Copy link
Contributor

The read value of mip should not depend on the value of hvip.

hvip.VSSIP is an alias of mip.VSSIP, so when reading hvip, the VSSIP bit of mip needs to be OR-ed. Similarly, when writing to hvip, the VSSIP bit of mip also needs to be updated.

However, there is no reason for the value of mip to depend on the value of hvip when being read.

@demin-han
Copy link
Contributor

#1590 add the hvip read.

@NewPaulWalker
Copy link
Contributor Author

#1590 add the hvip read.

Yes, the read value of hvip should depend on the value of mip, but the read value of mip should not depend on the value of hvip.

@demin-han
Copy link
Contributor

#1590 add the hvip read.

Yes, the read value of hvip should depend on the value of mip, but the read value of mip should not depend on the value of hvip.

without hvip read, the MIP_VSEIP and MIP_VSTIP will miss when reading mip.
These two bits are stored in hvip.

bool hvip_csr_t::unlogged_write(const reg_t val) noexcept {
state->mip->write_with_mask(MIP_VSSIP, val); // hvip.VSSIP is an alias of mip.VSSIP
const reg_t lscof_int = proc->extension_enabled(EXT_SSCOFPMF) ? MIP_LCOFIP : 0;
return basic_csr_t::unlogged_write(val & (lscof_int | MIP_VSEIP | MIP_VSTIP));
}

@NewPaulWalker
Copy link
Contributor Author

without hvip read, the MIP_VSEIP and MIP_VSTIP will miss when reading mip.
These two bits are stored in hvip.

Thank you for the reminder!

Yes, the read value of mip should depend on hvip, but only on the hvip.VSEIP and hvip.VSTIP bits.

Previously, directly OR-ing the read value of mip with the read value of hvip was fine. However, after I modified the write behavior of hvip: #1862 — specifically, after implementing the Sscofpmf extension, hvip.LCOFIP became writable. This caused an issue where the entire value of hvip was OR-ed when reading mip.

I will revise the mip read logic to make it depend only on the hvip.VSEIP and hvip.VSTIP bits.
Thank you again for the reminder.

The read value of mip should only depend on the two bits, VSEIP and VSTIP of hvip.

This PR fix the read value of CSR mip when Sscofpmf extension enabled.

After implementing the Sscofpmf extension, hvip.LCOFIP became writable.
This caused an issue where the entire value of hvip was OR-ed when reading mip.

I revise the mip read logic to make it depend only on the hvip.VSEIP and hvip.VSTIP bits.

Co-authored-by: Zhaoyang You <zyyou1998@gmail.com>
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.

2 participants