riscv-non-isa / riscv-iommu

RISC-V IOMMU Specification
https://jira.riscv.org/browse/RVG-55
Creative Commons Attribution 4.0 International
71 stars 14 forks source link

Why this code in the line return 1 rather than -1, is this a slip? #270

Closed baimengwei closed 7 months ago

baimengwei commented 7 months ago

https://github.com/riscv-non-isa/riscv-iommu/blob/42c778f6240618d2931d9aff20e8512f97413399/iommu_ref_model/libtables/src/translate_gpa.c#L57C40-L57C40

        if ( nl_gpte.V == 0 ) return 1;

uint64_t translate_gpa (iohgatp_t iohgatp, uint64_t gpa, uint64_t *spa) This function is used to translate a gpa to a spa. The function also returns the G-stage pte that provides the translation

However, when the gpte is not invalid, this function will return address 1 as a gpte address, which seems confusing? For me, this function seems to return the error code if the address is negative?

ved-rivos commented 7 months ago

Thanks for spotting that. It should have returned -1. Fixed in PR #271