From patchwork Fri Oct 20 13:06:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 828659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-86190-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xm65SrT4"; dkim-atps=neutral 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 3yJQzn0xDhz9t7V for ; Sat, 21 Oct 2017 00:06:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=iiuwzojELUUnyGlWgtqkYLhWT1hIv FvDFmU2znqw3kWIv6fftO4+kD8kuB2Gu1MBfYsgY6Qqk4xxVHla/2gYlXBE2Zjao yzzpI5ITi5qTgvq+KukOWI/hqBkNi8XfzfcuKXS9KUlyr/9IrkXR3jmTn/DYsneL J+DSGifN9trR2A= 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:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=f3d6J2BQENibQaLEEKVyXlenhuc=; b=xm6 5SrT41tYgGNquyX49vhnZz1drlh9SSU6KG+89pK9LiC+mrirRwmmHBkb+vySUMyx 2+wJkOxyymIeaNzoGFLMyYdiZWNufMCX7c1ytx95Z1PqoVLFZhjBWKYGIBCFP28i YhnVn5IN3BiGlW37QSSBVwWCtUuIgml0SUWuNojg= Received: (qmail 123215 invoked by alias); 20 Oct 2017 13:06:36 -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 122661 invoked by uid 89); 20 Oct 2017 13:06:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, 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=24123 X-HELO: mail-pf0-f180.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=H6X+4XcV859oKgY9vRFOUQK4UZ5oi0ZQZlkPQLKAXOU=; b=Zkh4y2KM+gjo/9HADx4ehWG+LcH39X3HR4hJ/I/DJxyGNlyEOssVrIBv5wKp0DZu/p 8smtcFIfzuwhAXVsc49anLtOPLR/Gi+fNGVlO2CSCdhDdIFYwX1pDTb0pyRI4qZ5cP2H 1I3v8DS6nGK1G+D1Mx/ZD06lAIHulcNjXIOXs9EM7yznTvIJghRXEk2ZV3ytQ6C55iWK /Hgu4eRIslnRF5CQdvEbZMWR6IK3hnWYwCRpm1+kas5vdXNHIOOdkLZmPWlYSRllJpd1 5RyMYGn6QWojSHkkMk1A7cCts0+Yn98k2XKqTzrX2hcNVaLat8l9nKgY7hh98/JUiA/p rxVA== X-Gm-Message-State: AMCzsaVTLAgVy2pu3y9xLndpw3nGh3jnR1URIEObPntoirqfYVCcVEQH TW1xarjLK4hkuJMI4a1GIRI0Kw== X-Google-Smtp-Source: ABhQp+RT1HGL7BpE42kQlbbLHGBdhweyMgbSpbA7aKHJHazZo85aQumuLPy4L00Idfdpx/y2mH+rPA== X-Received: by 10.99.134.200 with SMTP id x191mr4356033pgd.86.1508504792446; Fri, 20 Oct 2017 06:06:32 -0700 (PDT) Date: Fri, 20 Oct 2017 23:36:27 +1030 From: Alan Modra To: libc-alpha@sourceware.org Subject: PowerPC64 power8 strncpy cfi fixes Message-ID: <20171020130627.GC27132@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) cfi info for stack adjust needs to be on the insn doing the adjust. cfi describing register saves can be anywhere after the save insn but before the reg is altered. Fewer locations with cfi result in smaller cfi programs and possibly slightly faster exception handling. Thus the LR cfi_offset move. The idea behind ajusting sp after restoring regs is to break a register dependency chain, in this case not be using r1 immediately after it is modified. The missing LR cfi_restore meant that code after the blr, unaligned_lt_16 and other labels, would have cfi that said LR was at cfa+16, but that code is reached without LR being saved. * sysdeps/powerpc/powerpc64/power8/strncpy.S: Move LR cfi. Adjust stack after restoring regs. Add missing LR cfi_restore. Reviewed-by: Tulio Magno Quites Machado Filho diff --git a/sysdeps/powerpc/powerpc64/power8/strncpy.S b/sysdeps/powerpc/powerpc64/power8/strncpy.S index 150290a..c55e62d 100644 --- a/sysdeps/powerpc/powerpc64/power8/strncpy.S +++ b/sysdeps/powerpc/powerpc64/power8/strncpy.S @@ -241,23 +241,18 @@ L(zero_pad_start_1): /* Save the link register. */ mflr r0 std r0,16(r1) - cfi_offset(lr, 16) /* Create the stack frame. */ stdu r1,-FRAMESIZE(r1) cfi_adjust_cfa_offset(FRAMESIZE) + cfi_offset(lr, 16) bl MEMSET #ifndef MEMSET_is_local nop #endif - /* Restore the stack frame. */ - addi r1,r1,FRAMESIZE - cfi_adjust_cfa_offset(-FRAMESIZE) - /* Restore the link register. */ - ld r0,16(r1) - mtlr r0 + ld r0,FRAMESIZE+16(r1) #ifndef USE_AS_STPNCPY mr r3,r30 /* Restore the return value of strncpy, i.e.: @@ -266,12 +261,18 @@ L(zero_pad_start_1): #endif /* Restore non-volatile registers and return. */ - ld r26,-48(r1) - ld r27,-40(r1) - ld r28,-32(r1) - ld r29,-24(r1) - ld r30,-16(r1) - ld r31,-8(r1) + ld r26,FRAMESIZE-48(r1) + ld r27,FRAMESIZE-40(r1) + ld r28,FRAMESIZE-32(r1) + ld r29,FRAMESIZE-24(r1) + ld r30,FRAMESIZE-16(r1) + ld r31,FRAMESIZE-8(r1) + /* Restore the stack frame. */ + addi r1,r1,FRAMESIZE + cfi_adjust_cfa_offset(-FRAMESIZE) + /* Restore the link register. */ + mtlr r0 + cfi_restore(lr) blr /* The common case where [src]+16 will not cross a 4K page boundary.