Skip to content
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

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

Closed
baimengwei opened this issue Nov 10, 2023 · 1 comment
Closed

Comments

@baimengwei
Copy link

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants