From patchwork Mon Mar 21 11:23:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangjian X-Patchwork-Id: 8631831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0ED61C0553 for ; Mon, 21 Mar 2016 11:33:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EAA0F202B8 for ; Mon, 21 Mar 2016 11:33:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 732C020204 for ; Mon, 21 Mar 2016 11:32:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ahy3V-0002SI-0d; Mon, 21 Mar 2016 11:31:29 +0000 Received: from [119.145.14.52] (helo=szxga04-in.huawei.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ahy3O-0002D9-Jg for linux-arm-kernel@lists.infradead.org; Mon, 21 Mar 2016 11:31:26 +0000 Received: from 172.24.1.138 (EHLO lggeml423-hub.china.huawei.com) ([172.24.1.138]) by szxrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AUI32312; Mon, 21 Mar 2016 19:10:17 +0800 (CST) Received: from [127.0.0.1] (10.111.72.170) by lggeml423-hub.china.huawei.com (10.72.61.33) with Microsoft SMTP Server id 14.3.235.1; Mon, 21 Mar 2016 19:23:31 +0800 Subject: Re: [RFC5 PATCH v6 00/21] ILP32 for ARM64 To: Yury Norov References: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> <56AB3805.1040308@huawei.com> <20160129170929.GA3543@yury-N73SV> <56AC38F1.2030608@huawei.com> <20160218223506.GA7816@yury-N73SV> <20160225202855.GD16123@yury-N73SV> <56EBD84D.2060009@huawei.com> <20160318154918.GA1595@yury-N73SV> <56EC24EE.6020803@suse.de> <20160318164627.GA3201@yury-N73SV> <56EE5B6E.6030305@huawei.com> From: "Zhangjian (Bamvor)" Message-ID: <56EFD9B0.6080004@huawei.com> Date: Mon, 21 Mar 2016 19:23:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <56EE5B6E.6030305@huawei.com> X-Originating-IP: [10.111.72.170] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.56EFD9C2.01B8, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: e75bdbceb8d92e1758f7fafa28b65c6f X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160321_043125_355095_AECDFC90 X-CRM114-Status: GOOD ( 17.30 ) X-Spam-Score: -1.1 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Zhangjian \(Bamvor\)" , arnd@arndb.de, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, Andreas Schwab , "dingtianhong@huawei.com" , heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org, Alexander Graf , klimov.linux@gmail.com, broonie@kernel.org, jan.dakinevich@gmail.com, joseph@codesourcery.com, catalin.marinas@arm.com, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, Bamvor Zhang Jian , linux-arm-kernel@lists.infradead.org, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, Yury On 2016/3/20 16:12, Zhangjian (Bamvor) wrote: > Hi, Yury > > On 2016/3/19 0:46, Yury Norov wrote: [...] >> The minimal test reproducing it is attached. The similar test where >> parent forks a child and then kills it, works fine. (Attached too). >> >> I see that in case of pthread, there's much more stuff that is cloned. >> Other's looking similar. >> >> pthread_create(): >> clone(child_stack=0xb953cea0, flags=CLONE_VM|CLONE_FS|CLONE_FILES >> |CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS >> |CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, >> parent_tidptr=0xb953d398, tls=0xb953d7c0, child_tidptr=0xb953d398) = 1650 >> >> fork(): >> clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, >> child_tidptr=0xe5af6278) = 30537 >> >> So this most probably means that ilp32 code doesn't handle one of cloned >> item properly. I have already discovered a bug where child processes >> used parent TLS, > It is a kernel bug or glibc bug? Could you please explain it or show the patch? > The current ILP32 patches looks good to me. Recently, I backport these patches > to our 4.1 kernel. And I saw crash frequently even if I only do a single print > or infinite loop. There is some small changes about tls register after 4.1. I > am not sure if it is a similar issue. It is great if you have some suggestions/ > ideas. My issue is because I forget to change is_compat_task to is_a32_compat_task in arch/arm64/kernel/process.c such piece of code is delete after commit d00a3810c162 ("arm64: context-switch user tls register tpidr_el0 for compat tasks). It is not exist in upstream kernel, never mind. Meanwhile, I found that it seem that there is another is_compat_task in tls_thread_flush. Is it relative the issue you mentioned? ``` ``` Regards Bamvor > Thanks. > > Bamvor > > so maybe this is something similar... >> >> Except of this, I think ILP32 series is looking pretty well, at least >> kernel part. >> >> If you have any ideas/suggestions, I'll really appreciate it. >> >> Yury. >> >> strace -f ./trigo >> [...] >> clone(child_stack=0xdbbfb000, >> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND >> |CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS >> |CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, >> parent_tidptr=0xdbbfb4f8, tls=0xdbbfb920, child_tidptr=0xdbbfb4f8) = 32030 >> rt_sigprocmask(SIG_BLOCK, [CHLD], Process 32030 attached [], 8) = 0 >> [pid 32029] rt_sigaction(SIGCHLD, NULL, >> [pid 32030] set_robust_list(0xdbbfb504, 12 >> [pid 32029] <... rt_sigaction resumed> {SIG_DFL, [ILL ABRT SEGV URG], 0}, 8) = 0 >> [pid 32030] <... set_robust_list resumed> ) = 0 >> [pid 32029] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 >> [pid 32030] write(1, "started\n", 8started >> >> [pid 32029] nanosleep({1, 65536}, >> [pid 32030] <... write resumed> ) = 8 >> [pid 32030] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 >> [pid 32030] rt_sigsuspend([] >> [pid 32029] <... nanosleep resumed> 0xfff9fd98) = 0 >> [pid 32029] write(1, "stoping...\n", 11stoping...) = 11 >> [pid 32029] openat(AT_FDCWD, "/root/sys-root/libilp32/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3 >> [pid 32029] read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0 \0\0004\0\0\0"..., 512) = 512 >> [pid 32029] fstat(3, {st_mode=S_IFREG|0644, st_size=429138, ...}) = 0 >> [pid 32029] mmap(NULL, 135104, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xdb3db000 >> [pid 32029] mprotect(0xdb3ec000, 61440, PROT_NONE) = 0 >> [pid 32029] mmap(0xdb3fb000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0xdb3fb000 >> [pid 32029] close(3) = 0 >> [pid 32029] tgkill(32029, 32030, SIGRTMIN) = 0 >> [pid 32030] <... rt_sigsuspend resumed> ) = ? ERESTARTNOHAND (To be >> restarted if no handler) >> [pid 32029] write(1, "pthread_cancel == 0\n", 20pthread_cancel == 0) = 20 >> [pid 32030] --- SIGRTMIN {si_signo=SIGRTMIN, si_code=SI_TKILL, si_pid=32029, si_uid=0} --- >> [pid 32029] write(1, "stopped\n", 8stopped >> >> [pid 32030] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x14} --- >> [pid 32029] <... write resumed> ) = ? >> [pid 32030] +++ killed by SIGSEGV +++ >> +++ killed by SIGSEGV +++ >> Segmentation fault >> >> dmesg: >> trigo[32246]: unhandled level 2 translation fault (11) at 0x00000014, >> esr 0x90000006 >> pgd = ffffffc009335000 >> [00000014] *pgd=000000007917c003, *pud=000000007917c003, >> *pmd=0000000000000000 >> >> CPU: 2 PID: 32246 Comm: trigo Not tainted 4.5.0+ #91 >> Hardware name: linux,dummy-virt (DT) >> task: ffffffc00900e400 ti: ffffffc009078000 task.ti: ffffffc009078000 >> PC is at 0xda6853f0 >> LR is at 0xda6d5440 >> pc : [<00000000da6853f0>] lr : [<00000000da6d5440>] pstate: 60000000 >> sp : 00000000da511bc0 >> x29: 00000000da512e10 x28: 00000000da6a7000 >> x27: 0000000000000000 x26: 00000000da513490 >> x25: 0000000000000000 x24: 0000000000400820 >> x23: 00000000da6a9000 x22: 00000000ff869acb >> x21: 00000000da6a9000 x20: 00000000da512e50 >> x19: 0000000000000000 x18: 0000000000000001 >> x17: 0000000000410bd8 x16: 00000000da691138 >> x15: 0000000000000000 x14: 0000000000000000 >> x13: 00000000da535970 x12: 0000000000000038 >> x11: 0000000000000028 x10: 0101010101010101 >> x9 : ff63647371607372 x8 : 0000000000000085 >> x7 : 0000000000007df5 x6 : 00000000da512e1c >> x5 : 00000000da513518 x4 : 0000000000000002 >> x3 : 00000000da513920 x2 : 0000000000000000 >> x1 : 0000000000000008 x0 : 00000000da513490 >> > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 432b094..9ab968c 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -209,7 +209,7 @@ static void tls_thread_flush(void) { asm ("msr tpidr_el0, xzr"); - if (is_compat_task()) { + if (is_a32_compat_task()) { current->thread.tp_value = 0; /*