From patchwork Mon Sep 28 09:26:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 11803269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 815A6112E for ; Mon, 28 Sep 2020 09:27:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A07C21D95 for ; Mon, 28 Sep 2020 09:27:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MMmSYSuN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2A07C21D95 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5JnPd1DITzczEZBJZdjfB3sRj8CDGO9myPDiZVFYl5g=; b=MMmSYSuNZnrSnRe2WWulmPjK1 3fcRSi1UoXo7ENMspGHgnukCxvf9QDt2PGpo3/CB/mpWhx4Wk/9Yf4mdvaseigfWmPNPwJPeCxzCR 1qOnjZwzc+K1se4OlnZnlShXvwZdKBKT/HuAp6DhKKmDaOCzxqIuIYtXLgG3hwaOS5Ba+mVU5aXaW 6yu0LJaZ3cFB9OZ4k0ExoGTp4c8M/DNBAb0syzWXq2s8930lWpuFmikCLem78HpwFhdGUIgwb766U 4FAjzYc6D0nUGO7xy/U/KsPFenXx+ykqHdCVGsgaK+hmJZ/OX/H7WO0HNuy+LiaDzRw75IlQVqIrB aPvOm9/IQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMpRD-00062L-Fv; Mon, 28 Sep 2020 09:27:15 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMpR9-0005z8-OU for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 09:27:12 +0000 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 10E3F171D3C77CA7B15C; Mon, 28 Sep 2020 17:27:04 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.177.253) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Mon, 28 Sep 2020 17:26:54 +0800 From: Zhen Lei To: Russell King , Ard Biesheuvel , linux-arm-kernel , linux-kernel Subject: [PATCH 2/2] ARM: decompressor: relax the loading restriction of the decompressed kernel Date: Mon, 28 Sep 2020 17:26:41 +0800 Message-ID: <20200928092641.2070-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200928092641.2070-1-thunder.leizhen@huawei.com> References: <20200928092641.2070-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_052712_048182_242F03D3 X-CRM114-Status: GOOD ( 12.54 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.32 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [45.249.212.32 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kefeng Wang , Libin , Zhen Lei Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org mov r4, pc and r4, r4, #0xf8000000 //truncated to 128MiB boundary add r4, r4, #TEXT_OFFSET //PA(_start) Currently, the decompressed kernel must be placed at the position: 128MiB boundary + TEXT_OFFSET. This limitation is just because we masked PC with 0xf80000000. Actually, we can directly obtain PA(_start) by using formula : VA(_start) + (PHYS_OFFSET - PAGE_OFFSET). So the "PA(_start) - TEXT_OFFSET" can be 2MiB boundary, 1MiB boundary, and so on. Signed-off-by: Zhen Lei --- arch/arm/boot/compressed/head.S | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 434a16982e344fe..e5ba2ad2ea4700f 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -255,26 +255,16 @@ not_angel: #ifdef CONFIG_AUTO_ZRELADDR /* - * Find the start of physical memory. As we are executing - * without the MMU on, we are in the physical address space. - * We just need to get rid of any offset by aligning the - * address. - * - * This alignment is a balance between the requirements of - * different platforms - we have chosen 128MB to allow - * platforms which align the start of their physical memory - * to 128MB to use this feature, while allowing the zImage - * to be placed within the first 128MB of memory on other - * platforms. Increasing the alignment means we place - * stricter alignment requirements on the start of physical - * memory, but relaxing it means that we break people who - * are already placing their zImage in (eg) the top 64MB - * of this range. + * Find ZRELADDR (Address where the decompressed kernel was + * placed, usually == PHYS_OFFSET + TEXT_OFFSET). That's the + * start physical address of the text section, PA(_start). + * As we are executing without the MMU on, we are in the + * physical address space. */ - mov r4, pc - and r4, r4, #0xf8000000 - /* Determine final kernel image address. */ - add r4, r4, #TEXT_OFFSET + adr r0, LC2 + ldmia r0, {r3-r4} + sub r3, r0, r3 @ PHYS_OFFSET - PAGE_OFFSET + add r4, r4, r3 @ PA(_start) #else ldr r4, =zreladdr #endif @@ -660,6 +650,11 @@ LC1: .word .L_user_stack_end - LC1 @ sp .word _edata - LC1 @ r6 .size LC1, . - LC1 + .align 2 + .type LC2, #object +LC2: .word LC2 + .word _start @ start VA of text section + .Lheadroom: .word _end - restart + 16384 + 1024*1024