Add build option to disable usage of scv on powerpc

Commit 68ab82f566 added support for the scv
syscall ABI on powerpc.  Since then systems that have kernel and processor
support started using scv.  However adding the proper support for a new syscall
ABI requires changes to several other projects (e.g. qemu, valgrind, strace,
kernel), which are gradually receiving support.

Meanwhile, having a way to disable scv on glibc at build time can be useful for
distros that may encounter conflicts with projects that still do not support the
scv ABI, buying time until proper support is added.

This commit adds a --disable-scv option that disables scv support and uses sc
for all syscalls, like before commit 68ab82f566.

Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
This commit is contained in:
Matheus Castanho 2021-04-09 14:47:27 -03:00
parent acc85ea1eb
commit ebae2f5a6f
10 changed files with 59 additions and 13 deletions

View file

@ -253,6 +253,10 @@ if 'CFLAGS' is specified it must enable optimization. For example:
(set glibc.malloc.tcache_count to zero), this option can be used to (set glibc.malloc.tcache_count to zero), this option can be used to
remove it from the build completely. remove it from the build completely.
'--disable-scv'
Disable using 'scv' instruction for syscalls. All syscalls will
use 'sc' instead, even if the kernel supports 'scv'. PowerPC only.
'--build=BUILD-SYSTEM' '--build=BUILD-SYSTEM'
'--host=HOST-SYSTEM' '--host=HOST-SYSTEM'
These options are for cross-compiling. If you specify both options These options are for cross-compiling. If you specify both options

3
NEWS
View file

@ -31,6 +31,9 @@ Major new features:
__STDC_WANT_IEC_60559_BFP_EXT__, as specified in TS 18661-1, is __STDC_WANT_IEC_60559_BFP_EXT__, as specified in TS 18661-1, is
defined, and when _GNU_SOURCE is defined. defined, and when _GNU_SOURCE is defined.
* On powerpc64*, glibc can now be compiled without scv support using the
--disable-scv configure option.
Deprecated and removed features, and other changes affecting compatibility: Deprecated and removed features, and other changes affecting compatibility:
* The function pthread_mutex_consistent_np has been deprecated; programs * The function pthread_mutex_consistent_np has been deprecated; programs

View file

@ -26,6 +26,9 @@
/* On powerpc64, define if the compiler supports -mcpu=power10. */ /* On powerpc64, define if the compiler supports -mcpu=power10. */
#undef USE_PPC64_MCPU_POWER10 #undef USE_PPC64_MCPU_POWER10
/* On powerpc*, define if scv should be used for syscalls (when available). */
#undef USE_PPC_SCV
/* Define if _Unwind_Find_FDE should be exported from glibc. */ /* Define if _Unwind_Find_FDE should be exported from glibc. */
#undef EXPORT_UNWIND_FIND_FDE #undef EXPORT_UNWIND_FIND_FDE

16
configure vendored
View file

@ -791,6 +791,7 @@ enable_pt_chown
enable_tunables enable_tunables
enable_mathvec enable_mathvec
enable_cet enable_cet
enable_scv
with_cpu with_cpu
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
@ -1463,6 +1464,8 @@ Optional Features:
depends on architecture] depends on architecture]
--enable-cet enable Intel Control-flow Enforcement Technology --enable-cet enable Intel Control-flow Enforcement Technology
(CET), x86 only (CET), x86 only
--disable-scv syscalls will not use scv instruction, even if the
kernel supports it, powerpc only
Optional Packages: Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -3814,6 +3817,19 @@ else
fi fi
# Check whether --enable-scv was given.
if test "${enable_scv+set}" = set; then :
enableval=$enable_scv; use_scv=$enableval
else
use_scv=yes
fi
if test "$use_scv" != "no"; then :
$as_echo "#define USE_PPC_SCV 1" >>confdefs.h
fi
# We keep the original values in `$config_*' and never modify them, so we # We keep the original values in `$config_*' and never modify them, so we
# can write them unchanged into config.make. Everything else uses # can write them unchanged into config.make. Everything else uses
# $machine, $vendor, and $os, and changes them whenever convenient. # $machine, $vendor, and $os, and changes them whenever convenient.

View file

@ -470,6 +470,14 @@ AC_ARG_ENABLE([cet],
[enable_cet=$enableval], [enable_cet=$enableval],
[enable_cet=$libc_cv_compiler_default_cet]) [enable_cet=$libc_cv_compiler_default_cet])
AC_ARG_ENABLE([scv],
AC_HELP_STRING([--disable-scv],
[syscalls will not use scv instruction, even if the kernel supports it, powerpc only]),
[use_scv=$enableval],
[use_scv=yes])
AS_IF([[test "$use_scv" != "no"]],[AC_DEFINE(USE_PPC_SCV)])
# We keep the original values in `$config_*' and never modify them, so we # We keep the original values in `$config_*' and never modify them, so we
# can write them unchanged into config.make. Everything else uses # can write them unchanged into config.make. Everything else uses
# $machine, $vendor, and $os, and changes them whenever convenient. # $machine, $vendor, and $os, and changes them whenever convenient.

View file

@ -282,6 +282,10 @@ this cache can be disabled on a per-application basis using tunables
(set glibc.malloc.tcache_count to zero), this option can be used to (set glibc.malloc.tcache_count to zero), this option can be used to
remove it from the build completely. remove it from the build completely.
@item --disable-scv
Disable using @code{scv} instruction for syscalls. All syscalls will use
@code{sc} instead, even if the kernel supports @code{scv}. PowerPC only.
@item --build=@var{build-system} @item --build=@var{build-system}
@itemx --host=@var{host-system} @itemx --host=@var{host-system}
These options are for cross-compiling. If you specify both options and These options are for cross-compiling. If you specify both options and

View file

@ -306,7 +306,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
beq \JUMPFALSE beq \JUMPFALSE
.endm .endm
#if IS_IN(rtld) #if !defined(USE_PPC_SCV) || IS_IN(rtld)
# define DO_CALL(syscall) \ # define DO_CALL(syscall) \
li r0,syscall; \ li r0,syscall; \
DO_CALL_SC DO_CALL_SC
@ -323,7 +323,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
b 1f; \ b 1f; \
0: DO_CALL_SC; \ 0: DO_CALL_SC; \
1: 1:
#endif /* IS_IN(rtld) */ #endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
/* DO_CALL_SC and DO_CALL_SCV expect the syscall number to be in r0. */ /* DO_CALL_SC and DO_CALL_SCV expect the syscall number to be in r0. */
#define DO_CALL_SC \ #define DO_CALL_SC \
@ -378,7 +378,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
.endif .endif
#endif #endif
#if IS_IN(rtld) #if !defined(USE_PPC_SCV) || IS_IN(rtld)
# define PSEUDO_RET \ # define PSEUDO_RET \
RET_SC; \ RET_SC; \
TAIL_CALL_SYSCALL_ERROR TAIL_CALL_SYSCALL_ERROR
@ -395,7 +395,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
b 1f; \ b 1f; \
0: RET_SC; \ 0: RET_SC; \
1: TAIL_CALL_SYSCALL_ERROR 1: TAIL_CALL_SYSCALL_ERROR
#endif #endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
#define RET_SCV \ #define RET_SCV \
li r9,-4095; \ li r9,-4095; \
@ -417,7 +417,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
ENTRY (name); \ ENTRY (name); \
DO_CALL (SYS_ify (syscall_name)) DO_CALL (SYS_ify (syscall_name))
#if IS_IN(rtld) #if !defined(USE_PPC_SCV) || IS_IN(rtld)
# define PSEUDO_RET_NOERRNO \ # define PSEUDO_RET_NOERRNO \
blr blr
#else #else
@ -425,7 +425,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
# define PSEUDO_RET_NOERRNO \ # define PSEUDO_RET_NOERRNO \
NVOLREG_RESTORE; \ NVOLREG_RESTORE; \
blr blr
#endif /* IS_IN(rtld) */ #endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
#define ret_NOERRNO PSEUDO_RET_NOERRNO #define ret_NOERRNO PSEUDO_RET_NOERRNO
@ -438,7 +438,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
ENTRY (name); \ ENTRY (name); \
DO_CALL (SYS_ify (syscall_name)) DO_CALL (SYS_ify (syscall_name))
#if IS_IN(rtld) #if !defined(USE_PPC_SCV) || IS_IN(rtld)
# define PSEUDO_RET_ERRVAL \ # define PSEUDO_RET_ERRVAL \
blr blr
#else #else
@ -446,7 +446,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
# define PSEUDO_RET_ERRVAL \ # define PSEUDO_RET_ERRVAL \
NVOLREG_RESTORE; \ NVOLREG_RESTORE; \
blr blr
#endif /* IS_IN(rtld) */ #endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
#define ret_ERRVAL PSEUDO_RET_ERRVAL #define ret_ERRVAL PSEUDO_RET_ERRVAL

View file

@ -38,11 +38,13 @@ ENTRY (__clone)
beq- cr0,L(badargs) beq- cr0,L(badargs)
/* Save some regs in the "red zone". */ /* Save some regs in the "red zone". */
#ifdef USE_PPC_SCV
std r28,-32(r1) std r28,-32(r1)
cfi_offset(r28,-32)
#endif
std r29,-24(r1) std r29,-24(r1)
std r30,-16(r1) std r30,-16(r1)
std r31,-8(r1) std r31,-8(r1)
cfi_offset(r28,-32)
cfi_offset(r29,-24) cfi_offset(r29,-24)
cfi_offset(r30,-16) cfi_offset(r30,-16)
cfi_offset(r31,-8) cfi_offset(r31,-8)
@ -71,6 +73,7 @@ ENTRY (__clone)
/* Do the call. */ /* Do the call. */
li r0,SYS_ify(clone) li r0,SYS_ify(clone)
#ifdef USE_PPC_SCV
CHECK_SCV_SUPPORT r28 0f CHECK_SCV_SUPPORT r28 0f
/* This is equivalent to DO_CALL_SCV, but we cannot use the macro here /* This is equivalent to DO_CALL_SCV, but we cannot use the macro here
because it uses CFI directives and we just called cfi_endproc. */ because it uses CFI directives and we just called cfi_endproc. */
@ -87,6 +90,7 @@ ENTRY (__clone)
/* When using scv, error is indicated by negative r3. */ /* When using scv, error is indicated by negative r3. */
cmpdi cr1,r3,0 cmpdi cr1,r3,0
b 1f b 1f
#endif /* USE_PPC_SCV */
0: DO_CALL_SC 0: DO_CALL_SC
/* Check for child process. */ /* Check for child process. */
@ -119,22 +123,26 @@ L(parent):
cmpdi cr1,r28,0 cmpdi cr1,r28,0
/* Parent. Restore registers & return. */ /* Parent. Restore registers & return. */
#ifdef USE_PPC_SCV
cfi_offset(r28,-32) cfi_offset(r28,-32)
ld r28,-32(r1)
cfi_restore(r28)
#endif
cfi_offset(r29,-24) cfi_offset(r29,-24)
cfi_offset(r30,-16) cfi_offset(r30,-16)
cfi_offset(r31,-8) cfi_offset(r31,-8)
ld r28,-32(r1)
ld r29,-24(r1) ld r29,-24(r1)
ld r30,-16(r1) ld r30,-16(r1)
ld r31,-8(r1) ld r31,-8(r1)
cfi_restore(r28)
cfi_restore(r29) cfi_restore(r29)
cfi_restore(r30) cfi_restore(r30)
cfi_restore(r31) cfi_restore(r31)
#ifdef USE_PPC_SCV
beq cr1,0f beq cr1,0f
RET_SCV RET_SCV
b 1f b 1f
#endif
0: RET_SC 0: RET_SC
1: TAIL_CALL_SYSCALL_ERROR 1: TAIL_CALL_SYSCALL_ERROR

View file

@ -25,7 +25,7 @@ ENTRY (syscall)
mr r6,r7 mr r6,r7
mr r7,r8 mr r7,r8
mr r8,r9 mr r8,r9
#if !IS_IN(rtld) && (defined(__PPC64__) || defined(__powerpc64__)) #if defined(USE_PPC_SCV) && !IS_IN(rtld) && (defined(__PPC64__) || defined(__powerpc64__))
CHECK_SCV_SUPPORT r9 0f CHECK_SCV_SUPPORT r9 0f
DO_CALL_SCV DO_CALL_SCV
RET_SCV RET_SCV

View file

@ -125,7 +125,7 @@
/* When inside the dynamic loader, the thread pointer may not have been /* When inside the dynamic loader, the thread pointer may not have been
initialized yet, so don't check for scv support in that case. */ initialized yet, so don't check for scv support in that case. */
# if !IS_IN(rtld) # if defined(USE_PPC_SCV) && !IS_IN(rtld)
# undef TRY_SYSCALL_SCV # undef TRY_SYSCALL_SCV
# define TRY_SYSCALL_SCV(nr) \ # define TRY_SYSCALL_SCV(nr) \
CHECK_THREAD_POINTER && THREAD_GET_HWCAP() & PPC_FEATURE2_SCV ? \ CHECK_THREAD_POINTER && THREAD_GET_HWCAP() & PPC_FEATURE2_SCV ? \