From patchwork Tue Mar 1 03:06:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 590278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (caladan.dune.hu [78.24.191.180]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 35796140B9E for ; Tue, 1 Mar 2016 14:21:02 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 2C83EB91D9A; Tue, 1 Mar 2016 04:08:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Tue, 1 Mar 2016 04:08:25 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 2E410B91C0B for ; Tue, 1 Mar 2016 04:07:31 +0100 (CET) X-policyd-weight: using cached result; rate: -6.1 Received: from chaos.universe-factory.net (chaos.universe-factory.net [37.72.148.22]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Tue, 1 Mar 2016 04:07:31 +0100 (CET) Received: from avalon.neoraider.dn42 (unknown [IPv6:fd1b:c28a:2fd6::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by chaos.universe-factory.net (Postfix) with ESMTPSA id ACCA81830AF for ; Tue, 1 Mar 2016 04:07:30 +0100 (CET) From: Matthias Schiffer To: openwrt-devel@lists.openwrt.org Date: Tue, 1 Mar 2016 04:06:55 +0100 Message-Id: <303546e60924ac702fb6e1c1976b363ab58db930.1456800208.git.mschiffer@universe-factory.net> X-Mailer: git-send-email 2.7.2 In-Reply-To: References: In-Reply-To: References: Subject: [OpenWrt-Devel] [PATCH CC 21/32] ar71xx/lzma-loader: fix O32 ABI conformance X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" According to the calling convention of the o32 ABI the caller function must reserve stack space for $a0-$a3 registers in case the callee needs to save its arguments. The assembly code of the loader does not reserve stack space for these registers thus when the 'loader_main' function needs to save its arguments, those will be stored in the 'workspace' area instead of the stack. Because the workspace area is also used by other part of the code, the saved register values gets overwritten and this often leads to failed kernel boots. Fix the code to reserve stack space for the registers to avoid this error. Signed-off-by: Gabor Juhos Backport of r48279 --- target/linux/ar71xx/image/lzma-loader/src/head.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/linux/ar71xx/image/lzma-loader/src/head.S b/target/linux/ar71xx/image/lzma-loader/src/head.S index 543996a..47a7c9b 100644 --- a/target/linux/ar71xx/image/lzma-loader/src/head.S +++ b/target/linux/ar71xx/image/lzma-loader/src/head.S @@ -109,6 +109,9 @@ __bss_check: /* Setup new "C" stack */ la sp, _stack + /* reserve stack space for a0-a3 registers */ + subu sp, 16 + /* jump to the decompressor routine */ la t0, loader_main jr t0