feat(trap): support atomic instructions emulation #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since HPM6360 does not support execute atomic load/store with SDRAM address range, we need to emulate atomic instructions execute in trap handler then the Linux kernel can runs without any modifications and user space thread also is supported.
For AMO instructions, they will trap into Store/AMO access fault exception during execution, so we can emulate it in store fault exception handler.
For
lr/sc
instructions,lr
will trap into Load access fault during execution butsc
won't, however. So we need to replacesc
into an illegal instruction which I usecsrrw zero, time, zero
here, then it will trap into Illegal instruction exception and will be replaced back during exception handling. After replacing instructions we have to executefence.i
to make sure this data store is visible to the subsequent instruction fetch.