Received: by 10.213.65.68 with SMTP id h4csp39977imn; Mon, 19 Mar 2018 18:51:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELvl3+FrHB0NMOrmbZcReDrWd/Pv8+pF1pgHWFBCWKhZw2Uihd2uxPWSi7jndhoXyc76FHNM X-Received: by 2002:a17:902:9a42:: with SMTP id x2-v6mr2006963plv.201.1521510695263; Mon, 19 Mar 2018 18:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510695; cv=none; d=google.com; s=arc-20160816; b=afGiaQGP5bYTIo++yjKs3iRSnL7Z0mEDV1yWD+hDZ7vzfJD3XM8GQ158I0V0fvKc/Y dCHKgn+RwbeJoSzlMhGLWTHhuhXGqPrFTjYfKae4O4FNcXpjTmv8jfeN0SYKiOKf9R2A MfHYJYpDQ5Oo/7XAlnqF5agIHqi1dv6ZHRgtowBnIN6DGTwrR0D0CW1oTYRbIlvz7g+Y +sfM6LSI1RGwBee8vzU/Rr+IcvS/TyLdSKI+JGfA7WJ+8NBFhAeMjECAZq72Xn+/gzkh 4aYcs+Og3Rmsd0Be6yxvE/29JIQIecwHrPLia55U+F71OZSwfPD+kV7MsSC1/gpxQBOF NuVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=CLF4tjaimylaKnF/YCi+QVCjK+LQ0mJNP1V9zh4as84=; b=EGdv91zrEEYVnpc7KXMVaUT2cfAwdNrkQGITc7w5bJ35SGqM4GPgPT7YH8bgfNyxGf up/SnduNF+96HIrgVkxj4DQ2gFNOBUBjMQoQ1VoiDXwdV0LILSb0Fkuiraidydu7nAwg AFii3mRdwefqokDHVjh7FwjUp8HKGiSe3Mm9SrhGumhQuyhK4KYRIlonqh+ZxL28pkfL 7I3mPkMigOZX0mCO1ssZjvGG+JQYnlxtMP6c0Zn0C4jfjX35ByaQfUAREEFMwSexBzln 1lq5YHbyn8kVXim7T3XI8MNwgGum8BHJzzsfBGGBNT3c871iswXUupNNH+SjUpDsjO99 qSvA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si384173pgu.357.2018.03.19.18.51.21; Mon, 19 Mar 2018 18:51:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968980AbeCSUW2 (ORCPT + 99 others); Mon, 19 Mar 2018 16:22:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44240 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966027AbeCSSOh (ORCPT ); Mon, 19 Mar 2018 14:14:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 893EBF37; Mon, 19 Mar 2018 18:14:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leonid Yegoshin , Miodrag Dinic , Aleksandar Markovic , Douglas Leung , Paul Burton , james.hogan@imgtec.com, petar.jovanovic@imgtec.com, goran.ferenc@imgtec.com, linux-mips@linux-mips.org, Ralf Baechle , Sasha Levin Subject: [PATCH 4.4 064/134] MIPS: r2-on-r6-emu: Fix BLEZL and BGTZL identification Date: Mon, 19 Mar 2018 19:05:47 +0100 Message-Id: <20180319171858.532633977@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leonid Yegoshin [ Upstream commit 5bba7aa4958e271c3ffceb70d47d3206524cf489 ] Fix the problem of inaccurate identification of instructions BLEZL and BGTZL in R2 emulation code by making sure all necessary encoding specifications are met. Previously, certain R6 instructions could be identified as BLEZL or BGTZL. R2 emulation routine didn't take into account that both BLEZL and BGTZL instructions require their rt field (bits 20 to 16 of instruction encoding) to be 0, and that, at same time, if the value in that field is not 0, the encoding may represent a legitimate MIPS R6 instruction. This means that a problem could occur after emulation optimization, when emulation routine tried to pipeline emulation, picked up a next candidate, and subsequently misrecognized an R6 instruction as BLEZL or BGTZL. It should be said that for single pass strategy, the problem does not happen because CPU doesn't trap on branch-compacts which share opcode space with BLEZL/BGTZL (but have rt field != 0, of course). Signed-off-by: Leonid Yegoshin Signed-off-by: Miodrag Dinic Signed-off-by: Aleksandar Markovic Reported-by: Douglas Leung Reviewed-by: Paul Burton Cc: james.hogan@imgtec.com Cc: petar.jovanovic@imgtec.com Cc: goran.ferenc@imgtec.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/15456/ Signed-off-by: Ralf Baechle Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/mips-r2-to-r6-emul.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/arch/mips/kernel/mips-r2-to-r6-emul.c +++ b/arch/mips/kernel/mips-r2-to-r6-emul.c @@ -1097,10 +1097,20 @@ repeat: } break; - case beql_op: - case bnel_op: case blezl_op: case bgtzl_op: + /* + * For BLEZL and BGTZL, rt field must be set to 0. If this + * is not the case, this may be an encoding of a MIPS R6 + * instruction, so return to CPU execution if this occurs + */ + if (MIPSInst_RT(inst)) { + err = SIGILL; + break; + } + /* fall through */ + case beql_op: + case bnel_op: if (delay_slot(regs)) { err = SIGILL; break;