Received: by 10.192.165.148 with SMTP id m20csp2435162imm; Sun, 22 Apr 2018 07:03:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GtBs3GePur9vmsV0js3H2qPe/pFhkfa1zGCVEsKrxDu2EUOwFCt7zHhputHdbzzfE3mfo X-Received: by 10.98.89.70 with SMTP id n67mr16773025pfb.150.1524405834316; Sun, 22 Apr 2018 07:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405834; cv=none; d=google.com; s=arc-20160816; b=iBi31NPdAc6rDcFF0dDNcF1ARsNWEglpB+VuCiI7T5crhqD+UJTdofygWdCuKuySl7 6eh6OoWz7XfRYCc7tYO1zHVU60Hs7dR5kunXIRf4FiCkMnqSxkXuFf4OprnIzskXVqYR 9r3VeuegMSFS9aYsUllnEaaUrBqcvBfUeVEiLAZlStWmv4tqmjjd7S8p107hygi6XLHQ 0E2wIfIS4Ew2L5TnPB5rKCveo3xOHzozpqSBUnCsIYOuP9SeYwSldLtDL6aoOs1/f2Uh PLPs2vTGaWq+ksOWOCkN0PX+UkkOWSK4SU3EmFN2j9pG/JKCPJwMFvzL6rdo2d7WXziz LBzg== 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=0xtahmpkj2QNBDeFqNZiLdpD3a6AlQkjYVXL2X23Ibg=; b=gWuUsrYfnCXzSTLg+Qfy0uHfjO8l4OZ3N/n9bs+9Ns+s+IAPsJ/KUNodQ0j5HnIycz YytysIMmSuDOwGJUe34nghiaFqcyVS97m3h/KlQbKMZUFME2VneYxTaWypKo3odcqWQf DU7zrXikQIcsz7IRKHJxAebmCHGxKCBgVshAICgpQ73RaN6AFOFGy5Nwk4++ipsPZH+m OliZ5992TUliJOzDwsd0W8dqeBeIGt2IVsT3I56RwOHagojWeskq24npb9um5KaXiDd3 2pAnwPNfeYwoQXD4S2kpmSSAp7JoUSgeTZ99FtPzWlV+s7zZdCM2SEYdL9DDmwJsV14n +Ivw== 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 t134si8173835pgc.519.2018.04.22.07.03.40; Sun, 22 Apr 2018 07:03:54 -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 S1754868AbeDVOCb (ORCPT + 99 others); Sun, 22 Apr 2018 10:02:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48530 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754267AbeDVOCZ (ORCPT ); Sun, 22 Apr 2018 10:02:25 -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 07083CC0; Sun, 22 Apr 2018 14:02:24 +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.16 179/196] powerpc/lib: Fix off-by-one in alternate feature patching Date: Sun, 22 Apr 2018 15:53:19 +0200 Message-Id: <20180422135113.506068837@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-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;