From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804AbdCAHbZ (ORCPT ); Wed, 1 Mar 2017 02:31:25 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:42415 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750743AbdCAHbV (ORCPT ); Wed, 1 Mar 2017 02:31:21 -0500 From: Matt Redfearn To: Ralf Baechle CC: , Matt Redfearn , Marcin Nowakowski , , "Maciej W. Rozycki" , Paul Burton Subject: [PATCH 2/4] MIPS: microMIPS: Fix decoding of addiusp instruction Date: Tue, 28 Feb 2017 15:37:56 +0000 Message-ID: <1488296279-23057-3-git-send-email-matt.redfearn@imgtec.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488296279-23057-1-git-send-email-matt.redfearn@imgtec.com> References: <1488296279-23057-1-git-send-email-matt.redfearn@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.150.130.83] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 34c2f668d0f6 ("MIPS: microMIPS: Add unaligned access support.") added handling of microMIPS instructions to manipulate the stack pointer. Unfortunately the decoding of the addiusp instruction was incorrect, and performed a left shift by 2 bits to the raw immediate, rather than decoding the immediate and then performing the shift, as documented in the ISA. This led to incomplete stack traces, due to incorrect frame sizes being calculated. For example the instruction: 801faee0 : 801faee0: 4e25 addiu sp,sp,-952 As decoded by objdump, would be interpreted by the existing code as having manipulated the stack pointer by +1096. Fix this by changing the order of decoding the immediate and applying the left shift. Fixes: 34c2f668d0f6 ("MIPS: microMIPS: Add unaligned access support.") Signed-off-by: Matt Redfearn --- arch/mips/kernel/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 5b1e932ae973..6ba5b775579c 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -386,8 +386,9 @@ static int get_frame_info(struct mips_frame_info *info) if (ip->halfword[0] & mm_addiusp_func) { - tmp = (((ip->halfword[0] >> 1) & 0x1ff) << 2); - info->frame_size = -(signed short)(tmp | ((tmp & 0x100) ? 0xfe00 : 0)); + tmp = (ip->halfword[0] >> 1) & 0x1ff; + tmp = tmp | ((tmp & 0x100) ? 0xfe00 : 0); + info->frame_size = -(signed short)(tmp << 2); } else { tmp = (ip->halfword[0] >> 1); info->frame_size = -(signed short)(tmp & 0xf); -- 2.7.4