-
Notifications
You must be signed in to change notification settings - Fork 293
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
remoteproc: fix management of non loadable segments #553
Conversation
f2f9364
to
f712747
Compare
Can we take an exception to the |
The elf_loader.c was upstreamed before we put in place the checkpatch. That's why you can see some old stlyles occurrences. |
f712747
to
4de3aae
Compare
@arnopo I have resolved the warning. Please resume your review. |
Could you provide some debug trace of your issue, that we understand what you mean by "This creates an error condition and the firmware loading fails" ? |
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.
Code changes might not be needed. Comments to clear up any misunderstanding on my part are welcome.
4de3aae
to
3a89ad0
Compare
@edmooring I believe I answered your concern in the other comment thread. I am re-requesting review. Feel free to leave further comments if you have more questions. |
Yeah, you got it right @arnopo , it does land at the mentioned location. Technically, it shouldn't have landed here because it was already past the last LOAD segment in the previous iteration. This time now, it returns back from https://github.com/OpenAMP/open-amp/blob/main/lib/remoteproc/elf_loader.c#L578 with a valid As the I am putting the trace log for further information:
With the changes under review here, the loading is successful:
|
Thanks @UmairKhanUET for the details and trace. Regarding your commit, I wonder if we could not simplify this by refactoring the existing code instead of adding elf_max_load_phnum() nsegment = *load_state & ELF_NEXT_SEGMENT_MASK;
phdr = elf_next_load_segment(*img_info, &nsegment, da,
noffset, &nsize, &nsegmsize);
phnums = elf_phnum(*img_info);
if (phdr) {
*nlen = nsize;
*nmemsize = nsegmsize;
metal_log(METAL_LOG_DEBUG, "segment: %d, total segs %d\r\n", nsegment, phnums);
}
if (nsegment == phnums) {
if (phdr) {
*load_state = (*load_state & (~RPROC_LOADER_MASK)) |
RPROC_LOADER_POST_DATA_LOAD;
} else {
metal_log(METAL_LOG_DEBUG, "no more segment to load\r\n");
*load_state = (*load_state & (~RPROC_LOADER_MASK)) |
RPROC_LOADER_LOAD_COMPLETE;
*da = RPROC_LOAD_ANYADDR;
} Unfortunately I have no hardware to test the loader. Could you test it ( with probably few fixes) on your side and give me a feedback? |
Thanks @arnopo for the feedback. I will try this out and post the results here. |
3a89ad0
to
a7e99b2
Compare
Hi @arnopo , |
a7e99b2
to
46efa25
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.
Looks good to go.
@UmairKhanUET |
@arnopo Done |
unclear, I was speaking about the commit subject :-) |
The elf loader assumes that the last ELF program segment will always be a LOAD type segment. I deduce this from the fact that the elf_load() function, when loading the remote ELF sections during the RPROC_LOADER_READY_TO_LOAD stage, compares the last load segment num to the total ELF sections to determine if the loading is complete and it can move to the next stage RPROC_LOADER_POST_DATA_LOAD. If the last program segment in the ELF is not of type LOAD, the last loaded LOAD segment never equals total ELF sections. This creates an error condition and the firmware loading fails. This patch fixes this issue by comparing the last loaded LOAD segment number with the max LOAD segment number in the ELF. Signed-off-by: Umair Khan <[email protected]>
46efa25
to
7e76eb0
Compare
@arnopo I hope I did it right this time :D |
The elf loader assumes that the last ELF program segment will always be a LOAD type segment. I deduce this from the fact that the elf_load() function, when loading the remote ELF sections during the RPROC_LOADER_READY_TO_LOAD stage, compares the last load segment num to the total ELF sections to determine if the loading is complete and it can move to the next stage RPROC_LOADER_POST_DATA_LOAD. If the last program segment in the ELF is not of type LOAD, the last loaded LOAD segment never equals total ELF sections. This creates an error condition and the firmware loading fails. This patch fixes this issue by comparing the last loaded LOAD segment number with the max LOAD segment number in the ELF.
This PR fixes #552
Signed-off-by: Muhammad Umair Khan [email protected]