From patchwork Wed Sep 9 01:33:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 1360300 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ucHraPGs; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BmPgH2LS3z9sSJ for ; Wed, 9 Sep 2020 11:33:45 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 405AD8174F; Wed, 9 Sep 2020 03:33:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="ucHraPGs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53C9881B79; Wed, 9 Sep 2020 03:33:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) (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 8887C8006D for ; Wed, 9 Sep 2020 03:33:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ralph.siemsen@linaro.org Received: by mail-qv1-xf42.google.com with SMTP id ef16so750453qvb.8 for ; Tue, 08 Sep 2020 18:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7U57yqo+4luBheF7BXn1e3ZYC/20ro1qrDcvPXbrpIQ=; b=ucHraPGsoxsvCgU1jQ9+s4j2gJzY9yRXmTFs+Ac7sVwBS+rn01T1nyDEK71KOSpq/h vKkvIEpuKLtYla60TXrLG/7tindmIgRAPijAHdhKiWxGZ+ele2zj4xcbRNxs9J92RckN oFp5jxJIhmvaI/k4MvtV2xamDZ/mrh4VZsTjZLOpCVoqIxBvGJJCAdpCJ6FUPRndB1FM 4Gp6OP4YRFgYAsM4yP0dZNgfxi1PkZ3e935Myza2TKxF6nkOPTo+NZs2AfW7+K2kvtOI Of96jRnNHknFvHMPcHbBDyc6uhq4U2fW3sY/fdQU1VLIgNNZBTzx5/VXb2QBXmnvrR1k aN5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7U57yqo+4luBheF7BXn1e3ZYC/20ro1qrDcvPXbrpIQ=; b=jG04MBmvE8Xp+7S1mlxMecuPJX2Z1g8EsQqzi/5ybOGMqRSvMbXWnkGnkGnbqXKfI7 yOIBIuj8faO0sNjk6ZkqtSDterJV6iuFr+tgXkeR7fvCxUWdRj480vsQx19iQ7HX3qDw yQVF0uhtwY3OIWLysaaaOrsbZpWj6dyrDEtT8LBR3WnlNTqdSDoxRVWKHKqv3kzL2gZO X9cP8pRhHP0G2iSpG+boDME1Jb4KcnXGVHM8Yi+9XwI8rjOqml2wmkPzw1AlizXbZAzL 3ywBLzqB+MKWvbfrRyDModvNkSExTHNa7xgUXcjXNjGKTlIkZluY2M0yzelZl0SEr4GO VW/A== X-Gm-Message-State: AOAM533fc21kiYzop2xC0K99fw/OUHXRJ0kVFMopb7bERfrg5/fQ4RAJ mKFI6ji5We4wso9dIpES/nqQYDD1YVDnsA== X-Google-Smtp-Source: ABdhPJwD3DqY8kM5OEmtmsCXuHIZ0Ca4Wvd+YA0F7XD9gyqJ05IWHKjJlonuZc6ZXWHMFSrdaGkY0g== X-Received: by 2002:a0c:fca9:: with SMTP id h9mr1903115qvq.30.1599615212694; Tue, 08 Sep 2020 18:33:32 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id d200sm1007926qkc.109.2020.09.08.18.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 18:33:32 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Cc: sr@denx.de, trini@konsulko.com, Ralph Siemsen Subject: [PATCH] cmd: mem: fix range of bitflip test Date: Tue, 8 Sep 2020 21:33:25 -0400 Message-Id: <20200909013325.6053-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200305062132.22932-4-sr@denx.de> References: <20200305062132.22932-4-sr@denx.de> 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.102.3 at phobos.denx.de X-Virus-Status: Clean The bitflip test uses two equal sized memory buffers. This is achived by splitting the range of memory into two pieces. The address of the second buffer was not correctly calulated, thus the bitflip test would accessing memory beyond the end of the specified range. A second problem arises because u-boot "mtest" command expects the ending address to be inclusive. When computing (end - start) this results in missing 1 byte of the requested length. The bitflip test in turn misses the last word. Fixes: 8e434cb705d463bc8cff935160e4fb4c77cb99ab ("cmd: mem: Add bitflip memory test to alternate mtest") Signed-off-by: Ralph Siemsen Reviewed-by: Stefan Roese --- TODO/FIXME: maybe the ending address should be automatically aligned? Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/mem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/mem.c b/cmd/mem.c index 9b97f7bf69..88e15b2d61 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -988,8 +988,9 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc, break; count += errs; errs = test_bitflip_comparison(buf, - buf + (end - start) / 2, - (end - start) / + buf + (end - start + 1) / 2 / + sizeof(unsigned long), + (end - start + 1) / 2 / sizeof(unsigned long)); } else { errs = mem_test_quick(buf, start, end, pattern,