From 9f6dd78593e1d3b06f6e72f8479c91361e28ac28 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 26 Sep 2019 19:14:36 -0400 Subject: [PATCH] fix mips r6 syscall clobber lists not to include hi/lo registers mips r6 (an incompatible isa from traditional mips) removes the hi and lo registers used for mul/div results. older gcc versions accepted them in the clobber list for asm, but their presence is incorrect and breaks on later versions. in the process of fixing this, the clobber list for 32-bit mips syscalls has been deduplicated via a macro like on mips64 and n32. --- arch/mips/syscall_arch.h | 34 ++++++++++++++++++---------------- arch/mips64/syscall_arch.h | 6 ++++++ arch/mipsn32/syscall_arch.h | 6 ++++++ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/arch/mips/syscall_arch.h b/arch/mips/syscall_arch.h index 2ef8a952..808aa41d 100644 --- a/arch/mips/syscall_arch.h +++ b/arch/mips/syscall_arch.h @@ -5,6 +5,16 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" +#else +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "hi", "lo", "memory" +#endif + static inline long __syscall0(long n) { register long r7 __asm__("$7"); @@ -12,8 +22,7 @@ static inline long __syscall0(long n) __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -26,8 +35,7 @@ static inline long __syscall1(long n, long a) "addu $2,$0,%2 ; syscall" : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), "r"(r4) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -41,8 +49,7 @@ static inline long __syscall2(long n, long a, long b) "addu $2,$0,%2 ; syscall" : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -57,8 +64,7 @@ static inline long __syscall3(long n, long a, long b, long c) "addu $2,$0,%2 ; syscall" : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -73,8 +79,7 @@ static inline long __syscall4(long n, long a, long b, long c, long d) "addu $2,$0,%2 ; syscall" : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -92,8 +97,7 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e) "addu $sp,$sp,32" : "=&r"(r2), "=r"(r7), "+r"(r8) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$9", "$10"); return r7 ? -r2 : r2; } @@ -112,8 +116,7 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo "addu $sp,$sp,32" : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST, "$10"); return r7 ? -r2 : r2; } @@ -133,8 +136,7 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo "addu $sp,$sp,32" : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9), "+r"(r10) : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + : SYSCALL_CLOBBERLIST); return r7 ? -r2 : r2; } diff --git a/arch/mips64/syscall_arch.h b/arch/mips64/syscall_arch.h index 013908dd..69c429b8 100644 --- a/arch/mips64/syscall_arch.h +++ b/arch/mips64/syscall_arch.h @@ -3,9 +3,15 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" +#else #define SYSCALL_CLOBBERLIST \ "$1", "$3", "$10", "$11", "$12", "$13", \ "$14", "$15", "$24", "$25", "hi", "lo", "memory" +#endif static inline long __syscall0(long n) { diff --git a/arch/mipsn32/syscall_arch.h b/arch/mipsn32/syscall_arch.h index 5a6da0ed..5ff43bba 100644 --- a/arch/mipsn32/syscall_arch.h +++ b/arch/mipsn32/syscall_arch.h @@ -3,9 +3,15 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" +#else #define SYSCALL_CLOBBERLIST \ "$1", "$3", "$10", "$11", "$12", "$13", \ "$14", "$15", "$24", "$25", "hi", "lo", "memory" +#endif static inline long __syscall0(long n) { -- 2.25.1