From patchwork Thu Sep 25 20:53:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 396017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 39BB814017E for ; Fri, 3 Oct 2014 02:00:08 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:from:date:to:subject:mime-version :content-type; q=dns; s=default; b=f18rUAdmnpAzyLqw/bYlWo9HTow4p 15ryGwGinXfolWa1Taq3XooJUR7WEC+CHoj/3nmelTplZcn/wILYT1bNRPGkD91m LJLOgy70M60kUYa62O/oO/uMX3Ed/RUAo/D3ptNCHxK4YeVmI5jAs1dYa4adl/rc iEOMvynfXxlOs0= 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:message-id:from:date:to:subject:mime-version :content-type; s=default; bh=qHCOhHGhAObSjGRCxz/rHSbW9OI=; b=bPR dHxz3SbmEuW3KsVqg3yX/vNCTvaqnCqueFryh4SEQOJdctlcQcCwzjFRTX7CLfB6 sOXy6Vkcc6OMXY+2dV3CV5Q9vGYjXQwdU2b013JEyfsfPIpwxtV1yC2sVJcSLD76 rwNWoCLll+gsYT2NDfcMaBSJ3cwX1hclwVqmPXYs= Received: (qmail 3499 invoked by alias); 2 Oct 2014 15:59:29 -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 3459 invoked by uid 89); 2 Oct 2014 15:59:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, DATE_IN_PAST_96_XX, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: USMAMAIL.TILERA.COM Message-ID: <201410021559.s92FxQG8020870@farm-0002.internal.tilera.com> From: Chris Metcalf Date: Thu, 25 Sep 2014 16:53:03 -0400 To: Subject: [PATCH] tile: make the prolog of clone() more conformant MIME-Version: 1.0 With this change we properly set up the frame first, and tear it down last, doing argument checking only when the frame is set up. --- sysdeps/unix/sysv/linux/tile/clone.S | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 2014-10-02 Chris Metcalf * sysdeps/unix/sysv/linux/tile/clone.S (__clone): Fix code to set up frame more cleanly. diff --git a/sysdeps/unix/sysv/linux/tile/clone.S b/sysdeps/unix/sysv/linux/tile/clone.S index f48dba523c7c..0e109f849e95 100644 --- a/sysdeps/unix/sysv/linux/tile/clone.S +++ b/sysdeps/unix/sysv/linux/tile/clone.S @@ -41,10 +41,6 @@ .text ENTRY (__clone) - /* sanity check arguments */ - BEQZ r0, .Linvalid - BEQZ r1, .Linvalid - /* Create a stack frame so we can pass callee-saves to new task. */ { move r10, sp @@ -71,6 +67,10 @@ ENTRY (__clone) ST r11, r32 cfi_offset (r32, FRAME_R32 - FRAME_SIZE) + /* sanity check arguments */ + BEQZ r0, .Linvalid + BEQZ r1, .Linvalid + /* Make sure child stack is properly aligned, and set up the top frame so that we can call out of it immediately in the child. Setting it up here means we fault in the parent if @@ -120,6 +120,7 @@ ENTRY (__clone) swint1 BEQZ r0, .Lthread_start /* If in child task. */ +.Ldone: /* Restore the callee-saved registers and return. */ ADDLI_PTR lr, sp, FRAME_SIZE { @@ -149,7 +150,7 @@ ENTRY (__clone) .Linvalid: { movei r1, EINVAL - j SYSCALL_ERROR_NAME + j .Ldone } /* This function expects to receive: