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

AR: Clarify mcontext/hcontext. #882

Merged
merged 1 commit into from
Sep 28, 2023
Merged

AR: Clarify mcontext/hcontext. #882

merged 1 commit into from
Sep 28, 2023

Conversation

timsifive
Copy link
Contributor

It was a bit confusing before. Hopefully now it's more clear how they relate, and why you might want each one.

Comment on lines 221 to 222
This optional register may only be implemented if the H extension is
implemented. If it is implemented, \RcsrMcontext must also be implemented.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"may only be implemented" seems ambiguous because "may only" is kind of like "may not" which is like "you may not have a piece of candy."

Somehow this slight tweak seems less ambiguous to me:

Suggested change
This optional register may only be implemented if the H extension is
implemented. If it is implemented, \RcsrMcontext must also be implemented.
This optional register may be implemented only if the H extension is
implemented. If it is implemented, \RcsrMcontext must also be implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

If the H extension is not implemented then this register is not
implemented, though the underlying state may be accessible via
the optional \RcsrMcontext alias.
if Smstateen is implemented, then accessibility of this CSR in HS-Mode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if Smstateen is implemented, then accessibility of this CSR in HS-Mode
If Smstateen is implemented, then accessibility of this CSR in HS-Mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 266 to 268
This register is an alias of the \RcsrHcontext register, and provides
access to the \FcsrHcontextHcontext field even if the \RcsrHcontext
register is not implemented.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems confusing to me. It's an alias of a register that's not implemented.

I was going to suggest that we say: If hcontext is implemented then this is an alias of that. If hcontext is not implemented then this is its own register.

Then it occurred to me that there's no definition of mcontext fields in the latter scenario. Maybe we should reverse things and define the fields here. Then mcontext doesn't need to say anything about hcontext except that it must exist if hcontext exists (which it says in the previous paragraph). And hcontext simply says that it's an optional alias of mcontext and which modes it's accessible in.

The only complication is that the field name within this register is named hcontext. But maybe that's OK if we explain that one primary purpose of mcontext is for hypervisors running in M mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll flip it like you suggest, and see if we like that better.

It was a bit confusing before. Hopefully now it's more clear how they
relate, and why you might want each one.
Copy link
Collaborator

@pdonahue-ventana pdonahue-ventana left a comment

Choose a reason for hiding this comment

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

I see another reason to have the field defined under mcontext. Previously, it was defined under hcontext which only exists if H is implemented but then the field itself said "If the H extension is implemented..." which was just confusing if you looked at this register in isolation. So this is much better.

@timsifive timsifive merged commit 4acc8ce into master Sep 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants