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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 BC1F0C43460 for ; Mon, 17 May 2021 15:02:51 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5205F61019 for ; Mon, 17 May 2021 15:02:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5205F61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=F/dcR9VtZfVjQ0+bNXiBtAZdc/hKp6RcdzjoQStAogg=; b=Az/1ElSqu5D0KurK9+B9SWOI1 sezcu6UZrouXviC6+aXrTyft5V3rcHv/rzf5+3wwTByKYxxzAAk4udDkhOO0PXSYRVriZ7KF5+YVX TTD9fuVdH5qf5ZsRLQyG0T3t8mkUx2SPlLRzRCwmXhS5gcPRk0UorDktUm/ZxvhGpQLn+sBNf8/F0 4NYPpxaI2Rg0U52p5O5XNmzPI9MhK3rP7GEE9HkXOF/e8MMLhx9ynA2xdLy4Q3TpFl6lj1SS5SMnN W+CX4lhebT3/iUF2jTyCF6ESOPmkqo1KfDdK8mvYxAjl3efIubmdj91T9FBoDvN5KpMvbXkStaWYK J3FYY8blg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1liejw-00FLFz-UZ; Mon, 17 May 2021 15:01:05 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1liejj-00FLDr-TZ for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 15:00:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Zk629r6AyRIib1Jb23k9ic0+RwK6DtrYkCA9W0DTKO4=; b=rQFNJ44c5QAM5iP1r729VyNVgE aPskfW5wHYqCXNyDnV2wQi6QCtxZAk+k2Iw3+3ct15pbKw/ndjPeU0LFm6n21zVPi584Ye36T+S8C AzU8VKb4xrIrsjF9xK5E7WMCvyzLKYW3CYe1NrPyFkZAVSMemnoKoDwpKoCwVAm3IxF3Ar/OCWPnD Fh2TjdgYPSUY10NynoTljOIKJXFF9N3ykFL5C4jELpLHnI7W8d3UUPrnZ+wpcpASwjX92RzCk7GVJ 0x4zWe7FdWpf73yNtWwGGmSZRbtsCBz4TK1n+B+d8SVqDoV3kO+hdhDbodNeT6UUH4t7UXONz/eS8 mMkfB5FA==; Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lieje-00DtQy-7j for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 15:00:50 +0000 Received: by mail-lj1-x233.google.com with SMTP id b12so402479ljp.1 for ; Mon, 17 May 2021 08:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zk629r6AyRIib1Jb23k9ic0+RwK6DtrYkCA9W0DTKO4=; b=tYTBnGQVaxqaSHJ/6gTMmAJwi05z67Nrb/PDWORyd9cK8i95Wh6YUMer3nEV6Mpt8w VXkA1VNpVcQddi+ILnm7ykBHskEbdIpjwzuQsbYyGredgeq7RVh5x8iGL5ypJcDhHdPq aiwbv49IlJRo0gK1TNfLRZAHSTkSvWdQ3gB4IebwJhQQ2GKRp5+3/BVArGUQR1pFPSXb na6mia7KcVMiOQBhSBbVqgtcWxxlbKC4YOFS0kcuBLF7Acp2BhMw4/q8ZTXembGvy0q7 rOSQ4meNO5xV0UZ5sGK+gW4UlbJPzHjpSx/vo5BMRPFHoeLwAKbbInItc7Xm8RS4TqCJ wZfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zk629r6AyRIib1Jb23k9ic0+RwK6DtrYkCA9W0DTKO4=; b=m3TOzChnwiSbNQ2OXTixK/IRKkbCKGA5aPLLCGkVECyxPXc4M4S+EXJcEPbhvTOKI8 K/xZZRH4y9JIsUIz2xrALy4sVS6lpipiiqm0hli+D92nHmqQ80TeL17AeHLsokBXMYv+ 0BKdpP18iiI66UTsEsNZgD4pzzYkSmwQRd/w6Shj1C311uGlcFfy994KEr3P8Z2Oprti hpoY4HPcT2VTk814gICXP+tOyr8w7YrpAYa/BoDoHFoy8ROQu5LrvOjZP+CZLJ1LgXI/ vlqT6vzo3vn9kEcOY7F5l2R8v7nw6jzHITC59yBTs/kJ8pUL7ZHfGO8mG50bq5PetP9v mYag== X-Gm-Message-State: AOAM533Dt4JnkHzG4kEvOVyxQ8FXZA+31iqyv6h0RoiAr/U2eemamMny csrDOmttODwVvYHzNzd7tWM4Xi0jLdGpXg== X-Google-Smtp-Source: ABdhPJzm98FRbuu5JZwlXYleREu/Ko71xac7/UH2L7zMad7Fr6RZvip6ixkzWYT6Zxy5kpTwu/M2hA== X-Received: by 2002:a05:651c:210:: with SMTP id y16mr47466516ljn.279.1621263644020; Mon, 17 May 2021 08:00:44 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id h13sm2863080lji.102.2021.05.17.08.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 08:00:43 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, Russell King , Arnd Bergmann Cc: Florian Fainelli , Geert Uytterhoeven , Ard Biesheuvel , Linus Walleij Subject: [PATCH 2/3] ARM: Define kernel physical section start and end Date: Mon, 17 May 2021 16:57:18 +0200 Message-Id: <20210517145719.110966-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517145719.110966-1-linus.walleij@linaro.org> References: <20210517145719.110966-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210517_080046_297553_FA86F7E6 X-CRM114-Status: GOOD ( 20.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 When we are mapping the initial sections in head.S we know very well where the start and end of the kernel image in physical memory is placed. Later on it gets hard to determine this. Save the information into two variables named kernel_sec_start and kernel_sec_end for convenience for later work involving the physical start and end of the kernel. These variables are section-aligned corresponding to the early section mappings set up in head.S. Signed-off-by: Linus Walleij --- arch/arm/include/asm/memory.h | 7 +++++++ arch/arm/kernel/head.S | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index a5f1d1826a98..ca213d7d095f 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -158,6 +158,13 @@ extern unsigned long vectors_base; #ifndef __ASSEMBLY__ +/* + * Physical start and end address of the kernel sections. These addresses are + * 2MB-aligned to match the section mappings placed over the kernel. + */ +extern phys_addr_t kernel_sec_start; +extern phys_addr_t kernel_sec_end; + /* * Physical vs virtual RAM address space conversion. These are * private definitions which should NOT be used outside memory.h diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 4e2daaa7636a..9eb0b4dbcc12 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -47,6 +47,20 @@ .globl swapper_pg_dir .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE + /* + * This needs to be assigned at runtime when the linker symbols are + * resolved. + */ + .pushsection .data + .align 2 + .globl kernel_sec_start + .globl kernel_sec_end +kernel_sec_start: + .long 0 +kernel_sec_end: + .long 0 + .popsection + .macro pgtbl, rd, phys add \rd, \phys, #TEXT_OFFSET sub \rd, \rd, #PG_DIR_SIZE @@ -229,16 +243,23 @@ __create_page_tables: blo 1b /* - * Map our RAM from the start to the end of the kernel .bss section. + * The main matter: map in the kernel using section mappings, and + * set two variables to indicate the physical start and end of the + * kernel. */ - add r0, r4, #PAGE_OFFSET >> (SECTION_SHIFT - PMD_ORDER) + add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ORDER) ldr r6, =(_end - 1) - orr r3, r8, r7 + adr_l r5, kernel_sec_start @ _pa(kernel_sec_start) + str r8, [r5] @ Save physical start of kernel + orr r3, r8, r7 @ Add the MMU flags add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ORDER) 1: str r3, [r0], #1 << PMD_ORDER add r3, r3, #1 << SECTION_SHIFT cmp r0, r6 bls 1b + eor r3, r3, r7 @ Remove the MMU flags + adr_l r5, kernel_sec_end @ _pa(kernel_sec_end) + str r3, [r5] @ Save physical end of kernel #ifdef CONFIG_XIP_KERNEL /* -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel