From patchwork Mon Sep 21 09:12:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 11789007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63479112C for ; Mon, 21 Sep 2020 09:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 409E720874 for ; Mon, 21 Sep 2020 09:13:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rrgZr11H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726405AbgIUJNy (ORCPT ); Mon, 21 Sep 2020 05:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbgIUJNx (ORCPT ); Mon, 21 Sep 2020 05:13:53 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3291C061755 for ; Mon, 21 Sep 2020 02:13:53 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a9so7125891pjg.1 for ; Mon, 21 Sep 2020 02:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VairmXzYfCn1dnkA9xHTGhcEUlhFriElxDnD3N6Npyk=; b=rrgZr11Hv8ky9SeNV2+fSdSM4bwfDS5HPPTELoI7cUWvthQ9xnzAL99SNyyvLo8NiC G0yIepumSUOj2bBMDTvM8qb4RZCVin1fQ5KYqjwSKE8BIW+ku2i5x3ISinRlAbFgro8b 4AAHoVofzP/rggzAxc6VCKmfVXW8Dxgo8zOSw2ND2XpdAinw33kYoI7xSJBUQvfVkY1N gmYv1SvJVOA7LRsmDJq487Iq2qZbgdGlDAE32aYqpYDwW2wxMreGppNEdyrhv4+jObL0 XrBaP6iAYwTI5nwRbQ3ZFVh8m/ExasiXFAHw8Mb5KhZKO1GHK44hl3uRBgBupeTOnY+Y QAYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VairmXzYfCn1dnkA9xHTGhcEUlhFriElxDnD3N6Npyk=; b=fpYc/PrCXWCs34Vl3aYGiovhDInoHRq3vfrMfYeems2JR1SDhyWI3HJNvp2U5NCjgX PmWbsFW2wcWwrFQbHCAgHN3dqsmntRWaQ2uNB/W4WJiJLrg5DV1Rsl06tB2TLiSdgubj DLfCC0773THw4Ztnvamgh3XMDZmBGlM/rg5zXHo+p0bccEdAfXNt8JU4WiFFUFzYDFtN peBBe4i2KNEOUR1Rw0psRn9viX1IIw+sQEl8RKllEoCCeLov2BKr9EcmF/u4pNgzIzQ2 mQRukkLT5ilfoz6LuOxHQQFuqtHLPaspJUHo3CEKN4qu7Gm1AHbSVX7iaJWNyhOGJDtJ N5Qw== X-Gm-Message-State: AOAM533m1ioiJX6P0QRqR178CMy/aSsFsFmUbPXGPTkdppec6U9HuqC1 o+x8rFk3vwzBvB5gP7dLddo= X-Google-Smtp-Source: ABdhPJzo1rIhmuVt5jZAIWHTgwGLV0aAkoaqgONPslkxsdYNw07XJuWPi+d3PmDXDfeaJKY5C55JHQ== X-Received: by 2002:a17:90b:c90:: with SMTP id o16mr24671691pjz.86.1600679633492; Mon, 21 Sep 2020 02:13:53 -0700 (PDT) Received: from software.domain.org ([45.77.13.216]) by smtp.gmail.com with ESMTPSA id 134sm11723885pfa.93.2020.09.21.02.13.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2020 02:13:53 -0700 (PDT) Sender: Huacai Chen From: Huacai Chen To: Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, Fuxin Zhang , Huacai Chen , Jiaxun Yang , Huacai Chen Subject: [PATCH V7 3/3] MIPS: Loongson-3: Calculate ra properly when unwinding the stack Date: Mon, 21 Sep 2020 17:12:28 +0800 Message-Id: <1600679548-29154-3-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1600679548-29154-1-git-send-email-chenhc@lemote.com> References: <1600679548-29154-1-git-send-email-chenhc@lemote.com> Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Loongson-3 has 16-bytes load/store instructions: gslq and gssq. This patch calculate ra properly when unwinding the stack, if ra is saved by gssq and restored by gslq. Signed-off-by: Huacai Chen --- arch/mips/kernel/process.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index b36297e..37f05c8 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -279,7 +279,21 @@ static inline int is_ra_save_ins(union mips_instruction *ip, int *poff) *poff = ip->i_format.simmediate / sizeof(ulong); return 1; } - +#ifdef CONFIG_CPU_LOONGSON64 + if ((ip->loongson3_lswc2_format.opcode == swc2_op) && + (ip->loongson3_lswc2_format.ls == 1) && + (ip->loongson3_lswc2_format.fr == 0) && + (ip->loongson3_lswc2_format.base == 29)) { + if (ip->loongson3_lswc2_format.rt == 31) { + *poff = ip->loongson3_lswc2_format.offset << 1; + return 1; + } + if (ip->loongson3_lswc2_format.rq == 31) { + *poff = (ip->loongson3_lswc2_format.offset << 1) + 1; + return 1; + } + } +#endif return 0; #endif }