From patchwork Wed Sep 9 13:02:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 249456 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp389286ilg; Wed, 9 Sep 2020 06:02:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp8j4wPGaqHrtQaZFwd9zc3YVhid6Ex4iYCa2hA6BXab+RVUbVHgT4kAgOIgcE2vSzBAAS X-Received: by 2002:a50:ce06:: with SMTP id y6mr3960131edi.273.1599656541719; Wed, 09 Sep 2020 06:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599656541; cv=none; d=google.com; s=arc-20160816; b=VtupuiEwc3yA9cILemUBIeTisq4/uOp6pKkdAUb0uld/msPa5goFdJc+XI815h+da4 iZmWgLUryyf4KNq55gSegdfjj8n8g5xi9mgz1YJIuobelMX6o362+mkORUTJPSw4xWXN FMkRzWH7B939Z/KRnCOiUWRUA7kqiplQgwqz7IGO273Xh64ElWulZ9ysS78iLpL+b2cI fLioZ5DjOAgNZEGuhgH+hwo7kdYQZr2wdEA6YSG04jiO1HKe5hMTlT8+rqrZxv1ju7Vq fF7JNKo+VRi464lAPSMCCUXWD/FVg0XCRTB1lIKBJiGObCXlB/WH3BZbJb3pzsegLiNz e02A== 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=QlBwMAKRG6lmnu2/0L53k/TdK/k8G4ONVgJyzs+V4v8=; b=NbaIMHB7mx2XtawmNiDp/+XTdYDCrd1Uvs74XIld2Y6qkxoUBHro8P/scVwrvzRf53 3uZ5LdkwH80w43X2wae3oujNgUoWIegQoKwX4ygq2o2d/F7KpVGVCXPgAlL0Azg+G/fk N6V7fQyc3XBP+x5NMb4wK62nwxt+lDO0hgJZ/FG1Dgi421Kjqqsz+yNQMP3+Pw9sYZqL g5fCESKcbmqkDU+KQ1XVEiUd+EBzzInOkF2iFMVITCKJFs4vuZzjKmq+jV+Uh39gf6NQ OKRfg9y7Xh79SY4U/3hPukrBbB1jbp3SHhnm2pVv4mlbPbEEhf9w//42W+0Mpmw44YFr LNnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=czRUVIZV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id s22si1330472edc.481.2020.09.09.06.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 06:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=czRUVIZV; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 BAC8C821BF; Wed, 9 Sep 2020 15:02:19 +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="czRUVIZV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3C228221F; Wed, 9 Sep 2020 15:02:18 +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-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (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 2976A81B79 for ; Wed, 9 Sep 2020 15:02:12 +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-qk1-x743.google.com with SMTP id w16so2276335qkj.7 for ; Wed, 09 Sep 2020 06:02:12 -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=QlBwMAKRG6lmnu2/0L53k/TdK/k8G4ONVgJyzs+V4v8=; b=czRUVIZVW9QGWQBMkhrUYsoRx2few+6yF0CazBunYFMmCY/8BVkA4Xy8t4MPYgSkI2 /q/Za6qrXEzBlTYdEMhIAO/btpjuD1AFAOxoUgTEGTsBrLev4v0HfTM8+O4/oskRVbKS Tilww5sSQisg3Q/ADXPXRqONbhQIwdffHGKajZbqkXycf7mAjRxRN3RhOiXy+b7Z4Wv9 irxNtB/vUbxjHSimXo1OAUeUqY1YTHL705q7pw5DdsFyAddtVA6fnud/2NISyV9qYh5r 6cCn1rnWcEAoX1kYPBklRn4qiyneHwJuea6R4kj0G2KQtn5gnAZZFdpeIr/iqtVWFyZN LDLg== 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=QlBwMAKRG6lmnu2/0L53k/TdK/k8G4ONVgJyzs+V4v8=; b=NM0l0kDI45B0y1oWhGYgnTOVyaFhb+tad4KVuJWuv9RZKg9usu//gmh2je/ycfIWml Z44nuKc9Kp9nXcoxRBWFZLuRIq7SFgjx4v0l8PPFDYxGmJsTF1k+y21wTmS7euf7W5TO dbCr6tTktBDyTLNSONR/jWX5usqmwVXtc1hYis1sku2gW9z6x/5tGhyfZFm6pk2KSrrg mvPSnSDWZQErVZwqr+CABUr1MwyNJIxU5pSh3ks1G3l1weEKrG/8ZJMbXQMp6mOsH+r5 xwaraZNuf4G0BPKW44n8hArAvqwatyzRt9CG85cYwYqFoZ/dWQ1Xx6CI+3qadVHCzGnm w5eQ== X-Gm-Message-State: AOAM530wm9tewG+ayYUcRGyRUYwG5kHgU7NEO+2cWeCyNJXHcku2+wdJ x6M9aqm5N3PKjSYDJKak5u0NQpNeB3mn8A== X-Received: by 2002:a05:620a:2014:: with SMTP id c20mr2907933qka.89.1599656530363; Wed, 09 Sep 2020 06:02:10 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id p68sm2492553qkd.124.2020.09.09.06.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 06:02:09 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Cc: sr@denx.de, trini@konsulko.com, Ralph Siemsen Subject: [PATCH v2] cmd: mem: fix range of bitflip test Date: Wed, 9 Sep 2020 09:02:01 -0400 Message-Id: <20200909130201.12885-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <9c12ad86-531d-8487-997d-fc2edeab4fb4@denx.de> References: <9c12ad86-531d-8487-997d-fc2edeab4fb4@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 achieved by splitting the range of memory into two pieces. The address of the second buffer, as well as the length of each buffer, were not correctly calculated. This caused bitflip test to access beyond the end of range. This patch fixes the pointer arithmetic problem. 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 expects a count rather than an "ending" address. Thus it fails to test the last word of the requested range. Fixed by using (end - start + 1). Fixes: 8e434cb705d463bc8cff935160e4fb4c77cb99ab ("cmd: mem: Add bitflip memory test to alternate mtest") Signed-off-by: Ralph Siemsen -- Changes in v2: - Minor refactor to reduce line length - Spellcheck and cleanup commit message Change-Id: Ie641d04e731fc5bc6a3bbef914bf7fad136cdc94 --- cmd/mem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Stefan Roese diff --git a/cmd/mem.c b/cmd/mem.c index 9b97f7bf69..7bfa93d2a0 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -934,7 +934,7 @@ static ulong mem_test_quick(vu_long *buf, ulong start_addr, ulong end_addr, static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - ulong start, end; + ulong start, end, half_size; vu_long scratch_space; vu_long *buf, *dummy = &scratch_space; ulong iteration_limit = 0; @@ -987,10 +987,11 @@ static int do_mem_mtest(struct cmd_tbl *cmdtp, int flag, int argc, if (errs == -1UL) break; count += errs; + half_size = (end - start + 1) / 2 / + sizeof(unsigned long); errs = test_bitflip_comparison(buf, - buf + (end - start) / 2, - (end - start) / - sizeof(unsigned long)); + buf + half_size, + half_size); } else { errs = mem_test_quick(buf, start, end, pattern, iteration);