From patchwork Tue Nov 28 12:44:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 24570 Received: (qmail 7350 invoked by alias); 28 Nov 2017 12:44:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 7330 invoked by uid 89); 28 Nov 2017 12:44:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=06, Stefan, stefan, vdso X-HELO: mx0a-001b2d01.pphosted.com To: GNU C Library From: Stefan Liebler Subject: [PATCH] S390: Fix backtrace in vdso functions. Date: Tue, 28 Nov 2017 13:44:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17112812-0012-0000-0000-0000059264F6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112812-0013-0000-0000-0000190D4B5D Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-28_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711280173 Hi, On s390, GDB fails to show the complete backtrace from within vdso functions. The macro INTERNAL_VSYSCALL_CALL saves the return address in r14 to r10 before branching to the vdso function. The branch-instruction updates r14 in order to let the vdso function return. Then the original address in r14 is restored from r10. Unfortunately, there are no cfi-rules and GDB fails. Furthermore the call of the vdso function does not comply with the s390 ABI as no stack-frame for the vdso-function is generated. This patch removes the s390 specific macro INTERNAL_VSYSCALL_CALL and the common implementation in sysdeps/unix/sysv/linux/sysdep-vdso.h is used. Then the vdso function is called via function-pointer and GCC generates a new stack-frame and emits all needed cfi-rules. The defines CLOBBER_[0-6] are removed as they were only used in macro INTERNAL_VSYSCALL_CALL. The macro INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK is not used on s390. The only user is power. Thus it is removed from s390 sysdep.h. ChangeLog: * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_VSYSCALL_CALL, CLOBBER_0, CLOBBER_1, CLOBBER_2, CLOBBER_3, CLOBBER_4, CLOBBER_5, CLOBBER_6, INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise. Reviewed-by: Adhemerval Zanella commit a1000218276c4cfb9a72e53f17b144b137faf334 Author: Stefan Liebler Date: Mon Nov 27 11:24:45 2017 +0100 S390: Fix backtrace in vdso functions. On s390, GDB fails to show the complete backtrace from within vdso functions. The macro INTERNAL_VSYSCALL_CALL saves the return address in r14 to r10 before branching to the vdso function. The branch-instruction updates r14 in order to let the vdso function return. Then the original address in r14 is restored from r10. Unfortunately, there are no cfi-rules and GDB fails. Furthermore the call of the vdso function does not comply with the s390 ABI as no stack-frame for the vdso-function is generated. This patch removes the s390 specific macro INTERNAL_VSYSCALL_CALL and the common implementation in sysdeps/unix/sysv/linux/sysdep-vdso.h is used. Then the vdso function is called via function-pointer and GCC generates a new stack-frame and emits all needed cfi-rules. The defines CLOBBER_[0-6] are removed as they were only used in macro INTERNAL_VSYSCALL_CALL. The macro INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK is not used on s390. The only user is power. Thus it is removed from s390 sysdep.h. ChangeLog: * sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (INTERNAL_VSYSCALL_CALL, CLOBBER_0, CLOBBER_1, CLOBBER_2, CLOBBER_3, CLOBBER_4, CLOBBER_5, CLOBBER_6, INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove. * sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise. diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h index e56fc32..644b83c 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h @@ -271,48 +271,12 @@ #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6) #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7) -#define CLOBBER_0 , "3", "4", "5" -#define CLOBBER_1 , "3", "4", "5" -#define CLOBBER_2 , "4", "5" -#define CLOBBER_3 , "5" -#define CLOBBER_4 -#define CLOBBER_5 -#define CLOBBER_6 - /* List of system calls which are supported as vsyscalls. */ #define HAVE_CLOCK_GETRES_VSYSCALL 1 #define HAVE_CLOCK_GETTIME_VSYSCALL 1 #define HAVE_GETTIMEOFDAY_VSYSCALL 1 #define HAVE_GETCPU_VSYSCALL 1 -/* This version is for internal uses when there is no desire - to set errno */ -#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ - ({ \ - long int _ret = ENOSYS; \ - \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ - if (vdsop != NULL) \ - _ret = INTERNAL_VSYSCALL_CALL (vdsop, err, nr, ##args); \ - else \ - err = 1 << 28; \ - _ret; \ - }) - -#define INTERNAL_VSYSCALL_CALL(fn, err, nr, args...) \ - ({ \ - DECLARGS_##nr(args) \ - register long _ret __asm__("2"); \ - __asm__ __volatile__ ( \ - "lr 10,14\n\t" \ - "basr 14,%1\n\t" \ - "lr 14,10\n\t" \ - : "=d" (_ret) \ - : "d" (fn) ASMFMT_##nr \ - : "cc", "memory", "0", "1", "10" CLOBBER_##nr); \ - _ret; }) - /* Pointer mangling support. */ #if IS_IN (rtld) /* We cannot use the thread descriptor because in ld.so we use setjmp diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h index 622991d..18ed339 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h @@ -277,14 +277,6 @@ #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6) #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7) -#define CLOBBER_0 , "3", "4", "5" -#define CLOBBER_1 , "3", "4", "5" -#define CLOBBER_2 , "4", "5" -#define CLOBBER_3 , "5" -#define CLOBBER_4 -#define CLOBBER_5 -#define CLOBBER_6 - /* List of system calls which are supported as vsyscalls. */ #define HAVE_CLOCK_GETRES_VSYSCALL 1 #define HAVE_CLOCK_GETTIME_VSYSCALL 1 @@ -293,34 +285,6 @@ #define SINGLE_THREAD_BY_GLOBAL 1 -/* This version is for internal uses when there is no desire - to set errno */ -#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, nr, args...) \ - ({ \ - long int _ret = ENOSYS; \ - \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ - if (vdsop != NULL) \ - _ret = INTERNAL_VSYSCALL_CALL (vdsop, err, nr, ##args); \ - else \ - err = 1 << 28; \ - _ret; \ - }) - -#define INTERNAL_VSYSCALL_CALL(fn, err, nr, args...) \ - ({ \ - DECLARGS_##nr(args) \ - register long _ret __asm__("2"); \ - __asm__ __volatile__ ( \ - "lgr 10,14\n\t" \ - "basr 14,%1\n\t" \ - "lgr 14,10\n\t" \ - : "=d" (_ret) \ - : "a" (fn) ASMFMT_##nr \ - : "cc", "memory", "0", "1", "10" CLOBBER_##nr); \ - _ret; }) - /* Pointer mangling support. */ #if IS_IN (rtld) /* We cannot use the thread descriptor because in ld.so we use setjmp