From patchwork Tue Jan 11 17:06:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Bisson X-Patchwork-Id: 1578577 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=boundarydevices.com header.i=@boundarydevices.com header.a=rsa-sha256 header.s=google header.b=YoSCHS9s; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYHFQ2jxbz9s1l for ; Wed, 12 Jan 2022 04:07:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D53082A71; Tue, 11 Jan 2022 18:07:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=boundarydevices.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=boundarydevices.com header.i=@boundarydevices.com header.b="YoSCHS9s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5488982A71; Tue, 11 Jan 2022 18:07:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) (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 7917581879 for ; Tue, 11 Jan 2022 18:07:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=boundarydevices.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=gary.bisson@boundarydevices.com Received: by mail-pj1-x1034.google.com with SMTP id l16-20020a17090a409000b001b2e9628c9cso7007912pjg.4 for ; Tue, 11 Jan 2022 09:07:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+zwloR5axSusKSvX5ymV1ICa58u2hEWpG06ca3+P8r0=; b=YoSCHS9swzeyqwgxQ8817T8/qPDc7vUrhqBrgbtGqXUWtnOy1cI3QGvNVt0+P7/m5+ QL+u79zYLGh7P9ue+G3XzDE7s3jx7PwIv0e14DWVttsyNZSxuOaNC3dNpa0J0lJxitjv Se3KMxGQY2f32fQvDHrwKRG0HQqeXTLlDNliI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+zwloR5axSusKSvX5ymV1ICa58u2hEWpG06ca3+P8r0=; b=AQ8T+rCh7/DiNedfximzDyJFPVSAUacmWxuLG2uFGEENxJCPmfrl80Y3isoGVVhmCa vTDzihK7UqACcrZvpOtmNWcUGHciWJ2tnEYS774z0j8BC42v4y6N/8gLSyY+5ADTewjj PkTAJyEKN/UIvnFjxF56aa728oiRbcrpGkSG/0D0CokEnERQzxVyjy8IcGrU/jzttvag B/lqKo5ElkDuWent40lwdPok9JCVoEhCYjdkrhgeqriA9dq6NulBB9bwnydo5HjIp03m 56cKmQ+yESQ5NlMObQaM7g0RdB8ezQHPkog+kVqk4nH+RXPOIgmW4GRAYLhpLr/RhVLW /YhA== X-Gm-Message-State: AOAM533p4z7X866TCm5Jad5CjviRus+OvdmnGttivUT1bWhSyXfmI5tb mHStrWr2mFLK4p/VgruHrNCT9vVWKFBBug== X-Google-Smtp-Source: ABdhPJx69CZEggdt3kS4GdrQ7S0fDuv6UDXQ48bh3j+E+YzUxZgJzsqesdfST//OXK2EfO6XIwFpMg== X-Received: by 2002:a17:902:ea02:b0:149:473f:ca35 with SMTP id s2-20020a170902ea0200b00149473fca35mr5347607plg.99.1641920857516; Tue, 11 Jan 2022 09:07:37 -0800 (PST) Received: from localhost.localdomain (2a01cb000f5a8200e371e4a5048c8b22.ipv6.abo.wanadoo.fr. [2a01:cb00:f5a:8200:e371:e4a5:48c:8b22]) by smtp.gmail.com with ESMTPSA id t25sm8673669pgv.9.2022.01.11.09.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 09:07:36 -0800 (PST) From: Gary Bisson To: u-boot@lists.denx.de Cc: roman.kovalivskyi@globallogic.com, erosca@de.adit-jv.com, mkorpershoek@baylibre.com, Gary Bisson Subject: [PATCH] cmd: bcb: fix bcb struct alignment issue Date: Tue, 11 Jan 2022 18:06:06 +0100 Message-Id: <20220111170606.2042950-1-gary.bisson@boundarydevices.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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.2 at phobos.denx.de X-Virus-Status: Clean Without this patch the bcb struct could be located at an odd address which resulted in data not being copied to the buffer. Here was the repro steps (from Mattijs): => mmc dev 1 => bcb load 1 misc => bcb dump command 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 => part start mmc 1 misc misc_start => mmc read ${loadaddr} ${misc_start} 4 => bcb load 1 misc => bcb dump command 00000000: 62 6f 6f 74 6f 6e 63 65 2d 62 6f 6f 74 6c 6f 61 00000010: 64 65 72 00 00 00 00 00 00 00 00 00 00 00 00 00 This behavior was observed on an Amlogic A311D (ARM64) platform with a recent GCC toolchain (11.2.0) but is most likely affecting other platforms. To avoid issues the structure is aligned on DMA minimum alignment value as it is passed directly to the read function. Signed-off-by: Gary Bisson Tested-by: Mattijs Korpershoek # on khadas vim3 --- cmd/bcb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/bcb.c b/cmd/bcb.c index 6b6f1e9a2f1..92f4d27990d 100644 --- a/cmd/bcb.c +++ b/cmd/bcb.c @@ -12,6 +12,7 @@ #include #include #include +#include enum bcb_cmd { BCB_CMD_LOAD, @@ -24,7 +25,7 @@ enum bcb_cmd { static int bcb_dev = -1; static int bcb_part = -1; -static struct bootloader_message bcb = { { 0 } }; +static struct bootloader_message bcb __aligned(ARCH_DMA_MINALIGN) = { { 0 } }; static int bcb_cmd_get(char *cmd) {