* [RFC] cacheflush.2: Document different prototypes for different architectures
@ 2020-12-11 21:09 Alejandro Colomar (man-pages)
2020-12-11 23:52 ` Heinrich Schuchardt
0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-11 21:09 UTC (permalink / raw)
To: Michael Kerrisk (man-pages), linux-man
Cc: Dave Martin, Heinrich Schuchardt, Vineet Gupta, linux-snps-arc,
Guo Ren, linux-csky, Thomas Bogendoerfer, linux-mips, Nick Hu,
Greentime Hu, Vincent Chen, libc-alpha
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)?)
Research:
$ grep -rn cacheflush glibc/
glibc/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist:324:GLIBC_2.0
cacheflush F
glibc/sysdeps/unix/sysv/linux/m68k/Versions:13: cacheflush;
glibc/sysdeps/unix/sysv/linux/m68k/arch-syscall.h:17:#define
__NR_cacheflush 123
glibc/sysdeps/unix/sysv/linux/m68k/syscalls.list:18:cacheflush EXTRA
cacheflush i:iiii __cacheflush cacheflush
glibc/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist:744:GLIBC_2.4
cacheflush F
glibc/sysdeps/unix/sysv/linux/arc/Versions:10: cacheflush;
glibc/sysdeps/unix/sysv/linux/arc/sys/cachectl.h:1:/* cacheflush - flush
contents of instruction and/or data cache.
glibc/sysdeps/unix/sysv/linux/arc/sys/cachectl.h:30:extern int
cacheflush (void *__addr, int __nbytes, int __op) __THROW;
glibc/sysdeps/unix/sysv/linux/arc/arch-syscall.h:13:#define
__NR_cacheflush 244
glibc/sysdeps/unix/sysv/linux/arc/syscalls.list:3:cacheflush -
cacheflush i:pii _flush_cache cacheflush
glibc/sysdeps/unix/sysv/linux/arc/Makefile:10:# MIPS/Tile-style
cacheflush routine
glibc/sysdeps/unix/sysv/linux/arc/Makefile:12:sysdep_routines += cacheflush
glibc/sysdeps/unix/sysv/linux/arc/libc.abilist:574:GLIBC_2.32 cacheflush F
glibc/sysdeps/unix/sysv/linux/csky/Versions:3: cacheflush;
glibc/sysdeps/unix/sysv/linux/csky/sys/cachectl.h:30:extern int
cacheflush (void *__addr, const int __nbytes,
glibc/sysdeps/unix/sysv/linux/csky/arch-syscall.h:10:#define
__NR_cacheflush 245
glibc/sysdeps/unix/sysv/linux/csky/syscalls.list:2:cacheflush -
cacheflush i:pii _flush_cache cacheflush
glibc/sysdeps/unix/sysv/linux/csky/Makefile:2:sysdep_routines += cacheflush
glibc/sysdeps/unix/sysv/linux/csky/libc.abilist:594:GLIBC_2.29 cacheflush F
glibc/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist:322:GLIBC_2.0
cacheflush F
glibc/sysdeps/unix/sysv/linux/mips/mips32/arch-syscall.h:19:#define
__NR_cacheflush 4147
glibc/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:322:GLIBC_2.0
cacheflush F
glibc/sysdeps/unix/sysv/linux/mips/Versions:19: cachectl; cacheflush;
glibc/sysdeps/unix/sysv/linux/mips/sys/cachectl.h:35:extern int
cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/arch-syscall.h:16:#define
__NR_cacheflush 5197
glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist:320:GLIBC_2.0
cacheflush F
glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/arch-syscall.h:16:#define
__NR_cacheflush 6197
glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist:322:GLIBC_2.0
cacheflush F
glibc/sysdeps/unix/sysv/linux/mips/syscalls.list:8:cacheflush -
cacheflush i:pii _flush_cache cacheflush
glibc/sysdeps/unix/sysv/linux/mips/Makefile:6:sysdep_routines +=
cachectl cacheflush sysmips _test_and_set
glibc/sysdeps/unix/sysv/linux/sh/arch-syscall.h:16:#define
__NR_cacheflush 123
glibc/sysdeps/unix/sysv/linux/nios2/Versions:4: cacheflush;
glibc/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h:1:/* cacheflush -
flush contents of instruction and/or data cache.
glibc/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h:27:extern int
cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
glibc/sysdeps/unix/sysv/linux/nios2/arch-syscall.h:10:#define
__NR_cacheflush 244
glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:1:/* cacheflush system
call for Nios II Linux.
glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:27: return
INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:29:weak_alias
(_flush_cache, cacheflush)
glibc/sysdeps/unix/sysv/linux/nios2/Makefile:6:# MIPS-style cacheflush
routine
glibc/sysdeps/unix/sysv/linux/nios2/Makefile:8:sysdep_routines += cacheflush
glibc/sysdeps/unix/sysv/linux/nios2/libc.abilist:663:GLIBC_2.21 cacheflush F
glibc/sysdeps/unix/sysv/linux/arm/dl-machine.h:23:
INTERNAL_SYSCALL_CALL (cacheflush, (BEG), (END), 0)
glibc/sysdeps/unix/sysv/linux/arm/arch-syscall.h:17:#define
__NR_cacheflush 983042
glibc/sysdeps/unix/sysv/linux/arm/fixup-asm-unistd.h:19:#ifndef
__NR_cacheflush
glibc/sysdeps/unix/sysv/linux/arm/fixup-asm-unistd.h:20:# define
__NR_cacheflush __ARM_NR_cacheflush
glibc/sysdeps/unix/sysv/linux/microblaze/syscalls.list:3:cacheflush
EXTRA cacheflush i:iiii __cacheflush cacheflush
glibc/sysdeps/unix/sysv/linux/syscall-names.list:60:cacheflush
glibc/benchtests/strcoll-inputs/filelist#en_US.UTF-8:1417:cacheflush.c
glibc/benchtests/strcoll-inputs/filelist#en_US.UTF-8:1744:cacheflush.c
glibc/ChangeLog.old/ChangeLog.7:7489: * sysdeps/mach/mips/cacheflush.c:
Likewise.
glibc/ChangeLog.old/ChangeLog.7:9422: *
sysdeps/unix/sysv/linux/m68k/syscalls.list: Add cacheflush.
glibc/ChangeLog.old/ChangeLog.4:205: * sysdeps/mach/mips/cacheflush.c:
New file.
glibc/ChangeLog.old/ChangeLog.18:40858: *
sysdeps/unix/sysv/linux/nios2/cacheflush.c: New file.
glibc/ChangeLog.old/ChangeLog.ports-tile:700: *
sysdeps/unix/sysv/linux/tile/cacheflush.c: New file.
grep: glibc/.git/index: binary file matches
$ grep -rn -e 'sys_cacheflush' -e 'SYSCALL_DEFINE.(cacheflush,' linux/ |
grep -v -e '/arc/' -e '/csky/' -e '/mips/' -e '/nios2/'
tools/testing/selftests/futex/functional/usr/include/linux/capability.h:251:/*
Allow flushing all cache on m68k (sys_cacheflush) */
include/uapi/linux/capability.h:253:/* Allow flushing all cache on m68k
(sys_cacheflush) */
arch/m68k/kernel/sys_m68k.c:376:/* sys_cacheflush -- flush (part of) the
processor cache. */
arch/m68k/kernel/sys_m68k.c:378:sys_cacheflush (unsigned long addr, int
scope, int cache, unsigned long len)
arch/m68k/kernel/sys_m68k.c:531:/* sys_cacheflush -- flush (part of) the
processor cache. */
arch/m68k/kernel/sys_m68k.c:533:sys_cacheflush (unsigned long addr, int
scope, int cache, unsigned long len)
arch/m68k/kernel/syscalls/syscall.tbl:133:123 common cacheflush
sys_cacheflush
arch/sh/kernel/sys_sh.c:57:/* sys_cacheflush -- flush (part of) the
processor cache. */
arch/sh/kernel/sys_sh.c:58:asmlinkage int sys_cacheflush(unsigned long
addr, unsigned long len, int op)
arch/sh/kernel/syscalls/syscall.tbl:133:123 common cacheflush
sys_cacheflush
arch/arm/include/asm/cacheflush.h:263: * This is used for the ARM
private sys_cacheflush system call.
arch/nds32/include/uapi/asm/unistd.h:15:__SYSCALL(__NR_cacheflush,
sys_cacheflush)
arch/nds32/include/asm/syscalls.h:7:asmlinkage long
sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op);
arch/nds32/kernel/sys_nds32.c:29:SYSCALL_DEFINE3(cacheflush, unsigned
int, start, unsigned int, end, int, cache)
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);
// ARM??
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
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] cacheflush.2: Document different prototypes for different architectures
2020-12-11 21:09 [RFC] cacheflush.2: Document different prototypes for different architectures Alejandro Colomar (man-pages)
@ 2020-12-11 23:52 ` Heinrich Schuchardt
2020-12-12 18:19 ` Alejandro Colomar (man-pages)
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2020-12-11 23:52 UTC (permalink / raw)
To: Alejandro Colomar (man-pages), Michael Kerrisk (man-pages), linux-man
Cc: Dave Martin, Vineet Gupta, linux-snps-arc, Guo Ren, linux-csky,
Thomas Bogendoerfer, linux-mips, Nick Hu, Greentime Hu,
Vincent Chen, libc-alpha
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
>
> Research:
>
> $ grep -rn cacheflush glibc/
> glibc/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist:324:GLIBC_2.0
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/m68k/Versions:13: cacheflush;
> glibc/sysdeps/unix/sysv/linux/m68k/arch-syscall.h:17:#define
> __NR_cacheflush 123
> glibc/sysdeps/unix/sysv/linux/m68k/syscalls.list:18:cacheflush EXTRA
> cacheflush i:iiii __cacheflush cacheflush
> glibc/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist:744:GLIBC_2.4
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/arc/Versions:10: cacheflush;
> glibc/sysdeps/unix/sysv/linux/arc/sys/cachectl.h:1:/* cacheflush - flush
> contents of instruction and/or data cache.
> glibc/sysdeps/unix/sysv/linux/arc/sys/cachectl.h:30:extern int
> cacheflush (void *__addr, int __nbytes, int __op) __THROW;
> glibc/sysdeps/unix/sysv/linux/arc/arch-syscall.h:13:#define
> __NR_cacheflush 244
> glibc/sysdeps/unix/sysv/linux/arc/syscalls.list:3:cacheflush -
> cacheflush i:pii _flush_cache cacheflush
> glibc/sysdeps/unix/sysv/linux/arc/Makefile:10:# MIPS/Tile-style
> cacheflush routine
> glibc/sysdeps/unix/sysv/linux/arc/Makefile:12:sysdep_routines += cacheflush
> glibc/sysdeps/unix/sysv/linux/arc/libc.abilist:574:GLIBC_2.32 cacheflush F
> glibc/sysdeps/unix/sysv/linux/csky/Versions:3: cacheflush;
> glibc/sysdeps/unix/sysv/linux/csky/sys/cachectl.h:30:extern int
> cacheflush (void *__addr, const int __nbytes,
> glibc/sysdeps/unix/sysv/linux/csky/arch-syscall.h:10:#define
> __NR_cacheflush 245
> glibc/sysdeps/unix/sysv/linux/csky/syscalls.list:2:cacheflush -
> cacheflush i:pii _flush_cache cacheflush
> glibc/sysdeps/unix/sysv/linux/csky/Makefile:2:sysdep_routines += cacheflush
> glibc/sysdeps/unix/sysv/linux/csky/libc.abilist:594:GLIBC_2.29 cacheflush F
> glibc/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist:322:GLIBC_2.0
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/mips/mips32/arch-syscall.h:19:#define
> __NR_cacheflush 4147
> glibc/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:322:GLIBC_2.0
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/mips/Versions:19: cachectl; cacheflush;
> glibc/sysdeps/unix/sysv/linux/mips/sys/cachectl.h:35:extern int
> cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
> glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/arch-syscall.h:16:#define
> __NR_cacheflush 5197
> glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist:320:GLIBC_2.0
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/arch-syscall.h:16:#define
> __NR_cacheflush 6197
> glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist:322:GLIBC_2.0
> cacheflush F
> glibc/sysdeps/unix/sysv/linux/mips/syscalls.list:8:cacheflush -
> cacheflush i:pii _flush_cache cacheflush
> glibc/sysdeps/unix/sysv/linux/mips/Makefile:6:sysdep_routines +=
> cachectl cacheflush sysmips _test_and_set
> glibc/sysdeps/unix/sysv/linux/sh/arch-syscall.h:16:#define
> __NR_cacheflush 123
> glibc/sysdeps/unix/sysv/linux/nios2/Versions:4: cacheflush;
> glibc/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h:1:/* cacheflush -
> flush contents of instruction and/or data cache.
> glibc/sysdeps/unix/sysv/linux/nios2/sys/cachectl.h:27:extern int
> cacheflush (void *__addr, const int __nbytes, const int __op) __THROW;
> glibc/sysdeps/unix/sysv/linux/nios2/arch-syscall.h:10:#define
> __NR_cacheflush 244
> glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:1:/* cacheflush system
> call for Nios II Linux.
> glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:27: return
> INLINE_SYSCALL (cacheflush, 3, addr, nbytes, op);
> glibc/sysdeps/unix/sysv/linux/nios2/cacheflush.c:29:weak_alias
> (_flush_cache, cacheflush)
> glibc/sysdeps/unix/sysv/linux/nios2/Makefile:6:# MIPS-style cacheflush
> routine
> glibc/sysdeps/unix/sysv/linux/nios2/Makefile:8:sysdep_routines += cacheflush
> glibc/sysdeps/unix/sysv/linux/nios2/libc.abilist:663:GLIBC_2.21 cacheflush F
> glibc/sysdeps/unix/sysv/linux/arm/dl-machine.h:23:
> INTERNAL_SYSCALL_CALL (cacheflush, (BEG), (END), 0)
> glibc/sysdeps/unix/sysv/linux/arm/arch-syscall.h:17:#define
> __NR_cacheflush 983042
> glibc/sysdeps/unix/sysv/linux/arm/fixup-asm-unistd.h:19:#ifndef
> __NR_cacheflush
> glibc/sysdeps/unix/sysv/linux/arm/fixup-asm-unistd.h:20:# define
> __NR_cacheflush __ARM_NR_cacheflush
> glibc/sysdeps/unix/sysv/linux/microblaze/syscalls.list:3:cacheflush
> EXTRA cacheflush i:iiii __cacheflush cacheflush
> glibc/sysdeps/unix/sysv/linux/syscall-names.list:60:cacheflush
> glibc/benchtests/strcoll-inputs/filelist#en_US.UTF-8:1417:cacheflush.c
> glibc/benchtests/strcoll-inputs/filelist#en_US.UTF-8:1744:cacheflush.c
> glibc/ChangeLog.old/ChangeLog.7:7489: * sysdeps/mach/mips/cacheflush.c:
> Likewise.
> glibc/ChangeLog.old/ChangeLog.7:9422: *
> sysdeps/unix/sysv/linux/m68k/syscalls.list: Add cacheflush.
> glibc/ChangeLog.old/ChangeLog.4:205: * sysdeps/mach/mips/cacheflush.c:
> New file.
> glibc/ChangeLog.old/ChangeLog.18:40858: *
> sysdeps/unix/sysv/linux/nios2/cacheflush.c: New file.
> glibc/ChangeLog.old/ChangeLog.ports-tile:700: *
> sysdeps/unix/sysv/linux/tile/cacheflush.c: New file.
> grep: glibc/.git/index: binary file matches
>
> $ grep -rn -e 'sys_cacheflush' -e 'SYSCALL_DEFINE.(cacheflush,' linux/ |
> grep -v -e '/arc/' -e '/csky/' -e '/mips/' -e '/nios2/'
> tools/testing/selftests/futex/functional/usr/include/linux/capability.h:251:/*
> Allow flushing all cache on m68k (sys_cacheflush) */
> include/uapi/linux/capability.h:253:/* Allow flushing all cache on m68k
> (sys_cacheflush) */
> arch/m68k/kernel/sys_m68k.c:376:/* sys_cacheflush -- flush (part of) the
> processor cache. */
> arch/m68k/kernel/sys_m68k.c:378:sys_cacheflush (unsigned long addr, int
> scope, int cache, unsigned long len)
> arch/m68k/kernel/sys_m68k.c:531:/* sys_cacheflush -- flush (part of) the
> processor cache. */
> arch/m68k/kernel/sys_m68k.c:533:sys_cacheflush (unsigned long addr, int
> scope, int cache, unsigned long len)
> arch/m68k/kernel/syscalls/syscall.tbl:133:123 common cacheflush
> sys_cacheflush
> arch/sh/kernel/sys_sh.c:57:/* sys_cacheflush -- flush (part of) the
> processor cache. */
> arch/sh/kernel/sys_sh.c:58:asmlinkage int sys_cacheflush(unsigned long
> addr, unsigned long len, int op)
> arch/sh/kernel/syscalls/syscall.tbl:133:123 common cacheflush
> sys_cacheflush
> arch/arm/include/asm/cacheflush.h:263: * This is used for the ARM
> private sys_cacheflush system call.
> arch/nds32/include/uapi/asm/unistd.h:15:__SYSCALL(__NR_cacheflush,
> sys_cacheflush)
> arch/nds32/include/asm/syscalls.h:7:asmlinkage long
> sys_cacheflush(unsigned long addr, unsigned long len, unsigned int op);
> arch/nds32/kernel/sys_nds32.c:29:SYSCALL_DEFINE3(cacheflush, unsigned
> int, start, unsigned int, end, int, cache)
>
> 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);
>
> // ARM??
>
> 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] cacheflush.2: Document different prototypes for different architectures
2020-12-11 23:52 ` Heinrich Schuchardt
@ 2020-12-12 18:19 ` Alejandro Colomar (man-pages)
0 siblings, 0 replies; 3+ messages in thread
From: Alejandro Colomar (man-pages) @ 2020-12-12 18:19 UTC (permalink / raw)
To: Heinrich Schuchardt, Michael Kerrisk (man-pages), linux-man
Cc: Dave Martin, Vineet Gupta, linux-snps-arc, Guo Ren, linux-csky,
Thomas Bogendoerfer, linux-mips, Nick Hu, Greentime Hu,
Vincent Chen, libc-alpha
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
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-12 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 21:09 [RFC] cacheflush.2: Document different prototypes for different architectures Alejandro Colomar (man-pages)
2020-12-11 23:52 ` Heinrich Schuchardt
2020-12-12 18:19 ` Alejandro Colomar (man-pages)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).