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: 249431 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp5056138ilg; Tue, 8 Sep 2020 18:33:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7xKzdcltduiwmqFPAJzoMx4Xe2er2RURfoKq7AfMLrXYnQhaL4PSe/pn7R1W0C5iXsxeh X-Received: by 2002:a17:907:72cc:: with SMTP id du12mr1276245ejc.150.1599615220381; Tue, 08 Sep 2020 18:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599615220; cv=none; d=google.com; s=arc-20160816; b=J6Hm/jJRW5DvJ30DtqlQQgMvC7gLpBA+Bv6O0mx0+FINrkoceH8iGcVjMDP1rJ+Bd9 2JEW9ZYsUPzn6paNb7JFeOhxgx0DUrll7riYs2wmq2kL+5wt5NVBsGTHMASaPsfaqGD2 NqCJgTX4UW4VmR2mgwWAueE3IqDi0w/aOmCdsvZ3V02fHSLbfFOiuOKtuSuAByQlrFjW 1XgGtnVH5PmStrvzcw1elizAP6zNwp0LDcYZyYtOaAEqVLCkUoMLTcl6esEiqV+97KEK /7V0Bgua73CPQRt/TahP4jSbYtRbdGHPS1PbJjV+7Pm7NP0Cc2i01RCu3d2wKS9EgBJr +HLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=7U57yqo+4luBheF7BXn1e3ZYC/20ro1qrDcvPXbrpIQ=; b=bDxa9RSMLPAd3LiiGeStHic6iI4SZinzkfoptzlOHVKZxiIRAu5g2WN+zjxwLYvxcN JphVaHR7tqoGLcP2qSPBAgaFZmODagc5UJpUrLeuLHXevDBagrUh1GipOibAcz1kJZAC zttJF4NZlo6KDC0akWyScbTUDtVn54kXF/w5NTfWyWCVdzJ8+7J9/vk0XyMq/GP6pMPs JZo16rUj1BSgvqJxJ+y6jkS060XmVDd3wmaJtfVN7pyKpgc/2VHgX4EuGp6aUxrxjtUt KrdvV9VMYz1ociOc8jD47vrki2NYFcPBL8O9saRpLCctn8MtvzeFPvV+tYvi2iz2cvrG BUPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ucHraPGs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id jo13si503272ejb.200.2020.09.08.18.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 18:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ucHraPGs; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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 -- TODO/FIXME: maybe the ending address should be automatically aligned? Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/mem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Stefan Roese 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,