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(csr, exception): divide the excep raised from csrrw into 2 stages #739

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

Conversation

NewPaulWalker
Copy link
Contributor

@NewPaulWalker NewPaulWalker commented Dec 26, 2024

Before this, we assumed that all possible exceptions during CSR read and write operations should be handled according to their priority.

Therefore, we used has_vi to record whether a virtual instruction exception exists and ensured that all illegal instruction exceptions take precedence over virtual instruction exceptions.

However, with the implementation of certain extensions like Smcsrind and Smstateen, we encounter scenarios where virtual instruction exceptions must take precedence over illegal instruction exceptions triggered.

For instance, when mstateen0.csrind is set to 1 and hstateen0.csrind is 0, a virtual instruction exception should be raised if VS mode attempts to access sireg. However, if the vsiselect value is reserved in this situation, an illegal instruction exception will be raised instead. If these checks are treated as being at the same priority level, an illegal instruction exception would ultimately be raised.

In reality, a virtual instruction exception should take precedence because when the extension is disabled, we should not even evaluate the value of vsiselect.

We should first check whether the CSR exists, is read-only, has proper permissions, and is enabled/disabled before proceeding to check indirect CSR accesses.

@NewPaulWalker NewPaulWalker changed the title fix(csr, exception): divide the excep raised from csrrw into 4 stages fix(csr, exception): divide the excep raised from csrrw into 2 stages Dec 27, 2024
Before this, we assumed that all possible exceptions during CSR
read and write operations should be handled according to their priority.

Therefore, we used has_vi to record whether a virtual instruction exception
exists and ensured that all illegal instruction exceptions take precedence
over virtual instruction exceptions.

However, with the implementation of certain extensions like Smcsrind and
Smstateen, we encounter scenarios where virtual instruction exceptions must
take precedence over illegal instruction exceptions triggered.

For instance, when mstateen0.csrind is set to 1 and hstateen0.csrind is 0,
a virtual instruction exception should be raised if VS mode attempts to
access sireg. However, if the vsiselect value is reserved in this situation,
an illegal instruction exception will be raised instead. If these checks are
treated as being at the same priority level, an illegal instruction exception
would ultimately be raised.

In reality, a virtual instruction exception should take precedence because
when the extension is disabled, we should not even evaluate the value of
vsiselect.

We should first check whether the CSR exists, is read-only, has proper
permissions, and is enabled/disabled before proceeding to check indirect CSR
accesses.
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.

1 participant