From patchwork Fri Oct 7 21:11:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 679751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3srMdq38tPz9sDG for ; Sat, 8 Oct 2016 08:11:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6C6CD33C7D; Fri, 7 Oct 2016 21:11:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xcy7NvV8pWRg; Fri, 7 Oct 2016 21:11:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id BE25233DD2; Fri, 7 Oct 2016 21:11:38 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 60CE61C2D59 for ; Fri, 7 Oct 2016 21:11:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5C94FC2DA3 for ; Fri, 7 Oct 2016 21:11:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uu9RNttLiYKO for ; Fri, 7 Oct 2016 21:11:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtprelay.synopsys.com (smtprelay.synopsys.com [198.182.60.111]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 1493EC2D9A for ; Fri, 7 Oct 2016 21:11:36 +0000 (UTC) Received: from dc8secmta1.synopsys.com (dc8secmta1.synopsys.com [10.13.218.200]) by smtprelay.synopsys.com (Postfix) with ESMTP id D940A10C11FC; Fri, 7 Oct 2016 14:11:35 -0700 (PDT) Received: from dc8secmta1.internal.synopsys.com (dc8secmta1.internal.synopsys.com [127.0.0.1]) by dc8secmta1.internal.synopsys.com (Service) with ESMTP id CD17327113; Fri, 7 Oct 2016 14:11:35 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by dc8secmta1.internal.synopsys.com (Service) with ESMTP id 8EF9227102; Fri, 7 Oct 2016 14:11:35 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 7707D503; Fri, 7 Oct 2016 14:11:35 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 65343502; Fri, 7 Oct 2016 14:11:35 -0700 (PDT) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 7 Oct 2016 14:11:35 -0700 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Sat, 8 Oct 2016 02:41:32 +0530 Received: from vineetg-Latitude-E7450.internal.synopsys.com (10.10.161.39) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Sat, 8 Oct 2016 02:41:31 +0530 From: Vineet Gupta To: Subject: [PATCH 2/2] ARC: nptl: cancellable wrappers were broken #2 Date: Fri, 7 Oct 2016 14:11:17 -0700 Message-ID: <1475874677-28945-2-git-send-email-vgupta@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475874677-28945-1-git-send-email-vgupta@synopsys.com> References: <1475874677-28945-1-git-send-email-vgupta@synopsys.com> MIME-Version: 1.0 X-Originating-IP: [10.10.161.39] Cc: Alexey Brodkin , uclibc@uclibc.org, Vineet Gupta , linux-snps-arc@lists.infradead.org, Eugeniy Paltsev X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" Despite the prev fix, tst-mqueue3 was still segfaulting. The issue was BLINK register not restored properly for return 00002690 : 2690: sub r9,r25,0x448 2698: ld r10,[r9] 269c: cmp r10,0 26a0: beq -36 26a4: st.aw blink,[sp,-4] 26a8: st.aw r0,[sp,-4] 26ac: st.aw r1,[sp,-4] 26b0: st.aw r2,[sp,-4] 26b4: st.aw r3,[sp,-4] 26b8: st.aw r4,[sp,-4] 26bc: bl 1e28 <__librt_enable_asynccancel> 26c0: mov r9,r0 26c4: ld.ab r4,[sp,4] 26c8: ld.ab r3,[sp,4] 26cc: ld.ab r2,[sp,4] 26d0: ld.ab r1,[sp,4] 26d4: ld.ab r0,[sp,4] 26d8: ld.ab blink,[sp, 4] <---- function return BLINK 26dc: mov r8,182 26e0: trap_s 0 26e2: cmp r0,-1024 26e6: st.aw r0,[sp,-4] 26ea: mov r0,r9 26ee: bl 1e90 <__librt_disable_asynccancel> <-- BLINK clobbered to next PC 26f2: ld.ab r0,[sp,4] <----| loops here until sp is out of bound 26fa: cmp r0,-1024 | 26fe: jls [blink] -----| 2702: b 15d8 2706: nop_s So the fix was to retain BLINK on stack before function call, and pop it later - 26d8: ld.ab blink,[sp, 4] + 26d8: ld blink,[sp] <--- restore BLINK, but retain on stack 26dc: mov r8,182 26e0: trap_s 0 26e2: cmp r0,-1024 26e6: st.aw r0,[sp,-4] 26ea: mov r0,r9 26ee: bl 1e90 <__librt_disable_asynccancel> 26f2: ld.ab r0,[sp,4] + 26f6: ld.ab blink,[sp,4] <--- finally pop BLINK 26fa: cmp r0,-1024 26fe: jls [blink] Reported-by: Eugeniy Paltsev Cc: Alexey Brodkin Signed-off-by: Vineet Gupta --- libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h index 918f61d67548..01fd844d13f7 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/sysdep-cancel.h @@ -38,6 +38,7 @@ mov r0, r9 /* prep mask for disable_asynccancel */ ` \ CDISABLE ` \ pop r0 /* get syscall ret value back */ ` \ + pop blink /* UNDOCARGS above left blink on stack */ ` \ cmp r0, -1024 ` \ jls [blink] ` \ b __syscall_error@plt ` \ @@ -75,7 +76,9 @@ .endm #define DOCARGS_0 push blink -#define UNDOCARGS_0 pop blink + +/* don't pop blink at this point */ +#define UNDOCARGS_0 ld blink, [sp] #define DOCARGS_1 DOCARGS_0` push r0 #define UNDOCARGS_1 pop r0` UNDOCARGS_0