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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9E3D8EB64DC for ; Mon, 10 Jul 2023 01:11:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ACF9A857D0; Mon, 10 Jul 2023 03:11:44 +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="PPeb33SU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61C5D8573F; Sun, 9 Jul 2023 23:42:47 +0200 (CEST) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 5D1AC8565A for ; Sun, 9 Jul 2023 23:42:45 +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=virag.david003@gmail.com Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-992f6d7c7fbso491494166b.3 for ; Sun, 09 Jul 2023 14:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688938965; x=1691530965; h=mime-version:user-agent:content-transfer-encoding:date:cc:to:from :subject:message-id:from:to:cc:subject:date:message-id:reply-to; bh=plOTA4x3rwK/5lmRMHcBztbM/45tr+nu+nwja2KW9qE=; b=PPeb33SUOCnqi/O97+TwJ6Yf51zL0NzPAlV3qcVw058yDCGtbqqq/GrCt44nzQoFFX 8CL71iY+sd3M2EScSqvf1S7U8T0+yKxGJxUZZvnkzzKiB1pFjKKO649pm0PIBMLkkCuR 1D2GIwidEa50PZWDYTKmV3/zgoNqRH77e+yjzyqWBnMIVOdcSV6B7/RyRkBdSSjthJwX hJeAvnkKMHh86btlJsWZ1jDlkIhCdyYftx7Y80HJ6Kj2dlX7XIdFtJW7KCfl6bQmYxtc I4rkuXHSU8w7a1+JTeluALNxtV/r1j8SrRIVY1NNaZu2Rq6yOfiromxmB8nvd9ehhFHW re/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688938965; x=1691530965; h=mime-version:user-agent:content-transfer-encoding:date:cc:to:from :subject:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=plOTA4x3rwK/5lmRMHcBztbM/45tr+nu+nwja2KW9qE=; b=BxQ/nuImCKBdi9evIRhmoDJNWyKV8oXWMG5ozNDaRQKibxE5+3FIPKrGb5zOUH3a4n LmIdv1ekXODqh8x8tEW3OIdruyUVyGNJleXAuvazSTXZvBfGebD4+SW11XNI42ALVqFO WMH5wYiXQHG5p+whwkBtkuKT4cjQ7yS5Vdt1bBC42+oGFCciC3FlFX6fRHslX2OSFe9Y jDBj0WhFCpmVylBo4UvxG5iXxLiU9DKQro97GdmHaFdTAKIHr97/we6eT7SKmoINupXW WmKzTMjPFRTIJPm2CZYQV0o9Xrzvc6eQv+13SLObPApMBhN3mQlWIxrk+S1XfpIhRD8i BXjA== X-Gm-Message-State: ABy/qLadB8lC0Of5/ZbaRQa31xma52OdO+1N97oE6h+SF8No9K7vylti jfY+ovx7BN6JvL6CDUSAjbCc5dNC/Ys= X-Google-Smtp-Source: APBJJlHwNwWT/UnWX/ZSQ8yMb5auU8QKiFSku/b4GRARMbYaWHLrCsZUvfZLOgmJP39U690gVwwrKw== X-Received: by 2002:a17:907:760d:b0:992:566b:7d57 with SMTP id jx13-20020a170907760d00b00992566b7d57mr9458561ejc.61.1688938964639; Sun, 09 Jul 2023 14:42:44 -0700 (PDT) Received: from ?IPv6:2a02:ab88:368f:2080:5d6e:322:57b6:5f03? ([2a02:ab88:368f:2080:5d6e:322:57b6:5f03]) by smtp.gmail.com with ESMTPSA id g14-20020a1709064e4e00b00991faf3810esm5275315ejw.146.2023.07.09.14.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 14:42:44 -0700 (PDT) Message-ID: Subject: [BUG] fdt_pack_reg in common/fdt_support.c can cause crash from unaligned access From: David Virag To: u-boot@lists.denx.de Cc: virag.david003@gmail.com Date: Sun, 09 Jul 2023 23:42:37 +0200 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 10 Jul 2023 03:11:42 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean Hi, I'm trying to port U-Boot to a new board (Samsung JACKPOTLTE, ARMv8, Exynos7885) but when CONFIG_ARCH_FIXUP_FDT_MEMORY is enabled, the bootm command leads to an unaligned memory access, which results in a synchronous abort. After a long debugging session, I concluded that fdt_pack_reg in common/fdt_support.c writes to unaligned addresses in its for loop. In the case of address_cells being 2, and size_cells being 1, the buffer pointer gets incremented by 12 in each loop, making the second iteration (i=3D1) write a 64bit value to a non 64bit aligned address. Turning the alignment check enable bit (A) off in SCTLR makes the function work as intended. I couldn't find code that touches this bit, but I may have missed something. I don't think writing in two parts should be the fix, but something should be done about this. As far as I understand, any arm64 board that has this bit turned on, either from previous code or just the initial status of the bit after power on, could crash here. This is on top of the latest commit as of now (0beb649053b86b2cfd5cf55a0fc68bc2fe91a430) What should be done here? Best regards, David