s390: use generic uapi/asm/swab.h

clang doesn't like s390 specific inline assembler constraints. These
are present in our arch specific uapi/asm/swab.h which again is
required by some ebpf test cases.

For current compiler versions the generic swab.h already makes use of
gcc's builtin functions. Therefore we can simply remove our own header
file and use the generic one.

This will generate worse code if used with compilers before gcc 4.8,
which has no __builtin_bswap16(); or before gcc v4.4, which has no
__builtin_bswap[32|64](). For these cases a C implementation fallback
would be used which generates more code, but is still correct (170KB
extra code for gcc 4.3 with performance_defconfig).

However given that we need (and want) to get rid of the inline
assemblies anyway in order to be able to use clang, the above is just
a minor drawback if old gcc compilers are used.

With current compilers there is close to zero difference, except for
three btrfs bit functions which generate more out-of-line code. The
generated code looks still correct and also uses the s390 specific
byteswap instructions.

Reported-and-tested-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
Heiko Carstens 2017-08-02 09:45:02 +02:00 committed by Martin Schwidefsky
parent 2edf3fa576
commit 3cb8f11c5d
2 changed files with 1 additions and 89 deletions

View File

@ -9,4 +9,5 @@ generic-y += param.h
generic-y += poll.h
generic-y += resource.h
generic-y += sockios.h
generic-y += swab.h
generic-y += termbits.h

View File

@ -1,89 +0,0 @@
#ifndef _S390_SWAB_H
#define _S390_SWAB_H
/*
* S390 version
* Copyright IBM Corp. 1999
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
*/
#include <linux/types.h>
#ifndef __s390x__
# define __SWAB_64_THRU_32__
#endif
#ifdef __s390x__
static inline __u64 __arch_swab64p(const __u64 *x)
{
__u64 result;
asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x));
return result;
}
#define __arch_swab64p __arch_swab64p
static inline __u64 __arch_swab64(__u64 x)
{
__u64 result;
asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x));
return result;
}
#define __arch_swab64 __arch_swab64
static inline void __arch_swab64s(__u64 *x)
{
*x = __arch_swab64p(x);
}
#define __arch_swab64s __arch_swab64s
#endif /* __s390x__ */
static inline __u32 __arch_swab32p(const __u32 *x)
{
__u32 result;
asm volatile(
#ifndef __s390x__
" icm %0,8,%O1+3(%R1)\n"
" icm %0,4,%O1+2(%R1)\n"
" icm %0,2,%O1+1(%R1)\n"
" ic %0,%1"
: "=&d" (result) : "Q" (*x) : "cc");
#else /* __s390x__ */
" lrv %0,%1"
: "=d" (result) : "m" (*x));
#endif /* __s390x__ */
return result;
}
#define __arch_swab32p __arch_swab32p
#ifdef __s390x__
static inline __u32 __arch_swab32(__u32 x)
{
__u32 result;
asm volatile("lrvr %0,%1" : "=d" (result) : "d" (x));
return result;
}
#define __arch_swab32 __arch_swab32
#endif /* __s390x__ */
static inline __u16 __arch_swab16p(const __u16 *x)
{
__u16 result;
asm volatile(
#ifndef __s390x__
" icm %0,2,%O1+1(%R1)\n"
" ic %0,%1\n"
: "=&d" (result) : "Q" (*x) : "cc");
#else /* __s390x__ */
" lrvh %0,%1"
: "=d" (result) : "m" (*x));
#endif /* __s390x__ */
return result;
}
#define __arch_swab16p __arch_swab16p
#endif /* _S390_SWAB_H */