From patchwork Thu Sep 5 13:01:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13792346 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 D8BD9CD5BC0 for ; Thu, 5 Sep 2024 13:02:34 +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=5ksL9A9rh0mu4WvnLlasYj0UvFsMJ3ced0ZyNYxBMPw=; b=BVgF+ReAzzKKDRGhwLzYRq6Tvf jcXc+a+geUrpGJb1k5jIf0TQk+XY8kMQPguXdSLoaJM0ESzXL6Ea+rSFxPd/divBqTllcy7k+GEk8 0oofBkAOAQyPIQ5IPtxptN16Ih7PyfVcUwDCqn4dOvhvoGwi0AD4hnFWcu84JvNzYBMowCZlF6HQ3 jTOlstuHL332h4Pj3yGiPKql2lqTnXEHIpxtV/tgJM6zbu0ngn8GSerfnsgcP5O5bNRUYhdkXmTzj bEEVvuo0G4SyDmS9KVL/e3EloUcsqb8cmNg5Qvf8WNeT+xt83x2eGxY074fJd8khB15BsbQXtnxNx CxB8F8Ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smC7z-00000008S1i-3YOE; Thu, 05 Sep 2024 13:02:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smC71-00000008RtA-0YMX for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 13:01:24 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F030DFEC; Thu, 5 Sep 2024 06:01:48 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E73A03F73F; Thu, 5 Sep 2024 06:01:20 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, joey.gouly@arm.com, mark.rutland@arm.com, rongqianfeng@vivo.com, will@kernel.org, Ard Biesheuvel , Andrew Morton , Baoquan He Subject: [PATCH v1] arm64/mm: use lm_alias() with addresses passed to memblock_free() Date: Thu, 5 Sep 2024 14:01:15 +0100 Message-Id: <20240905130115.4135490-1-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_060123_242555_59A8767D X-CRM114-Status: GOOD ( 11.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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org __init_begin and __init_end are kernel image addresses, use lm_alias() to convert them to linear mapping addresses. This fixes the following splat at boot time (seen with CONFIG_DEBUG_VIRTUAL=y): [ 1.574253] virt_to_phys used for non-linear address: ffff800081270000 (set_reset_devices+0x0/0x10) [ 1.574272] WARNING: CPU: 0 PID: 1 at arch/arm64/mm/physaddr.c:12 __virt_to_phys+0x54/0x70 [ 1.574291] Modules linked in: [ 1.574300] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.11.0-rc6-next-20240905 #5810 b1ebb0ad06653f35ce875413d5afad24668df3f3 [ 1.574316] Hardware name: FVP Base RevC (DT) [ 1.574324] pstate: 2161402005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) [ 1.574338] pc : __virt_to_phys+0x54/0x70 [ 1.574351] lr : __virt_to_phys+0x54/0x70 [ 1.574365] sp : ffff80008169be20 [...] [ 1.574568] Call trace: [ 1.574574] __virt_to_phys+0x54/0x70 [ 1.574588] memblock_free+0x18/0x30 [ 1.574599] free_initmem+0x3c/0x9c [ 1.574610] kernel_init+0x30/0x1cc [ 1.574624] ret_from_fork+0x10/0x20 Fixes: 1db9716d4487 ("arm64/mm: Delete __init region from memblock.reserved") Signed-off-by: Joey Gouly Suggested-by: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Rong Qianfeng --- Saw this when trying out next-20240905. arch/arm64/mm/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 0bde16aadc83..f24095bd7e7d 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -411,8 +411,8 @@ void __init mem_init(void) void free_initmem(void) { - unsigned long aligned_begin = ALIGN_DOWN((u64)__init_begin, PAGE_SIZE); - unsigned long aligned_end = ALIGN((u64)__init_end, PAGE_SIZE); + unsigned long aligned_begin = ALIGN_DOWN((u64)lm_alias(__init_begin), PAGE_SIZE); + unsigned long aligned_end = ALIGN((u64)lm_alias(__init_end), PAGE_SIZE); /* Delete __init region from memblock.reserved. */ memblock_free((void *)aligned_begin, aligned_end - aligned_begin);