Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3963200img; Mon, 25 Mar 2019 23:38:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcCH4M53lVrVNpg3w7pNyhB4pzgE0IvdMNxrt+DaAg9c3C2NDB67LQJsuj5Z/PiwGRkUS2 X-Received: by 2002:a17:902:5c5:: with SMTP id f63mr26360167plf.64.1553582298140; Mon, 25 Mar 2019 23:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582298; cv=none; d=google.com; s=arc-20160816; b=ZUtfvYG5uj5lyDP9Zy5CyU0v2bhyQ0V8/67RFJWGo3a4MGGx5ka0mdToRTnrTCemx/ /TX1WHsHtQhVXNAlqB3z59Ut0HNoC1BIeV2fa05qzkVapzk83DgoAIKnXphxK8p37A3S 3jZN/weZOMQWPf9Fu8WPiAObe+pON/QYQOcKsl+ogK3MoPAeT1vYQEODx+nflLQ9Oog2 e/T7ZhsYh03ylTo2OfT6bpvGTdzMpGKfIi8jHdnuo/M5gbcMeJXJvjYku1swBcNfmfL3 KRhJNchAHx8QawNWPMCtesWRHPcyN3waHNFzeg9+bTbiKyj2DD92Nky6AaNyTjPKfctO I9ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ow6x5Js6BdLj3UCF4JQ2Vt3HasCyFozxFcpJlScAuiA=; b=b1BctlmOB9+ZLH+SCDmGhs1g1/dbztMwr066+oOgBBp9Jp1y7pId3IQub18Ja1mwq5 +PByJ/WakdzbwjFZDWuZnO0y8jyKYcWCIZuNtC0KroIJDHrFN49pCqoBWmc3PjHIJgGU ObtDYaGesUjpHzF0ikE54SWVEqdJJ1T7GchJVFZchjEVJ7DoxPuMNc0obEtc4Gfm2fAU DzjnbBmFgjO4shr4coxNdsgOuyqZ0YrkoTi5vrW8TjL4IpANw2kPAlFuLnSmF/o9yREy 6s8LY3WMsy6A3XCytFhDLaiL9BDcBVJmYTZqyZAF3fpaezSWTOaUZ26RYe7NIJHThmNU BbTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sAOT0UTk; 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 m10si15366806pgk.386.2019.03.25.23.38.03; Mon, 25 Mar 2019 23:38:18 -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=sAOT0UTk; 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 S1731182AbfCZGfj (ORCPT + 99 others); Tue, 26 Mar 2019 02:35:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:47458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbfCZGfh (ORCPT ); Tue, 26 Mar 2019 02:35:37 -0400 Received: from localhost (unknown [104.132.152.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 650F420823; Tue, 26 Mar 2019 06:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582137; bh=pqjvzSiJEsfK7ZffskbdO1uKI6xdKYWOWo4gD1qa7Do=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sAOT0UTkbmKRCntzdQ1tJ69HJ/32hsCIyF3U1vV2LPoMWSrsypK9K1bnSKHwlvaO9 HXDfqE88j/Q/XRQNZU6PruDaamCIQDu9hsxgvolTiEnGv7l0XI5W8GWzCMT853E0KN uFHbZpkYGcnlda44SGdiODtPS0rmIbA8ux4mSIM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Archer Yan , Paul Burton , linux-mips@vger.kernel.org Subject: [PATCH 4.19 13/45] MIPS: Fix kernel crash for R6 in jump label branch function Date: Tue, 26 Mar 2019 15:29:56 +0900 Message-Id: <20190326042703.370663184@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042702.565683325@linuxfoundation.org> References: <20190326042702.565683325@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Archer Yan commit 47c25036b60f27b86ab44b66a8861bcf81cde39b upstream. Insert Branch instruction instead of NOP to make sure assembler don't patch code in forbidden slot. In jump label function, it might be possible to patch Control Transfer Instructions(CTIs) into forbidden slot, which will generate Reserved Instruction exception in MIPS release 6. Signed-off-by: Archer Yan Reviewed-by: Paul Burton [paul.burton@mips.com: - Add MIPS prefix to subject. - Mark for stable from v4.0, which introduced r6 support, onwards.] Signed-off-by: Paul Burton Cc: linux-mips@vger.kernel.org Cc: stable@vger.kernel.org # v4.0+ Signed-off-by: Greg Kroah-Hartman --- arch/mips/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/mips/include/asm/jump_label.h +++ b/arch/mips/include/asm/jump_label.h @@ -21,15 +21,15 @@ #endif #ifdef CONFIG_CPU_MICROMIPS -#define NOP_INSN "nop32" +#define B_INSN "b32" #else -#define NOP_INSN "nop" +#define B_INSN "b" #endif static __always_inline bool arch_static_branch(struct static_key *key, bool branch) { - asm_volatile_goto("1:\t" NOP_INSN "\n\t" - "nop\n\t" + asm_volatile_goto("1:\t" B_INSN " 2f\n\t" + "2:\tnop\n\t" ".pushsection __jump_table, \"aw\"\n\t" WORD_INSN " 1b, %l[l_yes], %0\n\t" ".popsection\n\t"