Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3206347pxu; Tue, 15 Dec 2020 01:01:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0w6OBn5px8yTDqA3KHnnk/ZakxDGSsAgb36cZupFeJkwXsXT5bPIf9qeSmj2erckFDRYI X-Received: by 2002:a50:f299:: with SMTP id f25mr15114109edm.133.1608022873098; Tue, 15 Dec 2020 01:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608022873; cv=none; d=google.com; s=arc-20160816; b=ULO0P2SBZBXGfw0296zmwh276MyHO9moRcGCClXl1azuiNUfxDnWzQ1b4oLGsz+Hmt I6TSBdvrQE8a+4rTr85cTHXoQ/H9nDvWvKjhHL3geN1bs1Dm0lkLiaZsxUjzU6+FLcEb 9tTGLtXNJQ6OCwGgPinXy7zstM4C47r2Fs17MMJyPVCbo3j7BdVcfOAqniZ/5peWCE1w A6Hy38T9wNHVoXc/XwXGJRR8l1gCaIActqrFZXTaUrYVeWJbZiEsKF0JVfc4e9rUYUNL MiY29gq4ecidBq6gPfs7mKq8YEqrJSYoE750CK6eUxbq6gs/Zz/5/x5DKA4gqRpK+Bqz ielg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AKm4eJHa0x7jzyMwctEebqE5zykXwFHnRzlnlcFMVho=; b=MPATJkylWrCyz+O6i2iquINbgD9MQGKv5uOpDAaxGxcj01uP7A1WwKnICdmJ0oxtZq DgXao8iTqChEelSp0qcaQzz08oygVyQ2ZKWvtr2d7XaZZVD4nf3GAsgJdW5F/3xQwDfn KRYu8aAsz2ioKkXoovZU/4E6lSZGx7e1d7JZN7+zpf+j47RaFp+jHCXkO6NjO6EJbQsl bNxBQ/LiHwuL5ICloBAhBft4E3DtiJjDUD55xGRp0M1hCDCikYT2mV9xI4/eGfh7/FU+ pABsjpBcoZgctFRceBy6NPXsKX2+8vHEdcoKPl+ULPvVTeW3xMieCpIcA40OIZMpkpJQ FYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NgHRH8X+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si542573edm.265.2020.12.15.01.00.49; Tue, 15 Dec 2020 01:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NgHRH8X+; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbgLOI7Z (ORCPT + 99 others); Tue, 15 Dec 2020 03:59:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726777AbgLOI7T (ORCPT ); Tue, 15 Dec 2020 03:59:19 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7726C0617A6; Tue, 15 Dec 2020 00:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=AKm4eJHa0x7jzyMwctEebqE5zykXwFHnRzlnlcFMVho=; b=NgHRH8X+2NtNssI6RUv7NlxmWx xce2nCced5yWEbsjfNHzsgUH2BPLDgAuslXtubwogm+lWxJCBVsh6EWvlqRESsWSV56mSTwelxAQd hjSLxc2rpQqwvANXLLP0EQsiW3lf4D9mdSrNFriG3vgE3VOxZ9sWnOqMUKZlk7I745kusquQMx+AX 1SWL+BfGyZ1mNPu/JqmwaSyZbhHNkC7uYVPOAIVZK6h/aI3FVQLaPmqOyjgSpuefT+ldunvusWmUC PzAcuMmkv//VTgx9IFhWD5+HfXoxiN0uyxwIEyDbDPhbgp79C2i6OQtgnxXXkVlwIsl1xvg7dSVx1 nb5uMg/g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kp6A1-00051s-ID; Tue, 15 Dec 2020 08:58:21 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 3429D300446; Tue, 15 Dec 2020 09:58:19 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 142CE2C787A47; Tue, 15 Dec 2020 09:58:19 +0100 (CET) Date: Tue, 15 Dec 2020 09:58:19 +0100 From: Peter Zijlstra To: Tony W Wang-oc Cc: herbert@gondor.apana.org.au, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, TimGuo-oc@zhaoxin.com, CooperYan@zhaoxin.com, QiyuanWang@zhaoxin.com, HerryYang@zhaoxin.com, CobeChen@zhaoxin.com, SilviaZhao@zhaoxin.com Subject: Re: [PATCH] crypto: x86/crc32c-intel - Don't match some Zhaoxin CPUs Message-ID: <20201215085819.GE3040@hirez.programming.kicks-ass.net> References: <1607918392-19171-1-git-send-email-TonyWWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1607918392-19171-1-git-send-email-TonyWWang-oc@zhaoxin.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Dec 14, 2020 at 11:59:52AM +0800, Tony W Wang-oc wrote: Didn't I mention something about a comment? > static const struct x86_cpu_id crc32c_cpu_id[] = { > + X86_MATCH_VENDOR_FAM_FEATURE(ZHAOXIN, 0x6, X86_FEATURE_XMM4_2, 1), > + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(ZHAOXIN, 0x7, 0x1b, X86_FEATURE_XMM4_2, 1), > + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(ZHAOXIN, 0x7, 0x3b, X86_FEATURE_XMM4_2, 1), > + X86_MATCH_VENDOR_FAM_FEATURE(CENTAUR, 0x6, X86_FEATURE_XMM4_2, 1), > + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(CENTAUR, 0x7, 0x1b, X86_FEATURE_XMM4_2, 1), > + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(CENTAUR, 0x7, 0x3b, X86_FEATURE_XMM4_2, 1), > X86_MATCH_FEATURE(X86_FEATURE_XMM4_2, NULL), > {} Also, the above is weird in that is has the negative entries marked positive, and 1/NULL are inconsistent. Something like so then? --- diff --git a/arch/x86/crypto/crc32c-intel_glue.c b/arch/x86/crypto/crc32c-intel_glue.c index feccb5254c7e..f6e6669a5102 100644 --- a/arch/x86/crypto/crc32c-intel_glue.c +++ b/arch/x86/crypto/crc32c-intel_glue.c @@ -215,14 +215,31 @@ static struct shash_alg alg = { }; static const struct x86_cpu_id crc32c_cpu_id[] = { - X86_MATCH_FEATURE(X86_FEATURE_XMM4_2, NULL), + /* + * Negative entries; exclude these chips from using this driver. + * They match the positive rule below, but their CRC32 instruction + * implementation is so slow, it doesn't merrit use. + */ + X86_MATCH_VENDOR_FAM_FEATURE(ZHAOXIN, 0x6, X86_FEATURE_XMM4_2, false), + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(ZHAOXIN, 0x7, 0x1b, X86_FEATURE_XMM4_2, false), + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(ZHAOXIN, 0x7, 0x3b, X86_FEATURE_XMM4_2, false), + X86_MATCH_VENDOR_FAM_FEATURE(CENTAUR, 0x6, X86_FEATURE_XMM4_2, false), + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(CENTAUR, 0x7, 0x1b, X86_FEATURE_XMM4_2, false), + X86_MATCH_VENDOR_FAM_MODEL_FEATURE(CENTAUR, 0x7, 0x3b, X86_FEATURE_XMM4_2, false), + /* + * Positive entry; SSE-4.2 instructions include special purpose CRC32 + * instructions. + */ + X86_MATCH_FEATURE(X86_FEATURE_XMM4_2, true), {} }; MODULE_DEVICE_TABLE(x86cpu, crc32c_cpu_id); static int __init crc32c_intel_mod_init(void) { - if (!x86_match_cpu(crc32c_cpu_id)) + const struct x86_cpu_id *m = x86_match_cpu(crc32c_cpu_id); + + if (!m || !m->driver_data) return -ENODEV; #ifdef CONFIG_X86_64 if (boot_cpu_has(X86_FEATURE_PCLMULQDQ)) {