This repository has been archived by the owner on Apr 13, 2019. It is now read-only.
RISC-V - atomic_read breaks RV64 build on i386 #106
Closed
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.
@sorear This patch fixes qemu-system-riscv64 on i386 (32-bit). See compile error below.
The code is theoretically racy (see two 32-bit atomic operations on 32-bit hosts), but given the significant
mip
interrupt bits are in the lower 32-bits of the word, it's only a theoretical issue, as reads and writes of the lower 32-bits ofmip
will be atomic, as are normal aligned loads and stores, at least on i386 (misaligned loads and stores spanning cache lines however are not, but luckily structure alignment rules prevent this from happening except in contrived examples). i.e. it is still practically atomic after this change. This wouldn't be the case if more than 32-bits were used (where we'd see tears on 32-bit boundaries), however, all currently used interrupt bits are in the low 12-bits of the word so there is no impact. If we had >32 interrupt bits, then we can worry about adding locking.Boot tested riscv64 linux: