From patchwork Fri Feb 15 14:11:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 158521 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp749977jaa; Fri, 15 Feb 2019 06:11:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IZjfim/C5817LgCi+gAbb5T7qAmF6zzWsEuGRTCywHVFI79YWCt1EAMpajheUlY+SNde3GR X-Received: by 2002:a17:902:166:: with SMTP id 93mr10466890plb.20.1550239913488; Fri, 15 Feb 2019 06:11:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550239913; cv=none; d=google.com; s=arc-20160816; b=oCVKZGAeUCIrqzN3d25PXDauIvQPu0ufopfYBpwB+JbCYmcd6Yf/8ak2LLG93KroXX 3T4BAWl9ldkinzDYb9D+WmpI4Vj1xHzVII60mA5U6Y4p7QRx4f1f6vsPsxsmgI4v5ISW C597KxUDoHh6vjkVxWX77LCbxIb+yHsxHJ6yYKX7/W6WuFWLfD43B28KW2lMdfYpoEME ghhf0RJ0zPecssAhZ6QrUcj3/DLHjTMWLLYCdie7DaApMHafl3rITYtGwRLO52MdCy4j 1L+bjJnqPnJa9+KufBMXYDE15B35CV3OcFW0yKfSwLIi7GjBJmLPlfJn8yzKphdOBBLU 3g0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=LZmTjnYNjD+c/g3pGQg4EPa8hxXN8fX76Tkq7i8tYp4=; b=OsdzVVIBYr1hU2VgC80dH6TSJCi4uYKX8vyfGSqbUXtT7v9HqzqLG+PIdXmX3u1dMc ArR8PspW5+O62Yb4sRp8jKokPfj/msi7DPsi5YX+Ctt5DaddgKiedPxq4lukECq838yT DQDTCBOi/xOENqjuf4trs7FV6NxSimsnx1KSW9J/Lu17nzRba0D1AwowaNhnx5WwGV+1 HdwYlCm3f7htw9c4mOkOFaSowAWZlKaDXnulfwTdp6okBQynFJBJlmN/59GcAVT/sHWE p5QH7+1gS3gSoum5/kiD164kr+TymBOvxpBeXSWIAcibQTH1s3NaQvdTmzbsWQUyYYiF p1ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="pq/yP+8e"; dkim=pass header.i=@linaro.org header.s=google header.b=VynUD2tm; spf=pass (google.com: domain of libc-alpha-return-100071-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100071-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d188si5397625pgc.97.2019.02.15.06.11.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 06:11:53 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-100071-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="pq/yP+8e"; dkim=pass header.i=@linaro.org header.s=google header.b=VynUD2tm; spf=pass (google.com: domain of libc-alpha-return-100071-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100071-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=FFCWCkKspbGq30ybAJSNjh2pXpIdoT2Tn7mrFvthvHIchzEir+huc I+lW+UnZty8ufAtTn6Z41UFyBXWBZY1vq7cJc5IYYCLqyXPCq4orXlK5rH2m/ku4 qwUQsbwVqncVgHl6AGdhIPBl9TKowGzobqNRUXtAXSTAeNuz1LSf+4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=mgTja+BAH+0zPmWmuCF8gRr5vG4=; b=pq/yP+8ehG6qy1ipB2A13u5bmY6x CiV8RmjGY7LXrZbKNa4hSfiBhuuMRUiwxRlH/5fBhNTLFP6mpQbbjJwBMOoruAor 47lKQ0G0krFczEjwZ/k5lM6xGpiiq1lq8xGk+1E+iY/1iWLkThnqqpWnoc4wvvdV lUNYG00HVIRbu7Y= Received: (qmail 111418 invoked by alias); 15 Feb 2019 14:11:44 -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 111387 invoked by uid 89); 15 Feb 2019 14:11:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=cfi_offset, 7346, our X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=LZmTjnYNjD+c/g3pGQg4EPa8hxXN8fX76Tkq7i8tYp4=; b=VynUD2tmUVifQSJynwjppR6LqjlbobGfstlCTLNC/qVU+s9lkprq5aQR5t0piifrs+ W5cW00vKbTBaUBH9K/+HbJsDOtGJ36P2xuaaCoVtGM/Pgh+Nh670SHLp6o1aR5dvfE6B gFSwU3g/zPT+wlFfLyuVXFVYXbGNkAurI6WZPNAOxq5puBLMsHSqDJuJVJrh3sWpRAim eNV1bfJEQvqke6Win3n+yo+K/cHUtYm5ZXZR4ItzquRLBjYgW2I892I5aaBE32Mh6nnG 4fN+fq8dnNZrhezqbrLQS8eBbAjQ8ITK2m/PRmdB+wR6v2vVq5Eq48BZyGsxcLlsuhK0 1ZYg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/2] powerpc: Remove rt_sigreturn usage on context function Date: Fri, 15 Feb 2019 12:11:31 -0200 Message-Id: <20190215141132.24404-1-adhemerval.zanella@linaro.org> As described in a recent glibc thread [1], the rt_sigreturn syscall on setcontext and swapcontext is not used on default use and its intention is no really supported since neither setcontext nor swapcontext are async-signal-safe. Checked on powerpc64-linux-gnu and powerpc-linux-gnu * sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S: Remove rt_sigreturn call. * sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S: Likewie. * sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S: Likewise. [1] https://sourceware.org/ml/libc-alpha/2019-02/msg00367.html --- .../powerpc/powerpc32/setcontext-common.S | 22 ------- .../powerpc/powerpc32/swapcontext-common.S | 23 -------- .../sysv/linux/powerpc/powerpc64/setcontext.S | 59 ------------------- .../linux/powerpc/powerpc64/swapcontext.S | 58 ------------------ 4 files changed, 162 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S index 68c6321a9d..47235dd0cb 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S @@ -47,21 +47,6 @@ ENTRY(__CONTEXT_FUNC_NAME) cfi_offset(r31,-4) lwz r31,_UC_REGS_PTR(r3) - /* - * If this ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne 4f /* L(do_sigret) */ - /* Restore the signal mask */ li r5,0 addi r4,r3,_UC_SIGMASK @@ -296,11 +281,4 @@ ENTRY(__CONTEXT_FUNC_NAME) mtlr r0 blr - -4: /* L(do_sigret): */ - addi r1,r3,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ - END (__CONTEXT_FUNC_NAME) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S index 0ef0ad7e35..e0fd249615 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S @@ -280,23 +280,6 @@ ENTRY(__CONTEXT_FUNC_NAME) cmpwi r3,0 bne 3f /* L(error_exit) */ - /* - * If the new ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * r0, xer, ctr. We don't restore r2 since it will be used as - * the TLS pointer. - */ - lwz r4,_FRAME_PARM_SAVE2(r1) - lwz r31,_UC_REGS_PTR(r4) - lwz r0,_UC_GREGS+(PT_MSR*4)(r31) - cmpwi r0,0 - bne 4f /* L(do_sigret) */ - #ifdef __CONTEXT_ENABLE_FPRS # ifdef __CONTEXT_ENABLE_VRS @@ -520,10 +503,4 @@ ENTRY(__CONTEXT_FUNC_NAME) mtlr r0 blr -4:/*L(do_sigret):*/ - addi r1,r4,-0xd0 - li r0,SYS_ify(rt_sigreturn) - sc - /* NOTREACHED */ - END(__CONTEXT_FUNC_NAME) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S index 4e3ab6647a..d311a22c58 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S @@ -46,20 +46,6 @@ ENTRY(__novec_setcontext) cfi_adjust_cfa_offset (128) mr r31,r3 -/* - * If this ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * msr and ctr. We don't restore r13 since it will be used as - * the TLS pointer. */ - ld r0,(SIGCONTEXT_GP_REGS+(PT_MSR*8))(r31) - cmpdi r0,0 - bne L(nv_do_sigret) - li r5,0 addi r4,r3,UCONTEXT_SIGMASK li r3,SIG_SETMASK @@ -200,22 +186,6 @@ L(nv_error_exit): mtlr r0 ld r31,-8(r1) blr - - /* At this point we assume that the ucontext was created by a - rt_signal and we should use rt_sigreturn to restore the original - state. As of the 2.4.21 kernel the ucontext is the first thing - (offset 0) in the rt_signal frame and rt_sigreturn expects the - ucontext address in R1. Normally the rt-signal trampoline handles - this by popping dummy frame before the rt_signal syscall. In our - case the stack may not be in its original (signal handler return with - R1 pointing at the dummy frame) state. We do have the ucontext - address in R3, so simply copy R3 to R1 before the syscall. */ -L(nv_do_sigret): - mr r1,r3, - li r0,SYS_ify(rt_sigreturn) - sc - /* No return. */ - PSEUDO_END(__novec_setcontext) compat_symbol (libc, __novec_setcontext, setcontext, GLIBC_2_3) @@ -235,20 +205,6 @@ ENTRY(__setcontext) cfi_adjust_cfa_offset (128) mr r31,r3 -/* - * If this ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * msr and ctr. We don't restore r13 since it will be used as - * the TLS pointer. */ - ld r0,(SIGCONTEXT_GP_REGS+(PT_MSR*8))(r31) - cmpdi r0,0 - bne L(do_sigret) - li r5,0 addi r4,r3,UCONTEXT_SIGMASK li r3,SIG_SETMASK @@ -493,21 +449,6 @@ L(error_exit): ld r31,-8(r1) blr - /* At this point we assume that the ucontext was created by a - rt_signal and we should use rt_sigreturn to restore the original - state. As of the 2.4.21 kernel the ucontext is the first thing - (offset 0) in the rt_signal frame and rt_sigreturn expects the - ucontext address in R1. Normally the rt-signal trampoline handles - this by popping dummy frame before the rt_signal syscall. In our - case the stack may not be in its original (signal handler return with - R1 pointing at the dummy frame) state. We do have the ucontext - address in R3, so simply copy R3 to R1 before the syscall. */ -L(do_sigret): - mr r1,r3, - li r0,SYS_ify(rt_sigreturn) - sc - /* No return. */ - PSEUDO_END(__setcontext) versioned_symbol (libc, __setcontext, setcontext, GLIBC_2_3_4) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S index af5b108e8c..6d07b1c36b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S @@ -149,20 +149,6 @@ ENTRY(__novec_swapcontext) cmpdi r3,0 bne L(nv_error_exit) -/* - * If this new ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * msr and ctr. We don't restore r13 since it will be used as - * the TLS pointer. */ - ld r0,(SIGCONTEXT_GP_REGS+(PT_MSR*8))(r31) - cmpdi r0,0 - bne L(nv_do_sigret) - ld r8,.LC__dl_hwcap@toc(r2) # ifdef SHARED /* Load _rtld-global._dl_hwcap. */ @@ -288,21 +274,6 @@ L(nv_error_exit): ld r31,-8(r1) blr - /* At this point we assume that the ucontext was created by a - rt_signal and we should use rt_sigreturn to restore the original - state. As of the 2.4.21 kernel the ucontext is the first thing - (offset 0) in the rt_signal frame and rt_sigreturn expects the - ucontext address in R1. Normally the rt-signal trampoline handles - this by popping dummy frame before the rt_signal syscall. In our - case the stack may not be in its original (signal handler return with - R1 pointing at the dummy frame) state. We do have the ucontext - address in R3, so simply copy R3 to R1 before the syscall. */ -L(nv_do_sigret): - mr r1,r3, - li r0,SYS_ify(rt_sigreturn) - sc - /* No return. */ - PSEUDO_END(__novec_swapcontext) compat_symbol (libc, __novec_swapcontext, swapcontext, GLIBC_2_3) @@ -535,20 +506,6 @@ L(has_no_vec): cmpdi r3,0 bne L(error_exit) -/* - * If this new ucontext refers to the point where we were interrupted - * by a signal, we have to use the rt_sigreturn system call to - * return to the context so we get both LR and CTR restored. - * - * Otherwise, the context we are restoring is either just after - * a procedure call (getcontext/swapcontext) or at the beginning - * of a procedure call (makecontext), so we don't need to restore - * msr and ctr. We don't restore r13 since it will be used as - * the TLS pointer. */ - ld r0,(SIGCONTEXT_GP_REGS+(PT_MSR*8))(r31) - cmpdi r0,0 - bne L(do_sigret) - ld r8,.LC__dl_hwcap@toc(r2) ld r10,(SIGCONTEXT_V_REGS_PTR)(r31) # ifdef SHARED @@ -777,21 +734,6 @@ L(error_exit): ld r31,-8(r1) blr - /* At this point we assume that the ucontext was created by a - rt_signal and we should use rt_sigreturn to restore the original - state. As of the 2.4.21 kernel the ucontext is the first thing - (offset 0) in the rt_signal frame and rt_sigreturn expects the - ucontext address in R1. Normally the rt-signal trampoline handles - this by popping dummy frame before the rt_signal syscall. In our - case the stack may not be in its original (signal handler return with - R1 pointing at the dummy frame) state. We do have the ucontext - address in R3, so simply copy R3 to R1 before the syscall. */ -L(do_sigret): - mr r1,r3, - li r0,SYS_ify(rt_sigreturn) - sc - /* No return. */ - PSEUDO_END(__swapcontext) versioned_symbol (libc, __swapcontext, swapcontext, GLIBC_2_3_4) From patchwork Fri Feb 15 14:11:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 158522 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp750142jaa; Fri, 15 Feb 2019 06:12:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IZYdSxRiM45ROHsWMdCG0m96FSduFL54DtRoTJyIqWSj+l+PAvQNVjaaLgdFtHqBlk1V529 X-Received: by 2002:a62:20c9:: with SMTP id m70mr9134259pfj.118.1550239922279; Fri, 15 Feb 2019 06:12:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550239922; cv=none; d=google.com; s=arc-20160816; b=t4IRCcaKAOLHKXCgAR+6cS24H6NjAXnxhlw2/emEIgWG9GVNbDTgPC1cWrEGUBTCVh EIVO+0worWDHliQK9oXofa0thR7Z8wu+jt4yVS9ZneFsGtq/EdP6du5l6G/tVdToKIkx sJ3BjcFIqih+FEfssObKqtx52oXYTr/p9OgZsCHL9OuSWV5oeKcKLVgtOJ8VGaT4cZVC 4Fsugj5+oO9zg6mhi3rQ8dTOYH6VsL7vp/oIwuJ8srNxODYMrxYdJisvBMRRC4FLnOqP oaSFRIlXAbDdnd4BpZwoWOypAXV14CVEt625WCidSxdVKFuCy8eZZ2a0xfOFW8FKWMZW 5JIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=K/SdvDm8BLtOxyXXWg8ySDJ2aAK+ZnSlx3NtevCNfKs=; b=mE7C9RpM3QP/iKDt48dFfttvbxqin/BGTOPCh8ZGdFSCpcZqGv0Z20FdtP+Q/4xij/ 32RsXNyPJzLn87s0r+JDzQSSjtvx1Uje/mNuL2tJ4qVyqkjXzB0LLFliFQxhBonMxO7z 9eGOqnKmDVDj/lFEgDZVFKolmVJXqj/iy2yXwPUBFpSAjaQX11SoI/0iH8CUqs6qLhMk z203lj6mtOZq6xwSjMZgxO24MvfGhoAXfC7mH9Euyr3fki4ZHXovFkjvYgKpCNXiTgbH Qti2AbmviCkWmCH14aCXx+ivHGre5RgMxOE3y0xHICC6QKWjSgRlS9O3eGUTuLMwkzYS sSRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=R9NFTVAD; dkim=pass header.i=@linaro.org header.s=google header.b=XBQq0KwC; spf=pass (google.com: domain of libc-alpha-return-100072-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100072-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g12si5712652pgd.567.2019.02.15.06.12.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Feb 2019 06:12:02 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-100072-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=R9NFTVAD; dkim=pass header.i=@linaro.org header.s=google header.b=XBQq0KwC; spf=pass (google.com: domain of libc-alpha-return-100072-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-100072-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Rb693GlgRp/xrsshOcwGgLkhxiEfo29 ezCHw5INlrIZkmIlsv8cNw7vhPSG/OWU6cKQ57GrlQXAlh7AearJdO/rUgiynSmq 95gaoz8H45y31Z58MKT+Pm1hDLQaGwnqASqTSzHoCqAfSA7MTUg00zodM6RMH5CI W+MNOFwC5ei4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=dxpdyUdPbYWueDdwoAIrT3dOe9A=; b=R9NFT VADvwoaybZamVlpdrpsHQV1oi+/MuLbIrbR5trK+WU++l1JLCcUKO0uOSy0XJkrc BBhK6fWqaGp9JICF1HkxNmo0Df7Lv7Pi9DyMQdE+1XEwXrM7CmVt7PDeMXnvIoZj yvicunZ1K53f3yCzDpd2+essc87wgR+cHmIGbc= Received: (qmail 111432 invoked by alias); 15 Feb 2019 14:11:44 -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 111397 invoked by uid 89); 15 Feb 2019 14:11:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:4479 X-HELO: mail-qk1-f179.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=K/SdvDm8BLtOxyXXWg8ySDJ2aAK+ZnSlx3NtevCNfKs=; b=XBQq0KwCGQKbrBlSMjfxvHgICQPZtRlQqQ6TDWWK7cepr/3CxAJ6LIVoAnklFKSrXp sE0qEGMuGekdPiKwrjbx9GOi3/rZX6TqxZooPy3TkaebztVD5twHT+gopQJdLDGZj1es 7EQFhyTcd+dVoFVp/zbdq+E8DK7fFodZxeJA9dEwnK6u6j1fsZQjzK6XLbrSxagx8wPr 23fixtJ2yA77LZLCxG6r5GK1M4T4lLIyf0UtBufVKzr86e8f5oW+Vp7MUnRkyw2FN7Da jpMH4jFrmt6B6SqSSp7WXUpwZ8csZTI2PWOrsg9qF2eCI0tHJ8hdyrDflouLO9Ybahm5 DAvw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 2/2] mips: Remove rt_sigreturn usage on context function Date: Fri, 15 Feb 2019 12:11:32 -0200 Message-Id: <20190215141132.24404-2-adhemerval.zanella@linaro.org> In-Reply-To: <20190215141132.24404-1-adhemerval.zanella@linaro.org> References: <20190215141132.24404-1-adhemerval.zanella@linaro.org> Similar to powerpc, mips also issues rt_sigreturn for setcontext case the v0 value saved is not the one set by setcontext or makecontext. As for powerpc, it is intention is no really supported since setcontext is not async-signal-safe. Checked the context tests on mips64-linux-gnu and mips-linux-gnu. * sysdeps/unix/sysv/linux/mips/getcontext.S (__getcontext): Remove the magic flag store. * sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext): Likewise. * sysdeps/unix/sysv/linux/mips/swapcontext.S (__swapcontext): Likewise. * sysdeps/unix/sysv/linux/mips/setcontext.S (__setcontext): Remove rt_sigreturn call. --- sysdeps/unix/sysv/linux/mips/getcontext.S | 5 --- sysdeps/unix/sysv/linux/mips/makecontext.S | 5 --- sysdeps/unix/sysv/linux/mips/setcontext.S | 38 ---------------------- sysdeps/unix/sysv/linux/mips/swapcontext.S | 5 --- 4 files changed, 53 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/mips/getcontext.S b/sysdeps/unix/sysv/linux/mips/getcontext.S index 4f7f89ee9a..015bd5bff6 100644 --- a/sysdeps/unix/sysv/linux/mips/getcontext.S +++ b/sysdeps/unix/sysv/linux/mips/getcontext.S @@ -78,11 +78,6 @@ NESTED (__getcontext, FRAMESZ, ra) .set at #endif - /* Store a magic flag. */ - li v1, 1 - /* zero */ - REG_S v1, (MCONTEXT_GREGOFF + 0 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) - REG_S s0, (MCONTEXT_GREGOFF + 16 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) REG_S s1, (MCONTEXT_GREGOFF + 17 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) REG_S s2, (MCONTEXT_GREGOFF + 18 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) diff --git a/sysdeps/unix/sysv/linux/mips/makecontext.S b/sysdeps/unix/sysv/linux/mips/makecontext.S index 4439fec3ff..3f40f7c9f2 100644 --- a/sysdeps/unix/sysv/linux/mips/makecontext.S +++ b/sysdeps/unix/sysv/linux/mips/makecontext.S @@ -93,11 +93,6 @@ NESTED (__makecontext, FRAMESZ, ra) REG_S a7, A7OFF(sp) #endif - /* Store a magic flag. */ - li v1, 1 - /* zero */ - REG_S v1, (MCONTEXT_GREGOFF + 0 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) - /* Set up the stack. */ PTR_L t0, STACK_SP(a0) PTR_L t2, STACK_SIZE(a0) diff --git a/sysdeps/unix/sysv/linux/mips/setcontext.S b/sysdeps/unix/sysv/linux/mips/setcontext.S index b6553bdb5e..98afe6cbac 100644 --- a/sysdeps/unix/sysv/linux/mips/setcontext.S +++ b/sysdeps/unix/sysv/linux/mips/setcontext.S @@ -77,12 +77,6 @@ NESTED (__setcontext, FRAMESZ, ra) .set at #endif - /* Check for the magic flag. */ - li v0, 1 - /* zero */ - REG_L v1, (MCONTEXT_GREGOFF + 0 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) - bne v0, v1, 98f - REG_S a0, A0OFF(sp) /* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8) */ @@ -154,38 +148,6 @@ NESTED (__setcontext, FRAMESZ, ra) move v0, zero jr t9 -98: - /* This is a context obtained from a signal handler. - Perform a full restore by pushing the context - passed onto a simulated signal frame on the stack - and call the signal return syscall as if a signal - handler exited normally. */ - PTR_ADDIU sp, -((RT_SIGFRAME_SIZE + ALSZ) & ALMASK) - cfi_adjust_cfa_offset ((RT_SIGFRAME_SIZE + ALSZ) & ALMASK) - - /* Only ucontext is referred to from rt_sigreturn, - copy it. */ - PTR_ADDIU t1, sp, RT_SIGFRAME_UCONTEXT - li t3, ((UCONTEXT_SIZE + SZREG - 1) / SZREG) - 1 -0: - REG_L t2, (a0) - PTR_ADDIU a0, SZREG - REG_S t2, (t1) - PTR_ADDIU t1, SZREG - .set noreorder - bgtz t3, 0b - addiu t3, -1 - .set reorder - -/* rt_sigreturn () -- no arguments, sp points to struct rt_sigframe. */ - li v0, SYS_ify (rt_sigreturn) - syscall - - /* Restore the stack and fall through to the error - path. Successful rt_sigreturn never returns to - its calling place. */ - PTR_ADDIU sp, ((RT_SIGFRAME_SIZE + ALSZ) & ALMASK) - cfi_adjust_cfa_offset (-((RT_SIGFRAME_SIZE + ALSZ) & ALMASK)) 99: #ifdef __PIC__ PTR_LA t9, JUMPTARGET (__syscall_error) diff --git a/sysdeps/unix/sysv/linux/mips/swapcontext.S b/sysdeps/unix/sysv/linux/mips/swapcontext.S index 9c68961345..6612e757cd 100644 --- a/sysdeps/unix/sysv/linux/mips/swapcontext.S +++ b/sysdeps/unix/sysv/linux/mips/swapcontext.S @@ -87,11 +87,6 @@ NESTED (__swapcontext, FRAMESZ, ra) .set at #endif - /* Store a magic flag. */ - li v1, 1 - /* zero */ - REG_S v1, (MCONTEXT_GREGOFF + 0 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) - REG_S s0, (MCONTEXT_GREGOFF + 16 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) REG_S s1, (MCONTEXT_GREGOFF + 17 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0) REG_S s2, (MCONTEXT_GREGOFF + 18 * MCONTEXT_GREGSZ + MCONTEXT_GREGS)(a0)