Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6551126imm; Mon, 23 Jul 2018 21:45:50 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3eAdA4pCVorzCFUQUgHGHBj9XGDIecdW26PXX1/I+6VYEjjcqMsXC3RYOBBpouT7B14AX X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr10359890plo.257.1532407550441; Mon, 23 Jul 2018 21:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532407550; cv=none; d=google.com; s=arc-20160816; b=hHM96RJZ9tapaNc0RXX8Rltjxi1waaR4y3al9eQv0rL7UIGADUpw2brcY7uCUdTnER ZmzdniBhgHb7J3rfs6V8RHdxSLmLzLQ8c78+Z8zvbQMewdB60aUvQVwngn+c5YsfCydq GweBzMtkwmGqQgCP/PH+JzPoWlcLtT0cH7/Ga22XJ7+zW646976OWzOsHVVvdTbSndOb YyfUVMtHIWV2L+qMw4DEVNjc9J0HV+Td99XVAfsK/grYsy6OaCblovK+Mjuz4dvlTa7U 32Ph8+4UvHLEgP1DKU0fxXKUUtvNJzs0JH1Ms1uB8FoMb/ytPI/5v0yYSyTU1x4Vn6V0 Wejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=+uc3uwE1fRhBcZiIMKimWjz+xdXtDv7tiIQjrtM1Js4=; b=FI1DhQDd7ZG+X8CStkHsY4mk/gQmuXiOvmk3TkbNASFNPmQDnhrGHc98KX0fh+TKBr 81u+VYQEEet9P5nuvTmnHm8tpnUSqzQjsoS6NXbkg6DnfFKiw1yBUWwK/9Xdi6Wp6yfU usfhCUXrPy9EC9O5wTTWIRseKYiFQ9EyZVqflbsv2RUtNIMlC+J3IBOHWqQDjC3OP6g0 8icQM2ncJEny22PqxvDnyOQ4/92Ot+qWeFLreexhD6gUfC00HGuk58FknzX2MWzN9iCF oTlwrngXIuxKoNiNrTHYpd66WykSxAMq5IOlgWXYgpmJi+FoP6fkMDjAW1Bb/CuZE1wF ijCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k9tm3Xs0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2-v6si9454050plp.459.2018.07.23.21.45.35; Mon, 23 Jul 2018 21:45:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=k9tm3Xs0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388345AbeGXFs4 (ORCPT + 99 others); Tue, 24 Jul 2018 01:48:56 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37396 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388203AbeGXFs4 (ORCPT ); Tue, 24 Jul 2018 01:48:56 -0400 Received: by mail-pg1-f194.google.com with SMTP id n7-v6so1946553pgq.4; Mon, 23 Jul 2018 21:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+uc3uwE1fRhBcZiIMKimWjz+xdXtDv7tiIQjrtM1Js4=; b=k9tm3Xs0uDLzr3F6fWrX4G7XSgtB+Z3d6S3so9QsJe8ZyxA3/oFMKNeiBPsk74dUpo hec/Yi3sVAdVQptIuthLgc6UPokChclDA5s8uq1QTAPSTuwSdfZCyZZ4z8vm2flPVonq EjHCRmADA1l0ZlymId2qFN72XsGNUAFQUDcVXQHch7BP0csvfgrsrsudx8lRameuqqZR QIGGrH6N1Sp7Am/DcwuddixbzXA1Wzr6LXKKTK6b7l+bqjPqdOTesU3NL05tZl5WFCNo QvMM3y2xbq1ubjLOjUNoM68XXf7xCTFyx4+OOF7JaDEtmicIzjqzK4exa5amUglo9/qA CxXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+uc3uwE1fRhBcZiIMKimWjz+xdXtDv7tiIQjrtM1Js4=; b=qKk4XKU/aQnbs/NcD1rl3rG1VTTy4q1/TD8Nto1qM6tkz0s+wWH1DNNM7dWOIVSgxj 3z6InwrqP6a7a4hkb07fu8HEt4FdisTYElpYSTYce4X17XQ1mrPaI6/nOI5unTI3Cv9j D1vct9SwLDBMFAqVlnFkv+nguXvkWFcXmPkAkb5PyEpuDEAAUUk0Aa/oJzfOT/NJuMEg wm6rv3wVr+b8PiwPx/diT3rGC/kegJQkwlFHTmapb6hCOeKTnnYaiNmPTqJInhVI5Ap+ eVDbkcxJAHJtwlxdFdvq84C7O0rfn4TiAnx+dudL1XlOM3AYSXEGxKZt2LU6EWetS+50 GQgQ== X-Gm-Message-State: AOUpUlGO8TTKaM1IIRCV/gMucvkSDSLzEgr1OD61QbgZExZCTLyZBouH 2QxW+dM9iJ1yQjvbeVFvkUY8zS0n X-Received: by 2002:a62:a3d1:: with SMTP id q78-v6mr15970587pfl.5.1532407463257; Mon, 23 Jul 2018 21:44:23 -0700 (PDT) Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id c68-v6sm25362345pfj.51.2018.07.23.21.44.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 21:44:22 -0700 (PDT) Date: Mon, 23 Jul 2018 21:44:20 -0700 From: Eric Biggers To: Coly Li Cc: linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, Greg Kroah-Hartman , Linus Torvalds , Thomas Gleixner , Kate Stewart , Andrew Morton , Randy Dunlap , Andy Shevchenko , Noah Massey Subject: Re: [PATCH v4 3/3] lib/test_crc: Add test cases for crc calculation Message-ID: <20180724044420.GB1944@sol.localdomain> References: <20180718165545.1622-1-colyli@suse.de> <20180718165545.1622-4-colyli@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180718165545.1622-4-colyli@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 19, 2018 at 12:55:45AM +0800, Coly Li wrote: > This patch adds a kernel module to test the consistency of multiple crc > calculation in Linux kernel. It is enabled with CONFIG_TEST_CRC enabled. > > The test results are printed into kernel message, which look like, > > test_crc: crc64_be: FAILED (0x03d4d0d85685d9a1, expected 0x3d4d0d85685d9a1f) > > kernel 0day system has framework to check kernel message, then the above > result can be handled by 0day system. If crc calculation inconsistency > happens, it can be detected quite soon. > > lib/test_crc.c is a testing frame work for many crc consistency > testings. For now, there is only one test caes for crc64_be(). Are you aware there's already a CRC-32 test module: CONFIG_CRC32_SELFTEST and lib/crc32test.c? Confusingly, your patch uses a different naming convention for the new CRC-64 one, and puts the Kconfig option in a different place, and makes it sound like it's a generic test for all CRC implementations rather than just the CRC-64 one. Please use the existing convention (i.e. add CONFIG_CRC64_SELFTEST and lib/crc64test.c) unless you have a strong argument for why it should be done differently. (And I don't think it makes sense to combine all CRC tests into one module, since you should be able to e.g. enable just CRC32 and CRC32_SELFTEST without also pulling in a dependency on all the other CRC variants.) > +/* Add your crc test cases here */ > +static void test_crc64_be(struct crc_test_record *rec) > +{ > + u64 crc; > + > + crc = crc64_be(rec->initval, rec->data, sizeof(rec->data)); > + chk_and_msg(rec->name, crc, rec->expval); > +} > + > +/* > + * Set up your crc test initial data here. > + * Do not change the existing items, they are hard coded with > + * pre-calculated values. > + */ > +static struct crc_test_record test_data[] = { > + { .name = "crc64_be", > + .data = { 0x42F0E1EBA9EA3693, 0x85E1C3D753D46D26, > + 0xC711223CFA3E5BB5, 0x493366450E42ECDF }, > + .initval = 0x61C8864680B583EB, > + .expval = 0xb2c863673f4292bf, > + .handler = test_crc64_be, > + }, > + {} > +}; This is incorrect; the test is checksumming data that has a CPU-specific endianness. So, it will fail on big-endian systems. The data needs to be declared as a byte or char array instead. See e.g. what crypto/testmgr.h does for crypto API algorithms. Also please mark the test data structures 'const'. - Eric