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

Conflicting exception types caused by misaligned AMO instructions. #1726

Open
jillleon007 opened this issue Nov 15, 2024 · 8 comments
Open

Comments

@jillleon007
Copy link

In 《riscv-privlieged》,3.6.4. Misaligned Atomicity Granule PMA,It said
“If a misaligned AMO accesses a region that does not specify a misaligned atomicity granule PMA, or if not all accessed bytes lie within the same misaligned atomicity granule, then an exception is raised. For regular loads and stores that access such a region or for which not all accessed bytes lie within the same atomicity granule, then either an exception is raised, or the access proceeds but is not guaranteed to be atomic. Implementations may raise access-fault exceptions instead of address-misaligned exceptions for some misaligned accesses, indicating the instruction should not be emulated by a trap handler.”

Notice that:"Implementations may raise access-fault exceptions instead of address-misaligned exceptions for some misaligned accesses, indicating the instruction should not be emulated by a trap handler."

Need raise an acess-fault exceptions instead of address-misaligned exceptions

But in 《riscv-unprivileged》 14.4. "Zaamo" Extension for Atomic Memory Operations
For AMOs, the Zaamo extension requires that the address held in rs1 be naturally aligned to the size of the operand (i.e., eight-byte aligned for doublewords and four-byte aligned for words). If the address is not naturally aligned, an address-misaligned exception or an access-fault exception will be generated. The access-fault exception can be generated for a memory access that would otherwise be able to complete except for the misalignment, if the misaligned access should not be emulated.

Now we have a problem, which type exception should be raised when the address is not naturally aligned?

@aswaterman
Copy link
Member

It seems clear to me: raise an access exception if the access shouldn't be emulated by M-mode software.

@jillleon007
Copy link
Author

It seems clear to me: raise an access exception if the access shouldn't be emulated by M-mode software.

which one misalign exception or access-fault exception is for unalign AMO? It isn't related to M mode

@allenjbaum
Copy link

allenjbaum commented Nov 16, 2024 via email

@jillleon007
Copy link
Author

It seems clear to me: raise an access exception if the access shouldn't be emulated by M-mode software.

How to understand the "emulated by M-mode software", Does it mean the expcetion would be handle by software run on M-mode?

@aswaterman
Copy link
Member

Yes.

@allenjbaum
Copy link

allenjbaum commented Nov 21, 2024 via email

@aswaterman
Copy link
Member

I was just answering a question about what we mean by "emulated by M-mode software". It is true that emulation by M-mode software is not the only possible outcome; misaligned accesses might result in visible traps in some environments.

@allenjbaum
Copy link

allenjbaum commented Nov 22, 2024 via email

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

No branches or pull requests

3 participants