Open
Conversation
portPOINTER_SIZE_TYPE is used in FreeRTOS to store both pointer and integer values. Using a plain integer type for this purpose is unsafe on architectures that distinguish between pointers and integers, where an integer type (e.g. uint64_t) may not be able to represent all pointer values. The standard intptr_t type is explicitly defined to safely hold either a pointer or an integer. This commit changes portPOINTER_SIZE_TYPE to intptr_t, similar to the existing POSIX port, improving portability of the RISC-V port. Similarly, portSTACK_TYPE is used to store word-sized values on the stack that may represent either integers or pointers, and is often cast to pointer types. Changing it to uintptr_t makes this usage explicit and correct, improving portability, intent, and safety for capability-based extensions such as CHERI-RISC-V. Signed-off-by: Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk>
xTaskReturnAddress holds a [function] pointer, never an integer address. Use a proper exclusive function pointer type for this variable. Furthermore, use NULL instead of 0 for an invalid function pointer value This typedef could be made more generic for FreeRTOS-Kernel and not just for RISC-V; vApplicationTaskExit used to be declared/defined in previous versions and ideally could just be brought back. Signed-off-by: Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk>
Add a new configMTIME_INIT_IN_BSP configuration macro to allow BSPs and demo applications to initialise the MMIO MTIME pointers within the CLINT. This enables BSPs to provide custom addresses or properly typed pointer values, rather than relying on plain integer constants coming from macros as is currently the case. This change does not affect existing assumptions and usage, but allows architectures that differentiate between integers and pointers to work. Signed-off-by: Hesham Almatary <Hesham.Almatary@cl.cam.ac.uk>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



RISC-V port enhancements
Description
Non-breaking, backward-compatible enhancements to the RISC-V port mostly to do with types in order to make it more portable across architectures (eg: CHERI extensions that enforce memory safety and pointer provenance by separating pointer vs integer types) and environments (eg: POSIX).
Test Steps
Normal RISC-V demos should work, tested with
main_blinky.Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.