Received: by 10.192.165.148 with SMTP id m20csp2458937imm; Sun, 22 Apr 2018 07:28:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/nhv3J9ormxolm+CW4qpc5lpS01fptzarPfT7Exd1DGmRAeOCxY+DLVIv1ErRlTioI3sxF X-Received: by 10.98.247.17 with SMTP id h17mr16463020pfi.165.1524407328120; Sun, 22 Apr 2018 07:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407328; cv=none; d=google.com; s=arc-20160816; b=EhX5HbfUwG44OvxELyUOXsmSjdMm6M3LI+GGPuULaqHCKolFb3hBJddwrs+hfqef3X bInGgrmuFmOshbhN+Yt31D/I8kv60El1OW5gbzJv+oL/+ILtMuhTw7PmOM2SegxUuDQ8 7XsocQPWPhXjpPcQMP1x7j/0Au4EyIW0g1KTrDKSPv+LaSxp6Kuzx6fVxC3PF2SWeQXf BuO1tI9gZbZv+MpbDHR/dCf3wdluqFzasYrM1SAQCTV4Xywc3KaLrDg/5++W+7JMMMGS KlhoinMnxqBCnSB/Hti8Bxz1cWg20OT152PvLBCV4WavFfpHI8q2awqq61yWQRwXtWiS lDwQ== 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=W30zG5Oo2EQ3kHa+zoc0Zv7tdc7dTs02nRZrxT4w4Wc=; b=is9goMOr0Cobl/E1MQFxXRzgYOZhItOcH7SN3JiRR7J0s87LfVKbnFQb5sIT9z1i7O IHxDxKTAsr70R+ukPm+KUDVdRdcLLyVPW/GNhTKPIr1M9oNQ8+If7pwv5VjAmCa/C9Ul OdRzEMWbaYxq20II/fSEktpwDVH4JNi1eorVXnQOAoO+WdHKDS556f/3bVDIGkYem2dA 48G0xe5Ey42IPQbgoeX+uugJi08NMViOyHSEhFTEF7ioprZAD3MDvkk4vTm3QPolKwD6 W713copYg8FF+Hx1T1XKTIVYdpWpwNCothjL7AG3Ulq9h7iMLh4pF+GKzKUGVC4Viz1+ xAjA== 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 c7si8279854pgn.152.2018.04.22.07.28.27; Sun, 22 Apr 2018 07:28:48 -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 S1757610AbeDVOVs (ORCPT + 99 others); Sun, 22 Apr 2018 10:21:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33004 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757566AbeDVOVn (ORCPT ); Sun, 22 Apr 2018 10:21:43 -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 38964CDB; Sun, 22 Apr 2018 14:21:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman Subject: [PATCH 3.18 46/52] powerpc/lib: Fix off-by-one in alternate feature patching Date: Sun, 22 Apr 2018 15:54:19 +0200 Message-Id: <20180422135317.478837951@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@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 3.18-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 @@ -52,7 +52,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;