Anthony Cole created a merge request: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1595

Project:Branches: Tony/rtems:upstream-riscv-fence-i to rtems/rtos/rtems:main
Author: Anthony Cole

## Summary

bsps/riscv: Synchronize the instruction cache with fence.i

The riscv/riscv BSPs built nocache.c, so the instruction cache functions
did nothing and rtems_cache_get_instruction_line_size() returned 0.
RISC-V doesn't keep the instruction fetch coherent with stores: code
written as data may only be executed after a FENCE.I on the hart which
executes it, and nothing executed one.  libdl skips its cache
synchronization when the instruction line size is 0, so code loaded with
dlopen() could run stale.  On a RISC-V core whose instruction fetch
doesn't see stores still in the data cache, the dl01, dl11 and dl12
tests took illegal instruction exceptions in the loaded code.

Add bsps/riscv/shared/cache/cache.c, used by the riscv/riscv BSPs instead
of nocache.c.  The instruction cache invalidations execute FENCE.I, on
every processor in SMP configurations
(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING), so
rtems_cache_instruction_sync_after_code_change() does too.  Since GCC 12
the assembler accepts FENCE.I only with Zifencei in the -march option,
which the BSP options don't name, so it is enabled around the
instruction.  There is no data cache support: there is no standard way
to maintain it, and FENCE.I doesn't need it.

Close #5826

Assisted-by: Claude:claude-opus-5-5 claude-code
Signed-off-by: Anthony Cole <[email protected]>


## Generative AI

<!-- If you have used AI please use the "AI Contribution" template otherwise 
leave this blank see our fulls statement at 
https://www.rtems.org/generative-ai/-->


<!-- Default settings, if it is a dropdown it will set after submission -->

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1595
You're receiving this email because of your account on gitlab.rtems.org. 
Unsubscribe from this thread: 
https://gitlab.rtems.org/-/namespace/49/sent_notifications/6-9y7rw07ddp94udz226s2dahox-1d/unsubscribe
 | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | 
Help: https://gitlab.rtems.org/help


_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to