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 EA0D2EB64DA for ; Mon, 10 Jul 2023 20:13:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EB01986785; Mon, 10 Jul 2023 22:13:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="uj2OvIZF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6F68B86786; Mon, 10 Jul 2023 22:13:45 +0200 (CEST) Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 2C3C686782 for ; Mon, 10 Jul 2023 22:13:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-55e04a83465so3485656eaf.3 for ; Mon, 10 Jul 2023 13:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1689020022; x=1691612022; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+rLEAlZZoByL3iIcIzhpvgXbgXzn/cojyO+Phh8BTL4=; b=uj2OvIZF4CtBX/TCw6IkA7dVgGiGN2hWfLGU5NezYtT90Sq889IIw4IkIHC6PsM6K+ xD5I5w6jdZ4MWMvqM8MAkFs/EsjUkKiHJbkOnONFw7Izhej6iiedt7FsuYaRnyyUjP17 K7HjrXTo8IoARqbWQrVtpKheljsCxXIChf5ok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689020022; x=1691612022; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+rLEAlZZoByL3iIcIzhpvgXbgXzn/cojyO+Phh8BTL4=; b=HVXHMRDxEJTpT7DCcXOT7ybRyuUwcL9rdnYBQfuAJfezLLoeeL2hYAROqoLwfUujKg vcrcMhKiW3/jexs5OjwbjT0aLIfWG/5sSEMrbkGNdfqDSPGKT7P/feo1N+BSz6q1zFLN kHg3CC0opEJdM5oaE3WjZEkEjLMr3L7PJFI6pNMji8w+Bkcp6+Ti1GH5in32FHO9i8Vg cZ3oL/hs9YzLGzKCW7xh4fGlS4Jup/4F6dPIBXXi/uJ6jeNt0vmi2onLz2R0ehUGvctp RSAsGE/Dn+42dJjFeBd7RtmCNgSg5WukJaXEWRPhf/GL7UjpjoswIdVT++Ajj1z3geEF t/YQ== X-Gm-Message-State: ABy/qLZOKVdyQE6z1rWj0czA95DWyuerxC+9D3Ua5W4stlPgoU6fqmPd YO8yzrvDDWYA2KJI++FZ0+cM/w== X-Google-Smtp-Source: APBJJlEGgx0yUWtoRVzWpZuAABiNA9elnHZaCj/09OT5xxtzog2xmw5sT+1uE+BT5o1WOO2sYfp6MA== X-Received: by 2002:a05:6870:1cc:b0:1aa:192e:9f35 with SMTP id n12-20020a05687001cc00b001aa192e9f35mr15988668oad.26.1689020021794; Mon, 10 Jul 2023 13:13:41 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b00-6400-df98-0e31-df37-537b.res6.spectrum.com. [2603:6081:7b00:6400:df98:e31:df37:537b]) by smtp.gmail.com with ESMTPSA id l22-20020a0de216000000b00570589c5aedsm166415ywe.7.2023.07.10.13.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 13:13:41 -0700 (PDT) Date: Mon, 10 Jul 2023 16:13:39 -0400 From: Tom Rini To: Simon Glass Cc: David Virag , u-boot@lists.denx.de Subject: Re: [BUG] fdt_pack_reg in common/fdt_support.c can cause crash from unaligned access Message-ID: <20230710201339.GZ148062@bill-the-cat> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xp8YbEI9sHpYtPgD" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett 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 --xp8YbEI9sHpYtPgD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 10, 2023 at 01:45:46PM -0600, Simon Glass wrote: > Hi David, >=20 > On Sun, 9 Jul 2023 at 19:11, David Virag wrote: > > > > 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? >=20 > +Tom Rini =2E.. I was hoping you had an idea Simon. Is this part of the code we share with libfdt itself, or one of the helpers we made? --=20 Tom --xp8YbEI9sHpYtPgD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmSsZnAACgkQFHw5/5Y0 tyyEEwwAnuQ55+r1Qa4qESErSf1WnKbQreD3haYINT5Yi1NCpB1Whx37kz6Y0yG5 cSBtPxsTrPK3Yc9Uq46/4SsOmjI//MDwPgZh6oB+DK7QgliPHYSZIXt1R8foq3Fh OhbVQ6zYeAfA8VZ1VYSBk84vYFFVULTcxBOn5IyHJRE5ZnfoV/QrdtDX7y0/qgaR GLKI3nQ6tV/pN8JwBC40ujVnH7oEhaslqzy6uZHl1dJjDtBzdC9IFjCjMFlkj5Ej JwnpCnb0Ps99wzBFZ8SxTzir0a1zB8EGqMcnQA+i9wyt31JFc4iiGHsjZpU3ipKp zT9CqYr5VAsv9tJWnhG5AkTQL2xQD7uxjM6p46UpsQ+hN/RkOnV6w99bRK7IvacH UNI4XewVeGJXrC7092afX5mlTt4b9JePhCm23mJCw8tETukp0QFkMioEfBYrOIoN DU02ZQpYzQUkCTPdsDt1jRn0JsNFSyClUpXFdGx4ZHv4SSYgilypJcypLvM0U5Rt UqtKauiF =gy75 -----END PGP SIGNATURE----- --xp8YbEI9sHpYtPgD--