Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp759877pxb; Wed, 20 Jan 2021 21:35:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpg75tXBHZfTnk2ST4SuqitBrxp5XSU3lGZ1WbODteyT8IIQTtrnwU3UWrVN9KCVgOkBvk X-Received: by 2002:a17:906:a84d:: with SMTP id dx13mr8119210ejb.275.1611207323641; Wed, 20 Jan 2021 21:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611207323; cv=none; d=google.com; s=arc-20160816; b=I+LOmAaErxscJ1jkC59geuJ4iXDsRdGqk4jIL5EQy3IRWiQpgF+yV9ZrZk/na0z+g9 suOU+VQork2hS0WTMY/dkxsHz3Xh2rk/E9KOshGlfxAUFoKOMpxUc9wXo5VA2u6ApGUW Dl8Zn1CvcwqxSJeGClDytqHm4GdnGy7cwK3YB1eLHLX5z8cVuBMo97Xwgjoa5TEQkUgM de7zPVSxl5C5UJ40XwakGOgJOLeQxT0lhgtJvlPKT97QujIDRDYMJmtiBRuas/JOdLTK Rj5KNA+JXKEVgqH/vX0gPLvIxbklVu1lnc+qeUJ+gj7KajZMvT9O5KM31H4WABx2W9LM Ki6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=ptXu2is4mIMNsKyHI4HOQXJfiG+xdkG4G8Q3dwbMmRY=; b=W8RfJpSZ4c98jzcZJX8+OHpm4PmvwKRN/0tHU6PDn2wPqEtphQtXvim6kLh+PH5Zru /cBxcSDiizRudMXjAiqjJmFsreKET6vt+CzXPUPj7gVPu+keNSqf7xbA0hREdyhoHgXG 0YP/0k1KjyuCK7YaeW1Ip3ACxnmNEzd+93d4Fu2nu5B2uUI/HzZBdYqw+JEDI8HJUZpt GhWYEt5knoM+TMevBvoHDUbLwjtesXQLtT+Xidsu//Yq0JaA3SK1cDCdURsQPTqXuH99 Aoann3VwYtS1XutMOHK2gU8QkNIXtaPNrfgLiW64bDQbKs+vcxXeahdlv8np1zL+pcxG R/tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt22si1398183ejb.256.2021.01.20.21.34.59; Wed, 20 Jan 2021 21:35:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726886AbhAUFdv (ORCPT + 99 others); Thu, 21 Jan 2021 00:33:51 -0500 Received: from mail.loongson.cn ([114.242.206.163]:47444 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726885AbhAUFcp (ORCPT ); Thu, 21 Jan 2021 00:32:45 -0500 Received: from loongson.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxeL7GEQlgHXEIAA--.13206S4; Thu, 21 Jan 2021 13:31:52 +0800 (CST) From: Jinyang He To: Thomas Bogendoerfer Cc: Jiaxun Yang , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Burton , Jun-Ru Chang Subject: [PATCH v2 2/4] MIPS: microMIPS: Fix the judgment of mm_jr16_op and mm_jalr_op Date: Thu, 21 Jan 2021 13:31:36 +0800 Message-Id: <1611207098-11381-3-git-send-email-hejinyang@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1611207098-11381-1-git-send-email-hejinyang@loongson.cn> References: <1611207098-11381-1-git-send-email-hejinyang@loongson.cn> X-CM-TRANS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VCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IUYj1v3UUUUU== X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org mm16_r5_format.rt is 5 bits, so directly judge the value if equal or not. mm_jalr_op requires 7th to 16th bits. These 10 which bits generated by shifting u_format.uimmediate by 6 may be affected by sign extension. Thus, take out the 10 bits for comparison. Without this patch, errors may occur, such as these bits are all ones. Signed-off-by: Jinyang He --- arch/mips/kernel/process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index d737234..74d7fd8 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -292,8 +292,8 @@ static inline int is_jump_ins(union mips_instruction *ip) * microMIPS is kind of more fun... */ if (mm_insn_16bit(ip->word >> 16)) { - if ((ip->mm16_r5_format.opcode == mm_pool16c_op && - (ip->mm16_r5_format.rt & mm_jr16_op) == mm_jr16_op)) + if (ip->mm16_r5_format.opcode == mm_pool16c_op && + ip->mm16_r5_format.rt == mm_jr16_op) return 1; return 0; } @@ -305,7 +305,7 @@ static inline int is_jump_ins(union mips_instruction *ip) if (ip->r_format.opcode != mm_pool32a_op || ip->r_format.func != mm_pool32axf_op) return 0; - return ((ip->u_format.uimmediate >> 6) & mm_jalr_op) == mm_jalr_op; + return ((ip->u_format.uimmediate >> 6) & GENMASK(9, 0)) == mm_jalr_op; #else if (ip->j_format.opcode == j_op) return 1; -- 2.1.0