From patchwork Wed Jul 31 11:39:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harith George X-Patchwork-Id: 13748572 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B728AC3DA7F for ; Wed, 31 Jul 2024 11:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=eLclCjvWmzDVskwplMLBw1uSn78KDC7EwkI18+XKFCg=; b=HDeccnFqntRihWfS8hAy0aJXmW uQyqreDf/YvFopmazGbEVUP4j+iffhy4vuM3VkTChUfrYukSk4aoboaadKhnAoH65RyxOmviAP2eX /0cQRARJ4BEgeTxb51OiiHCM9DX9LvOvdj4+cU3TziRrJ33alFX2Tn7KQgRJOPcRcC+W+jpV9Jz2p WE2d9MVK0WynOEAnV02fSR92UH2QwS6izGrkrLST7QSlMjYS2eB6A48eKMtIyIAO0nMW/Ln3oGCeq Ut0IxSZMKrxD8GWtA0EjjTOCbF2aa9Dntbrluxi9OTQ/nt1/S0SN4akpWqSRSfQoO8fNnJgev78um s0eX2cWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ7gP-00000000w7V-3KdR; Wed, 31 Jul 2024 11:39:53 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ7fx-00000000vzp-0aTz for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 11:39:26 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-70d19d768c2so4222609b3a.3 for ; Wed, 31 Jul 2024 04:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722425964; x=1723030764; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eLclCjvWmzDVskwplMLBw1uSn78KDC7EwkI18+XKFCg=; b=AoKWuaSf7cBHm6eY7x4kAxxTh2VFZXeYUTzZeJ0CercThfJd91d20x3ZtrdwjqPyH2 OWOZuRYIpryCdpCUZKsmEuD0UTQtwTsPBwRFnqgY7JBY52NPxFmBJxGsGjcWmqCVf0Y7 dR+E8jKh/Lu5h7+lu33oe39lZEEyykCq+4qQ56WCWYGKGt5lau10Hw7piopW4dUPKO9S 4NnsHlc5Fn3UAsaoGh6wll9eXIbznBko+gFw2heah5Yo+Ovfm+TT15bxRY27zh25g0gt Q59nvKiF3dUANgVw7F+DXzrQvosbZNNK4tNkRDh7ruCXACbBGI5Ei30r4JhwSOawIrKr 59ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722425964; x=1723030764; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eLclCjvWmzDVskwplMLBw1uSn78KDC7EwkI18+XKFCg=; b=Ze4P7N/M7x4Vf3PdukaQcbolT97nwlz5CItSZThIB+VJb5uHWhdYCPJCjZDqVmNoHZ 6krabMx/CtLkjrXHS0kpCNb35Dp44pO5OK7DjhvDlS2Jw7GrA3ZrkY3zP/6hXeHunVs+ pVFScCn4U25OlYU9q5mkvxKZsAvkdw4LzZkmvVEVVYMRZuZzZvhiH/us7D8umW/j0sKl eOtbJqiO38Oz8BJbION/WBsmRPHeOnQvhJ7JcV31LULf96GCtlfv0XnJvq3sfsKFSZ4/ R5VQFBtV74uYS5E6T0xy1jfepsWiSPJUdZJ+Ks65u5eyqHa9Z8gS/t3VfoVWPmF3/Qjc vr3A== X-Forwarded-Encrypted: i=1; AJvYcCXGDoT1kB8ISvq7dSczTpoYTqwEXNF+quuDWt/bXRB1pnlTJcX+zR8D1ZijOrRgqIVkyv2KdvKKf+7X3iU4XnWUJRE8afVESYRAjoWgEifdXYpDIB8= X-Gm-Message-State: AOJu0Yw6ieMgky2gETSC3xmrsvcZgIKSyYrRB78hCOdc9B7pNUMGrTzE gU7wtOK9EUM0FFHCwggUUa1CyXfTRmtd30Bnfb0V0vMjZm9Psjsf X-Google-Smtp-Source: AGHT+IEC2QxBU4qtJWH66S0e//PI9jURHmJfotISS0SZIVdP3MgLEpncrKN9daK8Bt/bNO4NKaaq9Q== X-Received: by 2002:a05:6a20:7354:b0:1bd:1d6e:d444 with SMTP id adf61e73a8af0-1c4a118279emr13946423637.2.1722425963927; Wed, 31 Jul 2024 04:39:23 -0700 (PDT) Received: from alif.. ([14.195.28.86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead6e15d7sm9748343b3a.22.2024.07.31.04.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:39:23 -0700 (PDT) From: Harith George To: linus.walleij@linaro.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: harith.g@alifsemi.com, akpm@linux-foundation.org, rppt@kernel.org, rmk+kernel@armlinux.org.uk, m.szyprowski@samsung.com, vishal.moola@gmail.com, david@redhat.com, willy@infradead.org, nico@fluxnic.net, ardb@kernel.org Subject: [PATCH 1/2] arm: mm: Fix kernel memory mapping for xip kernels Date: Wed, 31 Jul 2024 17:09:04 +0530 Message-Id: <20240731113905.3326586-1-mail2hgg@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_043925_225976_8E82F699 X-CRM114-Status: GOOD ( 21.34 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Harith George The patchset introducing kernel_sec_start/end variables to separate the kernel/lowmem memory mappings, broke the mapping of the kernel memory for xipkernels. kernel_sec_start/end variables are in RO area before the MMU is switched on for xipkernels. So these cannot be set early in boot in head.S. Fix this by setting these after MMU is switched on. xipkernels need two different mappings for kernel text (starting at CONFIG_XIP_PHYS_ADDR) and data (starting at CONFIG_PHYS_OFFSET). Also, move the kernel code mapping from devicemaps_init() to map_kernel(). Fixes: a91da5457085 ("ARM: 9089/1: Define kernel physical section start and end") Signed-off-by: Harith George Reviewed-by: Linus Walleij --- arch/arm/kernel/head.S | 8 ++++++-- arch/arm/mm/mmu.c | 34 +++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 1ec35f065617..28873cda464f 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -252,11 +252,15 @@ __create_page_tables: */ add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ENTRY_ORDER) ldr r6, =(_end - 1) + + /* For XIP, kernel_sec_start/kernel_sec_end are currently in RO memory */ +#ifndef CONFIG_XIP_KERNEL adr_l r5, kernel_sec_start @ _pa(kernel_sec_start) #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32 str r8, [r5, #4] @ Save physical start of kernel (BE) #else str r8, [r5] @ Save physical start of kernel (LE) +#endif #endif orr r3, r8, r7 @ Add the MMU flags add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ENTRY_ORDER) @@ -264,6 +268,7 @@ __create_page_tables: add r3, r3, #1 << SECTION_SHIFT cmp r0, r6 bls 1b +#ifndef CONFIG_XIP_KERNEL eor r3, r3, r7 @ Remove the MMU flags adr_l r5, kernel_sec_end @ _pa(kernel_sec_end) #if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32 @@ -271,8 +276,7 @@ __create_page_tables: #else str r3, [r5] @ Save physical end of kernel (LE) #endif - -#ifdef CONFIG_XIP_KERNEL +#else /* * Map the kernel image separately as it is not located in RAM. */ diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index f11bf84aa3a2..537f94cd6012 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1402,18 +1402,6 @@ static void __init devicemaps_init(const struct machine_desc *mdesc) create_mapping(&map); } - /* - * Map the kernel if it is XIP. - * It is always first in the modulearea. - */ -#ifdef CONFIG_XIP_KERNEL - map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK); - map.virtual = MODULES_VADDR; - map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK; - map.type = MT_ROM; - create_mapping(&map); -#endif - /* * Map the cache flushing regions. */ @@ -1603,12 +1591,27 @@ static void __init map_kernel(void) * This will only persist until we turn on proper memory management later on * and we remap the whole kernel with page granularity. */ +#ifdef CONFIG_XIP_KERNEL + phys_addr_t kernel_nx_start = kernel_sec_start; +#else phys_addr_t kernel_x_start = kernel_sec_start; phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE); phys_addr_t kernel_nx_start = kernel_x_end; +#endif phys_addr_t kernel_nx_end = kernel_sec_end; struct map_desc map; + /* + * Map the kernel if it is XIP. + * It is always first in the modulearea. + */ +#ifdef CONFIG_XIP_KERNEL + map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK); + map.virtual = MODULES_VADDR; + map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK; + map.type = MT_ROM; + create_mapping(&map); +#else map.pfn = __phys_to_pfn(kernel_x_start); map.virtual = __phys_to_virt(kernel_x_start); map.length = kernel_x_end - kernel_x_start; @@ -1618,7 +1621,7 @@ static void __init map_kernel(void) /* If the nx part is small it may end up covered by the tail of the RWX section */ if (kernel_x_end == kernel_nx_end) return; - +#endif map.pfn = __phys_to_pfn(kernel_nx_start); map.virtual = __phys_to_virt(kernel_nx_start); map.length = kernel_nx_end - kernel_nx_start; @@ -1762,6 +1765,11 @@ void __init paging_init(const struct machine_desc *mdesc) { void *zero_page; +#ifdef CONFIG_XIP_KERNEL + /* Store the kernel RW RAM region start/end in these variables */ + kernel_sec_start = CONFIG_PHYS_OFFSET & SECTION_MASK; + kernel_sec_end = round_up(__pa(_end), SECTION_SIZE); +#endif pr_debug("physical kernel sections: 0x%08llx-0x%08llx\n", kernel_sec_start, kernel_sec_end); From patchwork Wed Jul 31 11:39:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harith George X-Patchwork-Id: 13748573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EDEA5C3DA64 for ; Wed, 31 Jul 2024 11:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ufe9f1aVq4XJvqV0V6RRRWx503LS6so5gVk+Ooe+2bY=; b=V1a/f8m6nsmTZymaq7NiMMSE4a ZlslUWsJuuMMpWTeGiHl7KViYx4kmM113J1p1krRqTw7EdA2aRwVZeUGtKF2mA9gUuR3POdcboIXy 36gwBTjwGPF/AuFGGMBAuZPY7WO6e8RW/ujx/9SQ5/DeiGHj4VVNbm6nevGT3MNnsr4UQ7DndSZZV gfqWASP+Y0CnjihKWvn1Id78x2HfCsP1OrdNOr1S9hKlVBN59ipTdxfn6eZ+odkO5966k73fKAiQH N2OpnOYPFuaTfY2XaAqA42yL+jRruAIGzp+iXgDgWOU52h8a36OMxpp5ZVJ+z49MpmZ9/vDyIRS6I Jesl+scA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ7gq-00000000wCc-0Bzy; Wed, 31 Jul 2024 11:40:20 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZ7g6-00000000w1c-2bGJ for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 11:39:36 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7104f939aaaso397250b3a.1 for ; Wed, 31 Jul 2024 04:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722425973; x=1723030773; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ufe9f1aVq4XJvqV0V6RRRWx503LS6so5gVk+Ooe+2bY=; b=Sj5vFpOC7uTvSrpOBEPERFofwt4XDuBjyi6G14zIeEbjqEj+gjucX+XXJWAs84RAZZ JmJAK+KLnEjjTOFSYhxffqr/31KI+IC1N9fFhF6+pt0qM/yBm3/0xnLa7kqPVZuXdtbV q8zH4mG1Y/TjuhCYm/G0vzv1GFB4BLJ6jStVyhmLShW0oFuNj1XlsGTUIRfy4aVbbFtV c1RORLsrGART4OMsQx/lErHkP12eGgjtGRwV/Z8lwW0UeZzNnpoR9vhlpb+gtQZSSLuZ ZVsPE8qCojYTWJuXEeTJSeLjyrK7kTR+wmVAQGfg3md7miP5vs8d6m2QNPGweEnM9qSl 3NCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722425973; x=1723030773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ufe9f1aVq4XJvqV0V6RRRWx503LS6so5gVk+Ooe+2bY=; b=mEZS6X9nyB7JNl5hyJO8BjoXzd4YVQYJCQXnQuR4I4QYKql367Ag9rgtm8CWxNhpNQ EEzIbu/pHo3z9v/1v6vLBvpxIpj75K90KuaQwMNvAc+0uWfZNOouoIFI5O/0D/POQw2O TEs0AwjqX7oOL2LQOh1tADHFgP99RQY36VWCRNSo7MkAAKUYblWZ020uTvuP4XaU311u JCZALnKTCmcZ+GbU1NM4b2sZ8H6SR7btJWoznORdpkbtDmEOArOk9aNu0cSGsmaULcMA IbY/tlTvAQPLVfv7mG1wdYsACOJpmi081V5v2ySnRNIsDtTSoFpMwTzPdmAiMvQV49ql SKQA== X-Forwarded-Encrypted: i=1; AJvYcCXU2zVLr8ghXOFVsO+sxINa0r+Bv364p3qnZ0rd6SIWQ810cKttA7u5apba756cyGucSMbHKliIllq4g4x5bVlLU869HedenQg5seDgwTg2H1q76cw= X-Gm-Message-State: AOJu0YwiPbCh7NL4jsYejbbVbNrAGap7kyETWzjBIba9joPI+ab7hxr/ 7v0UT6TA+rjbhB6/ET9UaBNH44cOEKjxYJ/ZQSvQaQ48kmuvvbWb X-Google-Smtp-Source: AGHT+IEpWQE0PpAjVOudxt5MtO5UL/YgFmAYeA5XrPyfqeIgzsAv3P4uAhWllcuzmQBA9T4/qgErtg== X-Received: by 2002:a05:6a20:7284:b0:1c4:936e:b8a2 with SMTP id adf61e73a8af0-1c4a12cd2f2mr13742329637.27.1722425973414; Wed, 31 Jul 2024 04:39:33 -0700 (PDT) Received: from alif.. ([14.195.28.86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead6e15d7sm9748343b3a.22.2024.07.31.04.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 04:39:33 -0700 (PDT) From: Harith George To: linus.walleij@linaro.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: harith.g@alifsemi.com, akpm@linux-foundation.org, rppt@kernel.org, rmk+kernel@armlinux.org.uk, m.szyprowski@samsung.com, vishal.moola@gmail.com, david@redhat.com, willy@infradead.org, nico@fluxnic.net, ardb@kernel.org Subject: [PATCH 2/2] arm: smp: Fix SMP for xip kernels Date: Wed, 31 Jul 2024 17:09:05 +0530 Message-Id: <20240731113905.3326586-2-mail2hgg@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731113905.3326586-1-mail2hgg@gmail.com> References: <20240731113905.3326586-1-mail2hgg@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_043934_759785_AB5AAD69 X-CRM114-Status: GOOD ( 13.09 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Harith George Fix the physical address calculation of the following to get smp working on xip kernels. - secondary_data needed for secondary cpu bootup. - secondary_startup address passed through psci. - identity mapped code region needed for enabling mmu for secondary cpus. Signed-off-by: Harith George --- arch/arm/kernel/head.S | 4 ++++ arch/arm/kernel/psci_smp.c | 7 +++++++ arch/arm/mm/idmap.c | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 28873cda464f..f22c50d4bd41 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -411,7 +411,11 @@ ENTRY(secondary_startup) /* * Use the page tables supplied from __cpu_up. */ +#ifdef CONFIG_XIP_KERNEL + ldr r3, =(secondary_data + PLAT_PHYS_OFFSET - PAGE_OFFSET) +#else adr_l r3, secondary_data +#endif mov_l r12, __secondary_switched ldrd r4, r5, [r3, #0] @ get secondary_data.pgdir ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE: diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c index d4392e177484..3bb0c4dcfc5c 100644 --- a/arch/arm/kernel/psci_smp.c +++ b/arch/arm/kernel/psci_smp.c @@ -45,8 +45,15 @@ extern void secondary_startup(void); static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle) { if (psci_ops.cpu_on) +#ifdef CONFIG_XIP_KERNEL + return psci_ops.cpu_on(cpu_logical_map(cpu), + ((phys_addr_t)(&secondary_startup) + - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + + CONFIG_XIP_PHYS_ADDR)); +#else return psci_ops.cpu_on(cpu_logical_map(cpu), virt_to_idmap(&secondary_startup)); +#endif return -ENODEV; } diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c index 448e57c6f653..4a833e89782a 100644 --- a/arch/arm/mm/idmap.c +++ b/arch/arm/mm/idmap.c @@ -84,8 +84,15 @@ static void identity_mapping_add(pgd_t *pgd, const char *text_start, unsigned long addr, end; unsigned long next; +#ifdef CONFIG_XIP_KERNEL + addr = (phys_addr_t)(text_start) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + + CONFIG_XIP_PHYS_ADDR; + end = (phys_addr_t)(text_end) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + + CONFIG_XIP_PHYS_ADDR; +#else addr = virt_to_idmap(text_start); end = virt_to_idmap(text_end); +#endif pr_info("Setting up static identity map for 0x%lx - 0x%lx\n", addr, end); prot |= PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AF;