On Tue, Apr 4, 2023 at 4:34 PM Rich Felker <dalias@libc.org> wrote:
On Tue, Apr 04, 2023 at 03:49:05PM -0700, enh wrote:
> i'm still trying to decide whether it makes sense to
> add __riscv_flush_icache() to bionic or not[1] and was looking to see
> whether musl had added it. i notice you've _implemented_ it but not added
> it to the <sys/cacheflush.h> header. was that deliberate or just an
> oversight?
>
> _____
> 1. see https://github.com/google/android-riscv64/issues/4 for my ramblings
> on that topic.

It's rather annoying that they added a new arch-specific header for
this rather than using the existing <sys/cachectl.h> ...

i don't think this is a new thing --- i think they've always had <sys/cachectl.h> only on systems like mips that actually need it, and it's different between those systems. (my x86-64 glibc box has no <sys/cachectl.h>, for example.)
 
We probably need to do something to clean this up but I'm not sure
what the right action is. I figured it was usable with no header, but
apparently it needs some flags ..?

https://www.gnu.org/software/libc/manual/html_node/RISC_002dV.html refers to a single flag ... but i don't think they actually _define_ that flag?

ah, it's in the kernel:
```
~/linux$ grep -r SYS_RISCV_FLUSH_ICACHE_LOCAL
arch/riscv/include/asm/cacheflush.h:#define SYS_RISCV_FLUSH_ICACHE_LOCAL 1UL
arch/riscv/include/asm/cacheflush.h:#define SYS_RISCV_FLUSH_ICACHE_ALL   (SYS_RISCV_FLUSH_ICACHE_LOCAL)
arch/riscv/kernel/sys_riscv.c: flush_icache_mm(current->mm, flags & SYS_RISCV_FLUSH_ICACHE_LOCAL);
~/linux$
 ```
but not in a uapi header :-/
 
Rich