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

llext: disable for Harvard ARC variants #82491

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

tagunil
Copy link
Collaborator

@tagunil tagunil commented Dec 3, 2024

Some ARC processor configurations have separate memory for code (ICCM) and for data (DCCM). Such configurations are unsuitable for LLEXT, except for some quite special cases. For now, disable LLEXT and its tests for these devices completely.

@zephyrbot zephyrbot added the area: llext Linkable Loadable Extensions label Dec 3, 2024
@zephyrbot zephyrbot requested review from lyakh, pillo79 and teburd December 3, 2024 14:10
@tagunil tagunil added the area: ARC ARC Architecture label Dec 3, 2024
@tagunil
Copy link
Collaborator Author

tagunil commented Dec 3, 2024

@laurenmurphyx64, I don't know which ARC cores you're interested in for LLEXT, so I'd like to have your input on that, as you are the person who enabled LLEXT for ARC in the first place.

pillo79
pillo79 previously approved these changes Dec 3, 2024
Copy link
Collaborator

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, did not know about that symbol, it definitely is a good filter.

Not a blocker but maybe the LLEXT docs should mention that as well? Something along the lines of "Harvard architectures, that separate code and data paths, are not supported" would be enough IMO.

@ruuddw
Copy link
Member

ruuddw commented Dec 3, 2024

"Such configurations are unsuitable for LLEXT"
That's a limitation of current LLEXT, not a fundamental issue right? What's required to handle separate code and data segments? Just a LLEXT loader update, or are there other problems with Harvard architectures?

Some ARC processor configurations have separate memory for code (ICCM)
and for data (DCCM). Such configurations are unsuitable for LLEXT,
except for some quite special cases. For now, disable LLEXT and its
tests for these devices completely.

Signed-off-by: Ilya Tagunov <[email protected]>
@tagunil
Copy link
Collaborator Author

tagunil commented Dec 3, 2024

Not a blocker but maybe the LLEXT docs should mention that as well? Something along the lines of "Harvard architectures, that separate code and data paths, are not supported" would be enough IMO.

Sure, I've just added the line to the docs in the updated commit.

@tagunil tagunil requested a review from pillo79 December 3, 2024 14:43
@tagunil
Copy link
Collaborator Author

tagunil commented Dec 3, 2024

"Such configurations are unsuitable for LLEXT"
That's a limitation of current LLEXT, not a fundamental issue right? What's required to handle separate code and data segments? Just a LLEXT loader update, or are there other problems with Harvard architectures?

Well, the whole idea of LLEXT, as I see it, is to be able to load some executable code into data memory and execute it from there. So if our processor has no common memory, but only ICCM and DCCM, where should we load the code? DCCM is not an option, because the processor cannot execute from there, right? ICCM might be an option, if it's writable by the processor and if we could convince the linker to put all the buffers there, but does it make sense?

@ruuddw
Copy link
Member

ruuddw commented Dec 3, 2024

Execution from DCCM is blocked indeed (good for security as well). But ICCM supports both code and data (with some performance penalty, as instruction fetches and load/store instructions use the same port instead of independent ports). And a loader could also load the code part into ICCM and the data part in DCCM.

@tagunil
Copy link
Collaborator Author

tagunil commented Dec 3, 2024

Execution from DCCM is blocked indeed (good for security as well). But ICCM supports both code and data (with some performance penalty, as instruction fetches and load/store instructions use the same port instead of independent ports). And a loader could also load the code part into ICCM and the data part in DCCM.

I think the first option could be implemented if we hack our linker script to place the LLEXT heap into ICCM and rework the LLEXT_STORAGE_WRITABLE option into something like LLEXT_STORAGE_WRITABLE_EXECUTABLE. But the question is if it's worth the effort right now. Do we have any practical use case for LLEXT on these hardware configurations?

@laurenmurphyx64
Copy link
Contributor

@laurenmurphyx64, I don't know which ARC cores you're interested in for LLEXT, so I'd like to have your input on that, as you are the person who enabled LLEXT for ARC in the first place.

But the question is if it's worth the effort right now. Do we have any practical use case for LLEXT on these hardware configurations?

@tagunil The best person for me to ask about what cores / configurations we're considering using is @teburd, but he's out of town for the next two weeks... I don't have any objections to this PR as it is, though, so I'll approve it.

@lyakh
Copy link
Collaborator

lyakh commented Dec 4, 2024

Execution from DCCM is blocked indeed (good for security as well). But ICCM supports both code and data (with some performance penalty, as instruction fetches and load/store instructions use the same port instead of independent ports). And a loader could also load the code part into ICCM and the data part in DCCM.

@ruuddw FWIW we do move different ELF sections to different memory regions / types in SOF application code, but with the current LLEXT API it isn't very convenient. It should improve if @teburd 's idea of separate load and link steps gets implemented

@ruuddw
Copy link
Member

ruuddw commented Dec 4, 2024

Thanks @lyakh for confirming that there is no fundamental issue with supporting ARC Harvard-style targets, just implementation work. I'm not aware of an urgent need for this support, we can wait for the simpler support of multiple regions. Maybe an ARC target can be used for testing that?

Comment on lines +25 to +26
Harvard architecture cores that separate code and data paths and have no
common memory are not supported.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: for ARC with HARVARD (which in most of the cases means ICCM + DCCM usage) it's really easy to overcome this by loading to ICCM directly. moreover CCMs are uncached (cause they are already fast enough) - so we won't even need to have caches sync.

Copy link
Collaborator Author

@tagunil tagunil Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but neither LLEXT nor our linker scripts are exactly ready for that at the moment. Besides, it could be quite wasteful to load the whole ELF into ICCM (LLEXT_STORAGE_WRITABLE=y case) or to place the whole LLEXT heap into ICCM (LLEXT_STORAGE_WRITABLE=n case). Do our real-world Harvard configurations have enough ICCM to make it practical? If they do, we may prioritize such work to make it happen.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess ideally we would need split heaps for this sort of architecture am I understanding this right? There's other reasons to consider this as well, like avoiding needing all of user mode for memory permission bits.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess ideally we would need split heaps for this sort of architecture am I understanding this right? There's other reasons to consider this as well, like avoiding needing all of user mode for memory permission bits.

Yes, I think we should at least consider splitting the heap into executable and non-executable parts.

@kartben kartben merged commit ce50ea2 into zephyrproject-rtos:main Dec 16, 2024
24 checks passed
@tagunil tagunil deleted the harvard-disable-llext branch December 16, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ARC ARC Architecture area: llext Linkable Loadable Extensions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants