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 loadmem bug in firesim_tsi.cc #1401
Conversation
6bca50d
to
bc67e5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have an impact on performance?
No. This only affects initial binary loading, and only for the tail case - the last 8 bytes in a section in a ELF. Even so it doesn't actually change the number of host-DRAM requests - it only aligns the chunked requests properly. |
We've had other issues with handling the last bytes of loadmem in the past. In lieu of actually testing the infrastructure better, could we check in a few binaries that have elf sizes that trigger this problem? |
I think the right way to do this is to add some self-test in One of the test vectors should check this case. It is sufficient to check that:
behaves correctly. |
That's a great idea so long as you pull in the address somewhere sane. Could you do that here? |
bc67e5f
to
6b45c10
Compare
It turns out this is actually not so easy to do safely. The problem is:
So the only way to add a FESVR-side self-test of the loadmem interface is to add assumptions on the relationship between the FESVR-accessible memory map and the LoadMem widget. I don't think this should be done. I think there are more pressing issues with the current setup. I believe an ELF file with sections mapped to invalid memory regions can cause a bus hang, or even worse, generate writes to host DRAM regions allocated to unrelated bridges without any indication. This ought to be fixed by moving the loadmem widget behind the AXI4 Xbar in FPGATop (instead of in front of it). In any case, I'd like this PR to get merged soon, as its blocking a chisel/rc/scala bump. I've improved this fix to pull hKey.dataBits from the generated header, instead of hardcoding it. Fixing the loadmem setup to be more robust should be a longer-term goal. |
Nvm, my better fix is no longer applicable now that the driver has been split apart more. Hardcoding chunk_align to 8 is the best temporary solution, but the longer term goal IMO should be to more tightly couple the loadmem path to fesvr. |
chunk_align has to match the loadmem-DRAM interface width Hardcode this for now
6b45c10
to
64ea141
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. You should also make an issue so we can track this there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see the small comment change so this is more trackable, otherwise ship it
Co-authored-by: David Biancolin <david.biancolin@sifive.com>
The default chunk_align (32b) was less than the default host-DRAM interface (64b), which caused drops on some loadmem_writes. Fix this for now by setting chunk_align to 8.
This error would manifest only when the address written had
(addr + len) % 8 == {5|6|7}
.For example, writing 0x6 bytes to 0x100 would result in a sequence of writes:
The second write would generate a 8-byte write to 0x100, clobbering the first write.
Related PRs / Issues
UI / API Impact
None
Verilog / AGFI Compatibility
Contributor Checklist
changelog:<topic>
label?ci:fpga-deploy
label?Please Backport
label?Reviewer Checklist (only modified by reviewer)
Note: to run CI on PRs from forks, comment
@Mergifyio copy main
and manage the change from the new PR.changelog:<topic>
label?