Received: by 10.192.165.148 with SMTP id m20csp2451933imm; Sun, 22 Apr 2018 07:20:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Mwm1S/XuA8mIzPpY/xfdbdoJLWe0azM4afTuDPFcoztiuNw+rx3xR6xkxIXTOOdxC/u2D X-Received: by 10.99.95.130 with SMTP id t124mr14492296pgb.150.1524406819309; Sun, 22 Apr 2018 07:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406819; cv=none; d=google.com; s=arc-20160816; b=GQfbqn/MvB0n+zJawwzXb3ANaRddwLJajnlmHwTKXGChtk4pukWmU6e00pCpTg58no 2T5d1R4yvcBqHIRVCu3uU75KzNVSOljeqoggWJTJX0hYQY0ZtlYM50LM3TIO3I1d0mvZ GheWFqyYNLunMxHQ2re3zeCgESpoCrvYappPun8Ud6IgGOJ30mNYIze2d1tNeKMgGslJ VI1coyDP3gx2/6wNPbLCWAQdVdSebsuwPZKYKnIDg/mbqAvCSfJ/Ogv/RkCo04Lla7KG peuLMPsvxHijEd/QD07USed1jSKmUDtvu228mkpPym9Xyjgx/Ed93pHuh1Pu4swKT7Ik eMxQ== 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=88NQrC+YNpd/UX/aQJi6ntP+GY2dsl8qwaLB18jN0Lk=; b=MD9gfp9H35yqUGIYsXpPgeJI94FhoFyz5B8VbleCa0OCJMtqtyUA2lKWmPDulr06Zj pvv0Viy7Jg/9KoS+DHhR0+4KR/1T8DSPkYHSbWGaJyff8f4dCQyAmK4jM47vO105Q0NX mfUUpX1LTTD0bF53qjPFgmFFbcSiEsEraA+Ptd//aszDEXc1cOCVo1NEEwPn7L6Y15zB OIwyF/bRWwkm7SRWqSrWsB8CECk2OkfgHKmaOTmgHJ61VajIMNMTJRSoN81KIV7VshQE TpXxROaqf890tPyQ6KSlgw8B0fwqLxNnh8Ig4TLZC4rVrQJrgwtOenmwq0tJgP2+CDnG +1ZA== 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 f1-v6si9680455pld.168.2018.04.22.07.20.04; Sun, 22 Apr 2018 07:20:19 -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 S932572AbeDVOTJ (ORCPT + 99 others); Sun, 22 Apr 2018 10:19:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59264 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932532AbeDVOTA (ORCPT ); Sun, 22 Apr 2018 10:19:00 -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 CDFB5CF8; Sun, 22 Apr 2018 14:18:59 +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.4 87/97] powerpc/lib: Fix off-by-one in alternate feature patching Date: Sun, 22 Apr 2018 15:54:05 +0200 Message-Id: <20180422135309.940968004@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@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: 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 @@ -53,7 +53,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;