systemc-components: add the SMMU V3 model#56
Conversation
ce7966d to
6622c44
Compare
| add_subdirectory(generic_lua_model) | ||
| add_subdirectory(container_builder) | ||
| add_subdirectory(smmu500) | ||
| add_subdirectory(smmuv3) |
There was a problem hiding this comment.
A general remark about naming. Arm-MMU 600 or 700 are the two Arm SMMUv3, targeting v3.1 and v3.2 respectively. It seems the current implement is more v3.1, since it does not have support for Secure stage 2 translations.
So probably naming it smmu600 makes sense.
There was a problem hiding this comment.
| read_dram(dest_pa, &readback, 4); | ||
| ASSERT_EQ(readback, 0xCAFEBABEu); | ||
| } | ||
|
|
There was a problem hiding this comment.
Maybe not required now, but would be useful to add S2 translations unit tests also, and S1 + S2 too, to mimic what a VM would do. In general, would be nice to have full coverage on SMMU code if we want to make this a "production ready" model.
Also, it would be nice to have expected_fail tests, with bad permissions or wrong translation table setup. It naturally comes with coverage approach mentioned in previous paragraph.
It can definitely grow over time, and it's not a blocker for this PR.
|
|
||
| ASSERT_EQ(mmio_read32(REG_CMDQ_CONS) & 0x1F, 1u); | ||
| } | ||
|
|
There was a problem hiding this comment.
Same remark about testing other commands.
|
|
||
| } // namespace gs | ||
|
|
||
| #endif // SMMUV3_H |
There was a problem hiding this comment.
Overall looks quite complete! It's pretty inspired from QEMU model (maybe that's what was suggested in the prompt?).
I would trust more coverage and unit tests than a manual review for most of the complex parts (stages, ptw, registers configuration, etc)
There was a problem hiding this comment.
Thank you very much Pierrick, more test cases were added, and I added support for TBU DMI and DMI INV and test benches for them, please check again.
9b6857a to
7ae2574
Compare
androm3da
left a comment
There was a problem hiding this comment.
Mostly nits here and there, I don't have any significant objections. LGTM
|
|
||
| if (level == 3) break; // Must be page descriptor | ||
|
|
||
| switch (type) { |
There was a problem hiding this comment.
Please add a default handler (maybe unreachable?)
| case NORMAL_WB: | ||
| oss << "Normal-WB"; | ||
| break; | ||
| } |
| class smmuv3_memory_attrs_extension : public tlm::tlm_extension<smmuv3_memory_attrs_extension> | ||
| { | ||
| public: | ||
| enum MemoryType { |
There was a problem hiding this comment.
enum class would restrict the type and scope more strongly, consider whether it could be used here.
There was a problem hiding this comment.
should be adjusted now!
p-b-o
left a comment
There was a problem hiding this comment.
It looks pretty good, and I think it's more than enough for a first version. If you don't have time, feel free to skip the coverage part.
| ASSERT_EQ(par_lo & ~0xFFFu, static_cast<uint32_t>(page_pa) & ~0xFFFu); | ||
| } | ||
|
|
||
| TEST_BENCH(smmuv3_bench, TwoLevelStreamTable_S1_4KPage) |
There was a problem hiding this comment.
While this test is useful, maybe the intent was to add a two stages translation test, exercising S1 + S2. I didn't find this configuration in all the new tests added.
There was a problem hiding this comment.
It should be added now, with other tests to increase coverage, and still adding more, also there is no any meaningful logging used, I am on the process of adding SCP_* log messages in the important locations.
| ASSERT_EQ(dmi_inv_observer.ranges.size(), 0u); | ||
| } | ||
|
|
||
| int sc_main(int argc, char** argv) |
There was a problem hiding this comment.
That's definitely a lot of new tests! Hard to say what might be missing from the full patchset, but running the test with a gcov build and see coverage might hint on which situations are not covered yet.
There was a problem hiding this comment.
still working on increasing it more, now it shows 89.31 % line coverage and 92.11 % for functions but still the branch is low: 73.76 %
There was a problem hiding this comment.
Great. Leaving a few branch combinations behind is not too much a problem (out of s1 + s2 which is important).
|
I'm not sure what is going on with the CI, but it seems like smmuv3 tests are segfaulting with gcc (undefined behavior resulting in a wrong optimization?). Definitely worth taking a look before merging it. |
c9c391c to
d89f84e
Compare
- Add smmuv3 model under systemc-components. - Add a test bench at tests/components/smmuv3. Signed-off-by: Mahmoud Kamel <mkamel@qti.qualcomm.com>
Uh oh!
There was an error while loading. Please reload this page.