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=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 9FBC0C2D0A8 for ; Mon, 28 Sep 2020 12:59:45 +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 537972068E for ; Mon, 28 Sep 2020 12:59:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UfHxaKtm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 537972068E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F1yvzmj3XO/33mHAyY58bInqlnvliiYD/CMmbQPKNeA=; b=UfHxaKtmu9W9odh1AU2SlkP7u GbQbq4LPFvVD7iQoq8HHXQv45PxJ9XRMBANjHoDEdrNL9SoZQJ/mleM0+TSKTg059T/njmpFa0Sz+ oVycovzy1ZHdfmUz1hzlgWmA0HKbY11qFUSaJwPbnuGO37GsaI7gJ0s3ugtQSL6MhVuEm+dg+RefX QW45Z2tO2hscYjIyrM5loto0JTVaxHWKWdKwCl8nqYj2x5mYfiKpK2J3ZpYhototLZwIyb0ndNCMP Cuz5n8mxNK34ESPQxTcJ/FsYt28tkwvp6vtcjQxeXBr69xBFrIsPfj7H10D7G/fLbms7qUFaaQrUK 1VkmlnRsg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMsjY-0000uF-Ps; Mon, 28 Sep 2020 12:58:24 +0000 Received: from mail-ot1-f67.google.com ([209.85.210.67]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMsjN-0000q8-Kp for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 12:58:17 +0000 Received: by mail-ot1-f67.google.com with SMTP id c2so776597otp.7 for ; Mon, 28 Sep 2020 05:58:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3saIS3hHmut30qTXV6lWeJ53gdiOKPXligB+1QcwTJU=; b=SLD+Aef44M+W3lSnrU9TCc/4IYdDoppf0jqdf4NsubarHPI3UomOECpjFiJ+sdJCq3 khAKCWzdIA6mlDn4blOe74o9ljYar/2Iu8jDW2ggWeY8SnTWBkQh2Mw4gCZTJUhYrtGY PzpS5jI+6hZN0pednxbrW3G944bQjpxmVPwm8YaTWgHBfCrGL5wIwf+jiGcCX/Xmlt1h mRGv5BFz7T4UBb6/phgKRf41qiBTjaQZ4RIqMwmMrb+596OYhljkPcj4QAWHGbmPsTVR gCanUrmpjsRABbvWazMBzAWzXLFPOpLyCdenrT3AZztpl/uHyz3+JAD69dD+/VeWobqN fVHQ== X-Gm-Message-State: AOAM530uWOJi3Y8chdI0lBdQzg8rBMVpp2cgTvxIJL7fo+uSeRITLeam y7fP5eabMdY6g0G3W0c4BBOS4e0C1P7+niUhUTmA/QTC X-Google-Smtp-Source: ABdhPJy1GXHmBYkrYjhw8L10FVIRtTxjX47/xIIfxeNFvlfVbbPFpss+xVpzuDTTXDyA5SU9gQc0Ewv27FRCa1/afcA= X-Received: by 2002:a05:6830:1008:: with SMTP id a8mr791234otp.107.1601297891277; Mon, 28 Sep 2020 05:58:11 -0700 (PDT) MIME-Version: 1.0 References: <20200928092641.2070-1-thunder.leizhen@huawei.com> <20200928092641.2070-3-thunder.leizhen@huawei.com> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 28 Sep 2020 14:57:59 +0200 Message-ID: Subject: Re: [PATCH 2/2] ARM: decompressor: relax the loading restriction of the decompressed kernel To: "Leizhen (ThunderTown)" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_085813_745370_E0A7CFD6 X-CRM114-Status: GOOD ( 28.58 ) 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 , linux-kernel , Russell King , Libin , Ard Biesheuvel , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Zhen, On Mon, Sep 28, 2020 at 2:15 PM Ard Biesheuvel wrote: > On Mon, 28 Sep 2020 at 13:57, Leizhen (ThunderTown) > wrote: > > On 2020/9/28 18:14, Ard Biesheuvel wrote: > > > On Mon, 28 Sep 2020 at 11:27, Zhen Lei wrote: > > >> > > >> 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 > > > > > > No, this won't work. > > > > But it works well on my board. > > > > That is because you load zImage at the base of DRAM. > > > > > > > The whole reason for rounding to a multiple of 128 MB is that we > > > cannot infer the start of DRAM from the placement of the zImage (which > > > provides _start). > > > > Maybe this is further guaranteed by the following code: > > /* > > * Set up a page table only if it won't overwrite ourself. > > * That means r4 < pc || r4 - 16k page directory > &_end. > > * Given that r4 > &_end is most unfrequent, we add a rough > > * additional 1MB of room for a possible appended DTB. > > */ > > > > In addition, the Image has already been loaded when this position is reached. > > > > ----------- <--128MiB boundary > > | | > > ----------- <--TEXT_OFFSET <-- > > | (1)Image | | > > ------------ | > > | | | > > ----------- (2)--copyto----- > > | (2)Image | > > ----------- > > > > I don't think it's the case of (2), but (1). Because no code modification is > > required for the case (2). > > > > By the way, I'm not familiar with the arm32 code, so I'm just speculating. > > > > The zImage code that runs has not received *any* information from the > platform on where DRAM starts, so the only info it has is the current > placement of zImage. > > So when zImage is loaded at the intended base of DRAM, things work fine. > > If the zImage is loaded close to the end of a 128 MB region, the > rounding would pick the start of that 128 MB region. However, the > _start symbol you are using will point to an address that is close to > the end of the 128 MB [given that it is inside zImage] so your logic > will pick an address that is much higher in memory. https://people.kernel.org/linusw/how-the-arm32-linux-kernel-decompresses https://people.kernel.org/linusw/how-the-arm32-kernel-starts are good reads. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel