Received: by 10.192.165.148 with SMTP id m20csp2479848imm; Sun, 22 Apr 2018 07:55:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Ma/o51iQFESjJc9SLGZt4wJELojlFc17nyXjFEsUYdv51rvcWauIshs9Nbuo4jIEDXjgP X-Received: by 2002:a17:902:7e4a:: with SMTP id a10-v6mr13597154pln.276.1524408951650; Sun, 22 Apr 2018 07:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408951; cv=none; d=google.com; s=arc-20160816; b=FRM20+OIUynTM54lVdXrAsXd7cl6EvigEuOm7GO4wuiIv5lYdZF6XemmBAj5HEGiKK KU8Ma+MlVUg8TmNIXbQ91zS8FNCkAMvDyDZv+3RtBxmwaptL/PDBRGfqnC/vHA/CgVW/ MdKowdafDv64QXhZ0AKMPYWPvjKUZRxVxWb7mnh8qWpNWP5eu4bK7ZVKbZ2JvnJ0Nnvv Zpzvi89kk3Yow+nH5WxMTbz0dozh2r4/EHkAt0Gxxwd7eNHumPLUCzcUBHFU587gsjKq AXPcpihz1ZEQZWCj7eX0SG/994xFFJ6KYtuThqD2R5QOFERsrycR2G//kf07PUN9rZ+m S1Xg== 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=fdqLhY9Tp4vcGSAQdbnAkC0+pcCIb9I5nPJapxITq1I=; b=tcSK791kGXWd2zNmLjXpP5EoiDyl0JZ1Mt5DNEz8m6HdHCiqYqTinWyIYahP6Cb7AN Ht1PhhZ+bwjwQ1vzTrLsq5NcvuaME76wQZpCuTGuMpS3E0+/7DePOtYRLwLNC+Utktjd exBBNZo1NOBgJuThA+XdjJQfRnKUHgWoYYQHRlDTebJtT+w8A2uOmJMjrsDGfZ9Mt3pr Tg4O1Kp49L1uyFKWBoNJIypBwpSt6iqFBnw3SYy/L9uXAeog3fsIlFQtdipGq/S9u92S 5bkjMvLS5IsZ+6XvZyzwjDelSh+Iq3iHB7VXcilCzWhNthvC3KoJDHYBjoqAFpu1sXjG 21dA== 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 e6si9184028pff.205.2018.04.22.07.55.37; Sun, 22 Apr 2018 07:55:51 -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 S1757051AbeDVOOm (ORCPT + 99 others); Sun, 22 Apr 2018 10:14:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56464 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756146AbeDVOOd (ORCPT ); Sun, 22 Apr 2018 10:14:33 -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 B14864A5; Sun, 22 Apr 2018 14:14:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman Subject: [PATCH 4.9 84/95] powerpc/lib: Fix off-by-one in alternate feature patching Date: Sun, 22 Apr 2018 15:53:53 +0200 Message-Id: <20180422135213.862996430@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Ellerman commit b8858581febb050688e276b956796bc4a78299ed upstream. When we patch an alternate feature section, we have to adjust any relative branches that branch out of the alternate section. But currently we have a bug if we have a branch that points to past the last instruction of the alternate section, eg: FTR_SECTION_ELSE 1: b 2f or 6,6,6 2: ALT_FTR_SECTION_END(...) nop This will result in a relative branch at 1 with a target that equals the end of the alternate section. That branch does not need adjusting when it's moved to the non-else location. Currently we do adjust it, resulting in a branch that goes off into the link-time location of the else section, which is junk. The fix is to not patch branches that have a target == end of the alternate section. Fixes: d20fe50a7b3c ("KVM: PPC: Book3S HV: Branch inside feature section") Fixes: 9b1a735de64c ("powerpc: Add logic to patch alternative feature sections") Cc: stable@vger.kernel.org # v2.6.27+ Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/lib/feature-fixups.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/powerpc/lib/feature-fixups.c +++ b/arch/powerpc/lib/feature-fixups.c @@ -55,7 +55,7 @@ static int patch_alt_instruction(unsigne unsigned int *target = (unsigned int *)branch_target(src); /* Branch within the section doesn't need translating */ - if (target < alt_start || target >= alt_end) { + if (target < alt_start || target > alt_end) { instr = translate_branch(dest, src); if (!instr) return 1;