Skip to content

Commit 840c054

Browse files
committed
ARC: Support syscall ABI v4
The syscall ABI includes the gcc functional calling ABI since a syscall implies userland caller and kernel callee. The current gcc ABI (v3) for ARCv2 ISA required 64-bit data be passed in even-odd register pairs, (potentially punching reg holes when passing such values as args). This was partly driven by the fact that the double-word LDD/STD instructions in ARCv2 expect the register alignment and thus gcc forcing this avoids extra MOV at the cost of a few unused register (which we have plenty anyways). This however was rejected as part of upstreaming gcc port to HS. So the new ABI v4 doesn't enforce the even-odd reg restriction. Do note that for ARCompact ISA builds v3 and v4 are practically the same in terms of gcc code generation. In terms of change management, we infer the new ABI if gcc 6.x onwards is used for building the kernel. This also needs a stable backport to enable older kernels to work with new tools/user-space Cc: <[email protected]> Signed-off-by: Vineet Gupta <[email protected]>
1 parent 86147e3 commit 840c054

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

arch/arc/include/uapi/asm/elf.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313

1414
/* Machine specific ELF Hdr flags */
1515
#define EF_ARC_OSABI_MSK 0x00000f00
16-
#define EF_ARC_OSABI_ORIG 0x00000000 /* MUST be zero for back-compat */
17-
#define EF_ARC_OSABI_CURRENT 0x00000300 /* v3 (no legacy syscalls) */
16+
17+
#define EF_ARC_OSABI_V3 0x00000300 /* v3 (no legacy syscalls) */
18+
#define EF_ARC_OSABI_V4 0x00000400 /* v4 (64bit data any reg align) */
19+
20+
#if __GNUC__ < 6
21+
#define EF_ARC_OSABI_CURRENT EF_ARC_OSABI_V3
22+
#else
23+
#define EF_ARC_OSABI_CURRENT EF_ARC_OSABI_V4
24+
#endif
1825

1926
typedef unsigned long elf_greg_t;
2027
typedef unsigned long elf_fpregset_t;

arch/arc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ int elf_check_arch(const struct elf32_hdr *x)
199199
}
200200

201201
eflags = x->e_flags;
202-
if ((eflags & EF_ARC_OSABI_MSK) < EF_ARC_OSABI_CURRENT) {
202+
if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) {
203203
pr_err("ABI mismatch - you need newer toolchain\n");
204204
force_sigsegv(SIGSEGV, current);
205205
return 0;

arch/arc/kernel/setup.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,10 @@ static char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len)
291291
cpu->dccm.base_addr, TO_KB(cpu->dccm.sz),
292292
cpu->iccm.base_addr, TO_KB(cpu->iccm.sz));
293293

294-
n += scnprintf(buf + n, len - n,
295-
"OS ABI [v3]\t: no-legacy-syscalls\n");
294+
n += scnprintf(buf + n, len - n, "OS ABI [v%d]\t: %s\n",
295+
EF_ARC_OSABI_CURRENT >> 8,
296+
EF_ARC_OSABI_CURRENT == EF_ARC_OSABI_V3 ?
297+
"no-legacy-syscalls" : "64-bit data any register aligned");
296298

297299
return buf;
298300
}

0 commit comments

Comments
 (0)