[RFC] cacheflush.2: Document different prototypes for different architectures

Alejandro Colomar (man-pages) alx.manpages at gmail.com
Sat Dec 12 13:19:23 EST 2020


Hi Heinrich,

Good.
BTW, it looks like internally LLVM uses 'void *'[1],
but Clang exposes 'char *'[2] in the prototype.  Weird...
I reported the bug yesterday: https://bugs.llvm.org/show_bug.cgi?id=48489

Thanks,

Alex

[1]:
https://github.com/llvm/llvm-project/blob/414d3dc62c706f41226b0d552210c79f5080df43/compiler-rt/lib/builtins/clear_cache.c#L59
[2]:
https://github.com/llvm/llvm-project/blob/7faf62a80bfc3a9dfe34133681fcc31f8e8d658b/clang/include/clang/Basic/Builtins.def#L583

On 12/12/20 12:52 AM, Heinrich Schuchardt wrote:
> On 12/11/20 10:09 PM, Alejandro Colomar (man-pages) wrote:
>> Hi Michael,
>>
>> Continuing with the changes in this thread:
>> https://lore.kernel.org/linux-man/747d56e0-c102-ab40-add4-530a48a43a4d@gmx.de/T/#t
>>
>>
>> I researched the architectures that have this syscall.  I found some
>> that clearly provide the syscall, and some that seem to have something,
>> but I didn't find a definition in the kernel (i.e., ARM, MicroBlaze
>> (glibc only)?)
> 
> arch/arm/include/uapi/asm/unistd.h:35:
> #define __ARM_NR_cacheflush               (__ARM_NR_BASE+2)
> 
> arch/arm64/include/asm/unistd.h:37:
> #define __ARM_NR_compat_cacheflush   (__ARM_NR_COMPAT_BASE + 2)
> 
> These syscalls are marked as private. So you should not use them from
> user space.
> 
> The compilers seem not to care about these syscalls being private:
> 
> https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/arm/lib1funcs.S#L1512
> 
> https://github.com/llvm-mirror/compiler-rt/blob/master/lib/builtins/clear_cache.c
> 
> 
> Best regards
> 
> Heinrich
[...]
>> Rendered page (NOTES only):
>>
>> [
>> NOTES
>>     Architecture-specific variants
>>         Glibc  provides a wrapper for this system call, with the pro‐
>>         totype shown in SYNOPSIS, for  the  following  architectures:
>>         ARC, CSKY, MIPS, and NIOS2. // lowercase?
>>
>>         On  some other architectures, Linux provides this system call
>>         with different arguments:
>>
>>         M68K:
>>
>>             int cacheflush(unsigned long addr, int scope, int cache,
>>                            unsigned long len);
>>
>>         SH:
>>
>>             int cacheflush(unsigned long addr, unsigned long len, int
>> op);
>>
>>         NDS32:
>>
>>             int cacheflush(unsigned int start, unsigned int end, int
>> cache);
>>
>>     GCC alternative
>>         Unless you need the finer grained control  that  this  system
>>         call  provides,  you  probably  want  to use the GCC built-in
>>         function __builtin___clear_cache(), which provides a portable
>>         interface  across  platforms  supported by GCC and compatible
>>         compilers:
>>
>>             void __builtin___clear_cache(void *begin, void *end);
>>
>>         On platforms that don't require  instruction  cache  flushes,
>>         __builtin___clear_cache() has no effect.
>>
>>         Note:  On  some  GCC-compatible compilers, such as clang, the
>>         prototype for this function uses char * instead of void * for
>>         the parameters.
>>
>> ]
>>
>> 'GCC alternative' is the name I gave to the NOTES from the other thread,
>> which aren't yet merged (I'll send the patches after the weekend,
>> probably).
>>
>> Subsections based on:
>> fadvise64(2)
>>
>> Can you review this?
>>
>> Thanks,
>>
>> Alex
>>
> 



More information about the linux-snps-arc mailing list