Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4152095rwb; Mon, 31 Jul 2023 02:09:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlHD0DWY5D8KdVZrsqj4ng+4uCCccDyNJSs4kXU5Jc2yVQIGUbAydWvwrpy898W16ieFugM0 X-Received: by 2002:a17:90b:46c2:b0:25c:18ad:6b82 with SMTP id jx2-20020a17090b46c200b0025c18ad6b82mr10617304pjb.21.1690794597206; Mon, 31 Jul 2023 02:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690794597; cv=none; d=google.com; s=arc-20160816; b=xOe45/ZoPnmvBz401bqvF7UQKUe3fIpIEeaVn2B954sD06+53lkTWFTUKh9rhCiGCk YxHGnQk2ppO4K2FaNy7IlwX3KtbZzeS9pK7jz7RRIW5qCiVgzDqwEs7Belqvu2oDokXh qKaEna9up4+i7SeNvBEvR/GkeEieVWoob2qzSnco/+F31OrxV+J4QfkgNw/DpYgduhtB OWD0brUpO2iclMLjUgPNOODUwJyAB1y3cuxKDecTz3z01vcyaS1Fgi+bUlFuE48ALyFH 6HZXJ93h0QtKjHNWE2RPDxg+mjfSCdgjSHfA0z7vj7Nt1WsJvrUczewsRZ1Cc7tkxBVR 1ZRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yZEKW9k82hKggWgN4sgkCzsd+9dkMRfO3guifBvET+w=; fh=3ZSPIWnd+HK6Z7GAIKhGwlldu45YVuy58q4HCcukU/M=; b=ZXOyHvpKFtwqko95gVNPRgkjDqCkUfI7T5AhJe7qKhyj1E8BJmUcft8FYQRUCkS5M7 moIzrJIM4ghxys1V84NT9yenpvmkBP6fydEIaMLZjJKKRYzQ6XEJmHPe0a6EONZmL5Hm GZhZ8FKzSN1ncdmelxlAwVkjcBtTzs4LM0qJIn0B0xiCLEilNPTQUVEz9HHWrmQb5ZMc fKGIVWHkLaTLYC0o/hyLCVfWws+9lxQMqSdV1zMpIy7qErXA9A2ehB6y6ErRRjO4mJRy DqYYN0orieDn95MSNRczgzX3TscgrtGkIChlCd8nbOIm/1vj2jwvyHSQ7aAcbGRw742m ToIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a17090a34c300b0026825823da0si7133703pjf.59.2023.07.31.02.09.43; Mon, 31 Jul 2023 02:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232004AbjGaIrO (ORCPT + 99 others); Mon, 31 Jul 2023 04:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbjGaIqk (ORCPT ); Mon, 31 Jul 2023 04:46:40 -0400 Received: from mx1.zhaoxin.com (MX1.ZHAOXIN.COM [210.0.225.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D5722115 for ; Mon, 31 Jul 2023 01:45:23 -0700 (PDT) X-ASG-Debug-ID: 1690793119-086e231869033b0001-Xm9f1P Received: from ZXSHMBX3.zhaoxin.com (ZXSHMBX3.zhaoxin.com [10.28.252.165]) by mx1.zhaoxin.com with ESMTP id Z2HnKAJvtAwZKXyU (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 31 Jul 2023 16:45:19 +0800 (CST) X-Barracuda-Envelope-From: LeoLiu-oc@zhaoxin.com X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 Received: from ZXBJMBX03.zhaoxin.com (10.29.252.7) by ZXSHMBX3.zhaoxin.com (10.28.252.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:18 +0800 Received: from xin.lan (10.32.64.1) by ZXBJMBX03.zhaoxin.com (10.29.252.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 31 Jul 2023 16:45:17 +0800 X-Barracuda-RBL-Trusted-Forwarder: 10.28.252.165 From: LeoLiu-oc X-Barracuda-RBL-Trusted-Forwarder: 10.29.252.7 To: , , , , , , , , CC: , , , , leoliu-oc Subject: [PATCH v2 1/2] hwrng: via-rng: convert to x86_cpu_id probing Date: Mon, 31 Jul 2023 16:45:14 +0800 X-ASG-Orig-Subj: [PATCH v2 1/2] hwrng: via-rng: convert to x86_cpu_id probing Message-ID: <20230731084515.2057375-2-LeoLiu-oc@zhaoxin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> References: <20230731084515.2057375-1-LeoLiu-oc@zhaoxin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.32.64.1] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To ZXBJMBX03.zhaoxin.com (10.29.252.7) X-Barracuda-Connect: ZXSHMBX3.zhaoxin.com[10.28.252.165] X-Barracuda-Start-Time: 1690793119 X-Barracuda-Encrypted: ECDHE-RSA-AES128-GCM-SHA256 X-Barracuda-URL: https://10.28.252.35:4443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at zhaoxin.com X-Barracuda-Scan-Msg-Size: 1824 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.112114 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: leoliu-oc With this, In addition to the Feature matching check, add the CPU Vendor ID/Family check. Signed-off-by: leoliu-oc --- drivers/char/hw_random/via-rng.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c index a9a0a3b09c8b..d7feb3923819 100644 --- a/drivers/char/hw_random/via-rng.c +++ b/drivers/char/hw_random/via-rng.c @@ -135,7 +135,7 @@ static int via_rng_init(struct hwrng *rng) * is always enabled if CPUID rng_en is set. There is no * RNG configuration like it used to be the case in this * register */ - if (((c->x86 == 6) && (c->x86_model >= 0x0f)) || (c->x86 > 6)){ + if (((c->x86 == 6) && (c->x86_model >= 0x0f))) { if (!boot_cpu_has(X86_FEATURE_XSTORE_EN)) { pr_err(PFX "can't enable hardware RNG " "if XSTORE is not enabled\n"); @@ -191,12 +191,17 @@ static struct hwrng via_rng = { .data_read = via_rng_data_read, }; +static const struct x86_cpu_id via_rng_cpu_ids[] = { + X86_MATCH_VENDOR_FAM_FEATURE(CENTAUR, 6, X86_FEATURE_XSTORE, NULL), + {} +}; +MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_ids); static int __init via_rng_mod_init(void) { int err; - if (!boot_cpu_has(X86_FEATURE_XSTORE)) + if (!x86_match_cpu(via_rng_cpu_ids)) return -ENODEV; pr_info("VIA RNG detected\n"); @@ -217,11 +222,5 @@ static void __exit via_rng_mod_exit(void) } module_exit(via_rng_mod_exit); -static struct x86_cpu_id __maybe_unused via_rng_cpu_id[] = { - X86_MATCH_FEATURE(X86_FEATURE_XSTORE, NULL), - {} -}; -MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_id); - MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock"); MODULE_LICENSE("GPL"); -- 2.34.1