Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp42127imu; Thu, 8 Nov 2018 14:25:25 -0800 (PST) X-Google-Smtp-Source: AJdET5cW+Af+CcAtD+BsOc4wwvKbSTYhJapslo7CPtHDKp4qTJO73pmRT/gK69s/q4QnnGEWa2Ha X-Received: by 2002:a63:396:: with SMTP id 144mr5381880pgd.68.1541715925003; Thu, 08 Nov 2018 14:25:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541715924; cv=none; d=google.com; s=arc-20160816; b=PJP7AC0aBsaSGgVzPVxdeNit4MOwoKJufcH+3rtnYNsOLcnr0B+ecywstdgQUBrSwb nxAIkF28eEGRSGhk0LoeJz8Vq0qhEvPKOKkyus1Ao6QgKX4Dc+6R08QXDiVas1mnaxzc FJA8QfCc6/fYSRmozI1iPy/jelQSMlB/t8JlZ4SeSOetgmLv6UTTYsgMpiMt4hT1I8JG nMpLpBUy3DMzkXIt0lbdubHXuBVFndaKGgcpvqEDOcnCcM8q1Mm32ehHvbbN4W8oJMJp DHrXwQe/HdFwU4j/DYNVxK8rUxHUmf/k9SejgTXE9Iu21PubJ3K11Q8tkarmDam1o0/w yU7g== 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=dceWhZZlMiJE/kUjXsJ05+PdmOJoC2Sg/TUdzJ+s/5E=; b=zyS87+Mah/a0Ng6akR3n6omA/2iYv72FitGZjvd77KgLtXYCUOG6el5Qfn5nRh3tAk oAPTpW9NJZwTY/HpkPnNBiesBQr7tvPNV5ze3Ke+WjHhENT9ICddqJCDugXDQ2gr9mXg 44FLh+om3a+k91+faY/UPZ16WktwlKUqkXBWCWOJavSjZzIXSyVjaNcPt+EMZm4GpSj/ MCui16MwXLVijhHmqOt9uFed1bSqDSAGVR+Mmjn0M1Cpb+Ji/y8PlXxSpRFTlnGj0tMQ 7b59vK0RkS6tt3iFIUCd3VXN6cgXH2uEnWY+9kRqWO2K37S06lKixprDPj7869zOBqlg odMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KumND7+V; 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 q13-v6si5017456pgq.526.2018.11.08.14.25.09; Thu, 08 Nov 2018 14:25:24 -0800 (PST) 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=KumND7+V; 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 S1731505AbeKIHm3 (ORCPT + 99 others); Fri, 9 Nov 2018 02:42:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:34246 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727288AbeKIHm2 (ORCPT ); Fri, 9 Nov 2018 02:42:28 -0500 Received: from localhost (unknown [208.72.13.198]) (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 A1E8820892; Thu, 8 Nov 2018 22:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714697; bh=vLsWWSKxGH4TWsC8SIfkxzCyh0YnPY3ArKJr42CGcTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KumND7+Vnvjg1BKsKaPhoLbrnkuaJQAW9YHe09TxKjHTkV1nUGNbL9AfGRnFTE1c+ ZQhU/LErf6Dmhzw40weRgWtJh5uIGFhS5U3j4m4xVM3pxtBELDXQcNtWrT3zvdEJJ8 F9J7exYyC5cg2JAvxD5FL5hne08Eo7QbS19JYtWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Patrice CHOTARD , Nicolas Pitre , Ard Biesheuvel , Russell King , Sasha Levin Subject: [PATCH 4.9 067/171] ARM: 8677/1: boot/compressed: fix decompressor header layout for v7-M Date: Thu, 8 Nov 2018 13:50:37 -0800 Message-Id: <20181108215132.416063037@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215127.257643509@linuxfoundation.org> References: <20181108215127.257643509@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 06a4b6d009a1b74a6ec46c5418b46cc53a79fcb8 ] As reported by Patrice, the header layout of the decompressor is incorrect when building for v7-M. In this case, the __nop macro resolves to 'mov r0, r0', which is emitted as a narrow encoding, resulting in the header data fields to end up at lower offsets than required. Given the variety of targets we need to support with the same code, the startup sequence is a bit of a jumble, and uses instructions and macros whose encoding widths cannot be specified (badr), or only exist in a narrow encoding (bx) So force the use of a wide encoding in __nop, and replace the start sequence with a simple jump to the label marking the start of code, preceded by a Thumb2 mode switch if required (using explicit wide encodings where appropriate). The label itself can be moved to the start of code [where it belongs] due to the larger range of branch instructions as compared to adr instructions. Reported-by: Patrice CHOTARD Acked-by: Nicolas Pitre Signed-off-by: Ard Biesheuvel Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/boot/compressed/efi-header.S | 4 +--- arch/arm/boot/compressed/head.S | 17 ++++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arch/arm/boot/compressed/efi-header.S b/arch/arm/boot/compressed/efi-header.S index 9d5dc4fda3c1..3f7d1b74c5e0 100644 --- a/arch/arm/boot/compressed/efi-header.S +++ b/arch/arm/boot/compressed/efi-header.S @@ -17,14 +17,12 @@ @ there. .inst 'M' | ('Z' << 8) | (0x1310 << 16) @ tstne r0, #0x4d000 #else - mov r0, r0 + W(mov) r0, r0 #endif .endm .macro __EFI_HEADER #ifdef CONFIG_EFI_STUB - b __efi_start - .set start_offset, __efi_start - start .org start + 0x3c @ diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index fc6d541549a2..2d7f2bb0d66a 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -130,19 +130,22 @@ start: .rept 7 __nop .endr - ARM( mov r0, r0 ) - ARM( b 1f ) - THUMB( badr r12, 1f ) - THUMB( bx r12 ) +#ifndef CONFIG_THUMB2_KERNEL + mov r0, r0 +#else + AR_CLASS( sub pc, pc, #3 ) @ A/R: switch to Thumb2 mode + M_CLASS( nop.w ) @ M: already in Thumb2 mode + .thumb +#endif + W(b) 1f .word _magic_sig @ Magic numbers to help the loader .word _magic_start @ absolute load/run zImage address .word _magic_end @ zImage end address .word 0x04030201 @ endianness flag - THUMB( .thumb ) -1: __EFI_HEADER - + __EFI_HEADER +1: ARM_BE8( setend be ) @ go BE8 if compiled for BE8 AR_CLASS( mrs r9, cpsr ) #ifdef CONFIG_ARM_VIRT_EXT -- 2.17.1