From patchwork Thu Sep 13 23:27:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 969585 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42BFGP2Z4fz9s3l for ; Fri, 14 Sep 2018 09:29:01 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NwkyNFlZ"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42BFGP10phzF3TP for ; Fri, 14 Sep 2018 09:29:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NwkyNFlZ"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=amodra@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NwkyNFlZ"; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42BFDL1pCPzF3T9 for ; Fri, 14 Sep 2018 09:27:10 +1000 (AEST) Received: by mail-pl1-x641.google.com with SMTP id g23-v6so3273834plq.9 for ; Thu, 13 Sep 2018 16:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=OS40UMdMEWuPpQdWmuBeNil0num1VSkSjdE2VWrOIUw=; b=NwkyNFlZAF/+goZ734VM1q5ANYya7O5T4zJrvf3rE10iQW9/Mesac4d6nRy+0TwEd4 GdR9sNYCpOqwQHjdOGtcaAOY2/5iOC47x6DaofToN5KChegFjIfT3OvB+O8UQjBWAC5J E2tIRDPcYl9Lb3SlSp1isYx7MXwgZ5N8t4PUgFJ/FxRkN6fM6df2w+npMKPssNqhRXXD rdZ09WkKZXFshllSFPkdpHIZ3JpJFQEywz82cuWjkqNHX2gUqm8MlfB6Ulw2ZOpRnIq6 q6ND1f0siUvJHqXbiViLKZAJ0MiBXI3JRxe9HgGFCakHWE5C/ppylZGyzy6/I+XmsIxb PLpQ== 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:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=OS40UMdMEWuPpQdWmuBeNil0num1VSkSjdE2VWrOIUw=; b=Wl6kKEgmqXU+6qcdGMrH7Wq+WL4l02lG8wqkneTuGIulElEI6x7NL+kdUMm5Aia+80 MgwVRlUS2wXTfnAGjeZXqM87kxaXnOsKod7yRUjMfZxWAsXvOLBKMBuvD88Vtf5OFboT DEsJIE/nzKEPdXuT/de3OI6ijA88ov8pRYZa8bCWXt+nTT09xQin0ysxyA41ozEyT9N7 h3ejfR0kg5FP5pQVBKai6eeoUD+cbCuqAHXY7vf3f5+Phodkrw2jNqheKagbaOaQWeb4 MST89Zy98BvCIn9aZ49/BGDg9e6EW4GTupIrtGN0U1C2HCUUqjNOQSfOlV2yZqLHJ4lB Iqrg== X-Gm-Message-State: APzg51ACI5QxsuyvlNzM9SCK28xeXgkRATDIyOcr2KCv+9RaOSt3lwhE 2LeINPz4gsAKWur7QslkOrXS4W5Q X-Google-Smtp-Source: ANB0VdbELa7q5ZWu+f5cX2rE+3yGLnPoh7g0nZkxwytAo4omCjwnPCevaVL3GTyTI3LgY5FIGV+VPg== X-Received: by 2002:a17:902:b7c3:: with SMTP id v3-v6mr9315069plz.238.1536881229285; Thu, 13 Sep 2018 16:27:09 -0700 (PDT) Received: from bubble.grove.modra.org ([58.175.241.133]) by smtp.gmail.com with ESMTPSA id w12-v6sm7044321pfd.110.2018.09.13.16.27.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Sep 2018 16:27:08 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 546A0802D5; Fri, 14 Sep 2018 08:57:04 +0930 (ACST) Date: Fri, 14 Sep 2018 08:57:04 +0930 From: Alan Modra To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH] Correct PowerPC VDSO call frame info Message-ID: <20180913232704.GL3174@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Neuling Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" There is control flow in __kernel_clock_gettime that reaches label 99 without saving lr in r12. CFI info however is interpreted by the unwinder without reference to control flow: It's a simple matter of "Execute all the CFI opcodes up to the current address". That means the unwinder thinks r12 contains the return address at label 99. Disabuse it of that notion by resetting CFI for the return address at label 99. Note that the ".cfi_restore lr" could have gone anywhere from the "mtlr r12" a few instructions earlier to the instruction at label 99. I put the CFI as late as possible, because in general that's best practice (and if possible grouped with other CFI in order to reduce the number of CFI opcodes executed when unwinding). Using r12 as the return address is perfectly fine after the "mtlr r12" since r12 on that code path still contains the return address. __get_datapage also has a CFI error. That function temporarily saves lr in r0, and reflects that fact with ".cfi_register lr,r0". A later use of r0 means the CFI at that point isn't correct, as r0 no longer contains the return address. Fix that too. Signed-off-by: Alan Modra Tested-by: Reza Arbab diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S index 3745113fcc65..2a7eb5452aba 100644 --- a/arch/powerpc/kernel/vdso32/datapage.S +++ b/arch/powerpc/kernel/vdso32/datapage.S @@ -37,6 +37,7 @@ data_page_branch: mtlr r0 addi r3, r3, __kernel_datapage_offset-data_page_branch lwz r0,0(r3) + .cfi_restore lr add r3,r0,r3 blr .cfi_endproc diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index 769c2624e0a6..1e0bc5955a40 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -139,6 +139,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) */ 99: li r0,__NR_clock_gettime + .cfi_restore lr sc blr .cfi_endproc diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S index abf17feffe40..bf9668691511 100644 --- a/arch/powerpc/kernel/vdso64/datapage.S +++ b/arch/powerpc/kernel/vdso64/datapage.S @@ -37,6 +37,7 @@ data_page_branch: mtlr r0 addi r3, r3, __kernel_datapage_offset-data_page_branch lwz r0,0(r3) + .cfi_restore lr add r3,r0,r3 blr .cfi_endproc diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S index c002adcc694c..a4ed9edfd5f0 100644 --- a/arch/powerpc/kernel/vdso64/gettimeofday.S +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S @@ -169,6 +169,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) */ 99: li r0,__NR_clock_gettime + .cfi_restore lr sc blr .cfi_endproc