Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1971722ima; Thu, 25 Oct 2018 07:45:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5dzpbQLYH2yI7SBvODGeBY13f8JYJq0GBkFZ7r9Hd90Zm1wG2xRi5CmIZhV1wPEHETv4hra X-Received: by 2002:a17:902:223:: with SMTP id 32-v6mr1805406plc.112.1540478758354; Thu, 25 Oct 2018 07:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478758; cv=none; d=google.com; s=arc-20160816; b=K/KuGsLar0QKT2/+uVpEBa/w3E8j1jPA9ehjil3qTgmP08ypxWFHXh2oyNdPY35GFH +EPqviC34fsSi2l1bEMFUEUbD114Nurss6Dc8S18bjdDaNXzu1WBTV2wZNWAo4SUxqkd 5BgF2fTN2GIfRJCeUHC5xfRW1kux9FFbP7gcaYtbRQKF/YJJzymoGDbhsH5V8aBW1fab p3Ht1rKleUOEhN60awtVeteax6JrGniezGTypmG8mrs9a7oqXvn3g0uxcP5FkPmG/3sH aWXVchiclUePRmm4tCIMm0b8WIf/Ir6eJgEQqfVQFaV7StcOFXQULdOgj5ZP91RIRIdN Yj/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=5hc5J23gQIrqra6atCzBo0A6usA9R2BD14SsdY6Uqn0=; b=HIPnfACwUR2tGv1eX2LKrEUxrQQtgqWDyT8kArqjT/ELbdv/jStML3p8vklVkHYiYh Pz4IEDlf47PAxBPL0jpCwjLNvv/ROIHkat04PuQpAK+rhKKLQjYjXTxEUNOHfeEeet+C I76bWrabTHYFJg7Q/R5qkzzBInowmKXSLzyRABwULicae2lAnoBDwgmbgb4Pt3Hitd2l h0ctU9U3PJ3/99HGoveWr3lMWlqaksmdwOJobVYSXzRdw1Rpg7RbODRDJjPu0vaY1tXp EgHcpTZYoKFlfFawMEnQzybH8pQXuiHS0+NGQH67oYjBR24CM0pRYPYg/EgDaRvdwQRq 12ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xn15p5DR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be11-v6si7845328plb.193.2018.10.25.07.45.40; Thu, 25 Oct 2018 07:45:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xn15p5DR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728484AbeJYWr2 (ORCPT + 99 others); Thu, 25 Oct 2018 18:47:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:55468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727433AbeJYWr2 (ORCPT ); Thu, 25 Oct 2018 18:47:28 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 693EC20854; Thu, 25 Oct 2018 14:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476872; bh=uDZH9nMm67wE1w0dCYmmvnHvoyegTO9xSrh0LvbH8Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xn15p5DRT4eekrkONkFR24djaUBuJ2dIeaE6TSUyQFjSFWq9jhHv8WLgswc+SbnEh P/rtpmjNuRY8fdMbaFQSTd3OklcrIKaTJdZ9rwnLUf98TQ7quJnQQDBrlRQjoeeRbD Isutv0D2bbs/1ezlawq2P7NSUGSONbnWVqEPPepw= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Matt Redfearn , Marcin Nowakowski , Miodrag Dinic , Ingo Molnar , David Daney , linux-mips@linux-mips.org, Ralf Baechle , Sasha Levin Subject: [PATCH AUTOSEL 4.9 03/98] MIPS: microMIPS: Fix decoding of swsp16 instruction Date: Thu, 25 Oct 2018 10:12:48 -0400 Message-Id: <20181025141423.213774-3-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matt Redfearn [ Upstream commit cea8cd498f4f1c30ea27e3664b3c671e495c4fce ] When the immediate encoded in the instruction is accessed, it is sign extended due to being a signed value being assigned to a signed integer. The ISA specifies that this operation is an unsigned operation. The sign extension leads us to incorrectly decode: 801e9c8e: cbf1 sw ra,68(sp) As having an immediate of 1073741809. Since the instruction format does not specify signed/unsigned, and this is currently the only location to use this instuction format, change it to an unsigned immediate. Fixes: bb9bc4689b9c ("MIPS: Calculate microMIPS ra properly when unwinding the stack") Suggested-by: Paul Burton Signed-off-by: Matt Redfearn Reviewed-by: James Hogan Cc: Marcin Nowakowski Cc: Miodrag Dinic Cc: Ingo Molnar Cc: David Daney Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/16957/ Signed-off-by: Ralf Baechle Signed-off-by: Sasha Levin --- arch/mips/include/uapi/asm/inst.h | 2 +- arch/mips/kernel/process.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/uapi/asm/inst.h b/arch/mips/include/uapi/asm/inst.h index 77429d1622b3..711d9b8465b8 100644 --- a/arch/mips/include/uapi/asm/inst.h +++ b/arch/mips/include/uapi/asm/inst.h @@ -964,7 +964,7 @@ struct mm16_r3_format { /* Load from global pointer format */ struct mm16_r5_format { /* Load/store from stack pointer format */ __BITFIELD_FIELD(unsigned int opcode : 6, __BITFIELD_FIELD(unsigned int rt : 5, - __BITFIELD_FIELD(signed int simmediate : 5, + __BITFIELD_FIELD(unsigned int imm : 5, __BITFIELD_FIELD(unsigned int : 16, /* Ignored */ ;)))) }; diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index ba315e523b33..0211dc737a21 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -212,7 +212,7 @@ static inline int is_ra_save_ins(union mips_instruction *ip, int *poff) if (ip->mm16_r5_format.rt != 31) return 0; - *poff = ip->mm16_r5_format.simmediate; + *poff = ip->mm16_r5_format.imm; *poff = (*poff << 2) / sizeof(ulong); return 1; -- 2.17.1