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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 751A6C07E95 for ; Tue, 20 Jul 2021 00:49:54 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6FCE610F7 for ; Tue, 20 Jul 2021 00:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6FCE610F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2818881BDA; Tue, 20 Jul 2021 02:49:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N3wlhuuH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A46B481BE8; Tue, 20 Jul 2021 02:49:50 +0200 (CEST) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 04F1881BC0 for ; Tue, 20 Jul 2021 02:49:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel.schwierzeck@gmail.com Received: by mail-wm1-x32e.google.com with SMTP id m11-20020a05600c3b0bb0290228f19cb433so531149wms.0 for ; Mon, 19 Jul 2021 17:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ZflraLWroMz7R25o4+NkcFxJpkIFqds/McbwMAlh4Io=; b=N3wlhuuHmN+QK9QzqAe+A/HLbjtOB6NRJIFJ+0r6akxEAJNDYrz+4CL5vuAORJ0p/O CuzR5NjA/l8/aKtrCbCJ9wapz7l21OUQwbhHIESpU+9e7qsRV/6eoYdaMdd9fcwMEXMs avpbSqBS39EQUvQfdvoef/KM/DxbF9p9PMnsh2LrVEuvnUv7LjlDQ+1J0J0ZuCXmvEtO n90ohftParzz86gfLRuN04Jar9C04edGMYDFsn9eEQ4fhYmK7L+Dph84luFcDSBYahqc 3sQJXd5MfTn+e2AAn1Z8I91uhZVqtBaDSf9J1Sh8A3yaR8TI6C/+LUxuXK3DEILYGjLw I4Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ZflraLWroMz7R25o4+NkcFxJpkIFqds/McbwMAlh4Io=; b=WWOaKl64FqQH30UALmzD/g5Yv3ApPWnExabj5KBUMHybNY6D6R9qYaOHvpB2ccu4l0 Xayl7fcU+Emusrq47+p0cW1+dnxxaup/bJ8twddCLsLdPQiMc6fu+bXX5nOVPDpeDYfT hoqnBEFTs7nsGr7oG1dwAsd7+Ai0kw5H3t3aYq+MjffkvnBg1AecIV6v6raTQuqWZiZP RRbzkpNJiw9B7PTbqXNCcHzAjCHedbMUpuCp6PKxF7SbqPayIHExdYnp2OsDSjV7wGJY Aro0hno7FXBhSGYWyFUhtKP7yu4mijFyA689Y9i8Wh1Mc9f/elTnbTYkWPnu0w8s3HG4 icyA== X-Gm-Message-State: AOAM530fQHIbrPGc9DafiqH3r3Eo/oTo/eE7cJtPAyJt3r0mjUR3X8dT 4AMOGiU1ofDHNEAOceMPalA= X-Google-Smtp-Source: ABdhPJwijmq7PYeJ7/xU4EBKC3JsfO26mUaC/Wv8s1iHMATdMKUNfE/KjjWm5Q/56Ysdr5Sw/1I0BQ== X-Received: by 2002:a05:600c:a45:: with SMTP id c5mr35892212wmq.153.1626742186524; Mon, 19 Jul 2021 17:49:46 -0700 (PDT) Received: from unifi.lan.schwierd.dedyn.io (i5E86073A.versanet.de. [94.134.7.58]) by smtp.googlemail.com with ESMTPSA id a7sm11452097wru.67.2021.07.19.17.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 17:49:45 -0700 (PDT) Message-ID: Subject: Re: U-Boot loaded RAMDisk crashes Linux on MT7623 From: Daniel Schwierzeck To: Daniel Golle , u-boot@lists.denx.de Cc: Weijie Gao =?UTF-8?Q?=28=E9=AB=98=E6=83=9F=E6=9D=B0=29?= , Alvin Kuo =?UTF-8?Q?=28=E9=83=AD=E6=81=92=E6=BA=90=29?= , Steven Liu =?UTF-8?Q?=28=E5=8A=89=E4=BA=BA=E8=B1=AA=29?= , Mark-MC Lee =?UTF-8?Q?=28=E6=9D=8E=E6=98=8E=E6=98=8C=29?= , Sam Shih =?UTF-8?Q?=28=E5=8F=B2=E7=A2=A9=E4=B8=89=29?= , John Crispin Date: Tue, 20 Jul 2021 02:49:44 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Daniel, Am Montag, den 19.07.2021, 18:34 +0100 schrieb Daniel Golle: > Hi, > > I writing in the hope that someone has a good idea about why U-boot > is > handing over a broken memory address for a loaded ramdisk which > results > in Linux crashing very early on boot on MediaTek's MT7623N SoC > (ARMv7). > If anyone has a good idea why this is happening, I'd be very glad, as > this currently prevents me from updating that target in OpenWrt. > Background: > OpenWrt used to have the initramdisk built-into the kernel itself. > Having it separate is nicer as then you won't need to recompile the > kernel or even have a compiler installed in order to modify the > ramdisk. This already works great on MT7622 and it'd be great to have > it the same way on MT7623 (and MT7629 in future). > > So when loading a uImage.FIT with RAMDisk subimage to me it looks > like > U-Boot is not translating the address of the ramdisk correctly, see > logs below: > > U-Boot> tftpboot 0x88000000 openwrt-mediatek-mt7623-bpi_bananapi-r2- > initramfs-recovery.itb > Using ethernet@1b100000 device > TFTP from server 192.168.5.2; our IP address is 192.168.5.100 > Filename 'openwrt-mediatek-mt7623-bpi_bananapi-r2-initramfs- > recovery.itb'. > Load address: 0x88000000 > Loading: > ################################################################# > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > ############################################################ > ##### > 13 MiB/s > done > Bytes transferred = 10492520 (a01a68 hex) > U-Boot> bootm > ## Loading kernel from FIT Image at 88000000 ... > Using 'config-1' configuration > Trying 'kernel-1' kernel subimage > Description: ARM OpenWrt Linux-5.10.51 > Type: Kernel Image > Compression: gzip compressed > Data Start: 0x880000e4 > Data Size: 4944975 Bytes = 4.7 MiB > Architecture: ARM > OS: Linux > Load Address: 0x80008000 > Entry Point: 0x80008000 > Hash algo: crc32 > Hash value: 9da8225f > Hash algo: sha1 > Hash value: ea4e69501bed0925ecdee0bb6b3a3b489fedc38c > Verifying Hash Integrity ... crc32+ sha1+ OK > ## Loading ramdisk from FIT Image at 88000000 ... > Using 'config-1' configuration > Trying 'initrd-1' ramdisk subimage > Description: ARM OpenWrt bpi_bananapi-r2 initrd > Type: RAMDisk Image > Compression: Unknown Compression > Data Start: 0x884b7668 > Data Size: 5511960 Bytes = 5.3 MiB > Architecture: ARM > OS: Linux > Load Address: unavailable > Entry Point: unavailable you could try to explicitely set load and entry address to 0. > Hash algo: crc32 > Hash value: 01e5fbf0 > Hash algo: sha1 > Hash value: 6ceb78df26920d97dee505ddeb0318e0c1522ba0 > Verifying Hash Integrity ... crc32+ sha1+ OK > WARNING: 'compression' nodes for ramdisks are deprecated, please fix > your .its file! > ## Loading fdt from FIT Image at 88000000 ... > Using 'config-1' configuration > Trying 'fdt-1' fdt subimage > Description: ARM OpenWrt bpi_bananapi-r2 device tree blob > Type: Flat Device Tree > Compression: uncompressed > Data Start: 0x889f9288 > Data Size: 33453 Bytes = 32.7 KiB > Architecture: ARM > Hash algo: crc32 > Hash value: a2599155 > Hash algo: sha1 > Hash value: 59c64737be8bda92b33417dfadca87e9c4662be2 > Verifying Hash Integrity ... crc32+ sha1+ OK > Booting using the fdt blob at 0x889f9288 > Uncompressing Kernel Image > Loading Ramdisk to ff4b9000, end ff9fab18 ... OK > ^^^^^^^^^^ > Using Device Tree in place at 889f9288, end 88a04534 > > Starting kernel ... > > [ 0.000000] Booting Linux on physical CPU 0x0 > [ 0.000000] Linux version 5.10.51 (daniel@box) (arm-openwrt-linux- > muslgnueabi-gcc (OpenWrt GCC 8.4.0 r17073+11-8bb4437c01) 8.4.0, GNU > ld (GNU Binutils) 2.34) #0 SMP PREEMPT Mon Jul 19 12:26:15 2021 > [ 0.000000] CPU: ARMv7 Processor [410fc073] revision 3 (ARMv7), > cr=10c5387d > [ 0.000000] CPU: div instructions available: patching division > code > [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing > instruction cache > [ 0.000000] OF: fdt: Machine model: Bananapi BPI-R2 > [ 0.000000] earlycon: uart8250 at MMIO32 0x11004000 (options '') > [ 0.000000] printk: bootconsole [uart8250] enabled > [ 0.000000] Memory policy: Data cache writealloc > [ 0.000000] Zone ranges: > [ 0.000000] Normal [mem 0x0000000080000000-0x00000000afffffff] > [ 0.000000] HighMem [mem 0x00000000b0000000-0x00000000ffffefff] > [ 0.000000] Movable zone start for each node > [ 0.000000] Early memory node ranges > [ 0.000000] node 0: [mem 0x0000000080000000- > 0x00000000ffffefff] > [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000- > 0x00000000ffffefff] > [ 0.000000] 8<--- cut here --- > [ 0.000000] Unable to handle kernel paging request at virtual > address 3f9fab0c > > ^^^^^^^^^^ > Xf8fabXX looks familiar, see above. Just 3XXXXXXX seems wrong, or at > least not where physical memory ended up being mapped in Linux. > I also don't understand why U-Boot is reloacing the RAMdisk in first > place, shouldn't it be fine to just pass the address where it is > loaded inside the FIT structure (0x884b7668)? The bootm command calls boot_ramdisk_high() when CONFIG_SYS_BOOT_RAMDISK_HIGH is enabled. This is the case for most archs. If you look at that function, you can somewhat control the behavior either via env variables "initrd_high", "bootm_low", "bootm_size" or via gd->ram_base, gd->ram_size, gd->ram_top. Maybe you could debug and play with that function. According to the code an in-place initramfs is only possible, if you do a "setenv initrd_high 0xffffffff". But you should also check if ARM Linux has some special alignment requirements for initramfs and if a address of 0x884b7668 is useable (for example on MIPS, there is a 16 kiB boundary requirement and moving the initramfs with boot_ramdisk_high() accomplishes that). > > [ 0.000000] pgd = (ptrval) > [ 0.000000] [3f9fab0c] *pgd=00000000 > [ 0.000000] Internal error: Oops: 5 [#1] PREEMPT SMP ARM > [ 0.000000] Modules linked in: > [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.10.51 #0 > [ 0.000000] Hardware name: Mediatek Cortex-A7 (Device Tree) > [ 0.000000] PC is at memcmp+0x10/0x50 > [ 0.000000] LR is at start_kernel+0x8c/0x508 > [ 0.000000] pc : [] lr : [] psr: > 200000d3 > [ 0.000000] sp : c0d01fc0 ip : 3f9fab0c fp : 00000000 > [ 0.000000] r10: 10c5387d r9 : 3f9fab08 r8 : c09c007c > [ 0.000000] r7 : 3f9fab18 r6 : c0da1038 r5 : c0d04ec0 r4 : > 3f9fab0c > [ 0.000000] r3 : 00000023 r2 : 0000000c r1 : c09c007c r0 : > 3f9fab0c > [ 0.000000] Flags: nzCv IRQs off FIQs off Mode SVC_32 ISA > ARM Segment none > [ 0.000000] Control: 10c5387d Table: 8000406a DAC: 00000051 > [ 0.000000] Process swapper (pid: 0, stack limit = 0x(ptrval)) > [ 0.000000] Stack: (0xc0d01fc0 to 0xc0d02000) > [ 0.000000] 1fc0: 00000000 00000000 00000000 00000000 c0c28a54 > 00000000 00000000 c0c00330 > [ 0.000000] 1fe0: 00000051 10c0387d 00000000 889f9288 410fc073 > 00000000 00000000 00000000 > [ 0.000000] [] (memcmp) from [<00000000>] (0x0) > [ 0.000000] Code: e3520000 0a00000f e1a0c000 e5d13000 (e5d00000) > [ 0.000000] random: get_random_bytes called from > print_oops_end_marker+0x24/0x4c with crng_init=0 > [ 0.000000] ---[ end trace 0000000000000000 ]--- > [ 0.000000] Kernel panic - not syncing: Fatal exception > [ 0.000000] Rebooting in 1 seconds.. > [ 0.000000] Reboot failed -- System halted > > Anyway, all ideas are welcome :) > > > Cheers > > > Daniel -- - Daniel