From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C188CC4727F for ; Mon, 28 Sep 2020 09:27:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E0A0221E8 for ; Mon, 28 Sep 2020 09:27:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbgI1J1F (ORCPT ); Mon, 28 Sep 2020 05:27:05 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:42264 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726674AbgI1J1F (ORCPT ); Mon, 28 Sep 2020 05:27:05 -0400 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 CC: Zhen Lei , Libin , Kefeng Wang 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -- 1.8.3