2012-09-29 05:05:31 +00:00
|
|
|
#define __SYSCALL_LL_E(x) \
|
|
|
|
((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
|
|
|
|
((union { long long ll; long l[2]; }){ .ll = x }).l[1]
|
fix passing of 64-bit syscall arguments on microblaze
this has been wrong since the beginning of the microblaze port: the
syscall ABI for microblaze does not align 64-bit arguments on even
register boundaries. commit 788d5e24ca19c6291cebd8d1ad5b5ed6abf42665
exposed the problem by introducing references to a nonexistent
__syscall7. the ABI is not documented well anywhere, but I was able to
confirm against both strace source and glibc source that microblaze is
not using the alignment.
per the syscall(2) man page, posix_fadvise, ftruncate, pread, pwrite,
readahead, sync_file_range, and truncate were all affected and either
did not work at all, or only worked by chance, e.g. when the affected
argument slots were all zero.
2019-05-05 14:52:41 +00:00
|
|
|
#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
|
2012-09-29 05:05:31 +00:00
|
|
|
|
2012-10-19 02:13:36 +00:00
|
|
|
static __inline long __syscall0(long n)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall1(long n, long a)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall2(long n, long a, long b)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
register unsigned long r6 __asm__("r6") = b;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5), "r"(r6)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall3(long n, long a, long b, long c)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
register unsigned long r6 __asm__("r6") = b;
|
|
|
|
register unsigned long r7 __asm__("r7") = c;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5), "r"(r6), "r"(r7)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall4(long n, long a, long b, long c, long d)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
register unsigned long r6 __asm__("r6") = b;
|
|
|
|
register unsigned long r7 __asm__("r7") = c;
|
|
|
|
register unsigned long r8 __asm__("r8") = d;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall5(long n, long a, long b, long c, long d, long e)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
register unsigned long r6 __asm__("r6") = b;
|
|
|
|
register unsigned long r7 __asm__("r7") = c;
|
|
|
|
register unsigned long r8 __asm__("r8") = d;
|
|
|
|
register unsigned long r9 __asm__("r9") = e;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8), "r"(r9)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
|
|
|
|
{
|
|
|
|
register unsigned long r12 __asm__("r12") = n;
|
|
|
|
register unsigned long r3 __asm__("r3");
|
|
|
|
register unsigned long r5 __asm__("r5") = a;
|
|
|
|
register unsigned long r6 __asm__("r6") = b;
|
|
|
|
register unsigned long r7 __asm__("r7") = c;
|
|
|
|
register unsigned long r8 __asm__("r8") = d;
|
|
|
|
register unsigned long r9 __asm__("r9") = e;
|
|
|
|
register unsigned long r10 __asm__("r10") = f;
|
|
|
|
__asm__ __volatile__ ("brki r14, 0x8" : "=r"(r3)
|
|
|
|
: "r"(r12), "r"(r5), "r"(r6), "r"(r7), "r"(r8), "r"(r9), "r"(r10)
|
2014-04-02 18:13:20 +00:00
|
|
|
: "memory", "r4");
|
2012-10-19 02:13:36 +00:00
|
|
|
return r3;
|
|
|
|
}
|
|
|
|
|
2018-06-20 04:07:09 +00:00
|
|
|
#define SYSCALL_IPC_BROKEN_MODE
|
prefer new socket syscalls, fallback to SYS_socketcall only if needed
a number of users performing seccomp filtering have requested use of
the new individual syscall numbers for socket syscalls, rather than
the legacy multiplexed socketcall, since the latter has the arguments
all in memory where they can't participate in filter decisions.
previously, some archs used the multiplexed socketcall if it was
historically all that was available, while other archs used the
separate syscalls. the intent was that the latter set only include
archs that have "always" had separate socket syscalls, at least going
back to linux 2.6.0. however, at least powerpc, powerpc64, and sh were
wrongly included in this set, and thus socket operations completely
failed on old kernels for these archs.
with the changes made here, the separate syscalls are always
preferred, but fallback code is compiled for archs that also define
SYS_socketcall. two such archs, mips (plain o32) and microblaze,
define SYS_socketcall despite never having needed it, so it's now
undefined by their versions of syscall_arch.h to prevent inclusion of
useless fallback code.
some archs, where the separate syscalls were only added after the
addition of SYS_accept4, lack SYS_accept. because socket calls are
always made with zeros in the unused argument positions, it suffices
to just use SYS_accept4 to provide a definition of SYS_accept, and
this is done to make happy the macro machinery that concatenates the
socket call name onto __SC_ and SYS_.
2020-08-09 00:59:26 +00:00
|
|
|
|
|
|
|
#undef SYS_socketcall
|