Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4571051imw; Tue, 12 Jul 2022 10:11:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tLakddcoMhw2BpIkk4Fc9krIXFtfSIXu8TX+CL0wXvJEl/FYECfHHsWLEca6ItJMBpZ8gM X-Received: by 2002:a17:906:6a02:b0:72b:47ae:2a4f with SMTP id qw2-20020a1709066a0200b0072b47ae2a4fmr15004250ejc.446.1657645889020; Tue, 12 Jul 2022 10:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657645889; cv=none; d=google.com; s=arc-20160816; b=aNSYdx4r7CgL6zCdj6kyFveRhaiNmez0iAAmFiX406SohzL0SqlncHjWz6eDyIv+zc DzL3faFfMjm9irvBocoNohQ2UOX6YY5DWLIturO7frzlZpwKxsf50In+JntAKOFWBX5x fbhXMS+AxNPrLaSGWZD6P1ivFuaBnnQNuT4o5PxNY5+tMHn38nTataDB7+RrSSP4Leoo 5FUZchiZjHFsIvfpW01NjkXdQ0BHHyeGy2Sp7C6Kt3GkQa15gDgJawoD91GNugf9/WU4 OmmZ3WLpB+VuLG9wDa9h8iFNppY3Ff081Yf6k+sRzw9w2BwVdmDM1wonETbiGcbUdLTc 0qrw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=RYwp+YtDSCff/wQqHeUwTyAjBYTByIi6+8XH5HemPZs=; b=F5aeq1ClGHadP/7ygfcmk5Zc9DYwFChOmN3TwaQV7B2pMPXw7Ok3degDsUCEAP+yRS PIKxsGjDuHtNGV8yrD34wIxdDnjKasnxJRDLYSS4E8X/oBMT+92e6lxcCJ9ndpR1F0Y6 2oTMri8ypqiIBVEfZt2gFlRu5QNggdgM7LoLS5lBlEsOJb+nNxIwNl7KfifNLdVRkolq j1SKUgWz2LPf83qW8yP3oUHkyq6yEib4TmK1CTQEqidAbZwTU6tZBULMMJLg3yE+AupU tEgovlLI7OcBKYILUcYxvF+ZjCqSeGq5Orxt845kdDpi1xBCpgWdmwtDYXBgvuAWzo3+ pglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=np8uv2v+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a056402520600b0043ac5aa9baasi15508031edd.616.2022.07.12.10.11.03; Tue, 12 Jul 2022 10:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@ibm.com header.s=pp1 header.b=np8uv2v+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbiGLQua (ORCPT + 99 others); Tue, 12 Jul 2022 12:50:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232752AbiGLQu2 (ORCPT ); Tue, 12 Jul 2022 12:50:28 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C5E6BF552; Tue, 12 Jul 2022 09:50:28 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CGBVaI022563; Tue, 12 Jul 2022 16:50:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=RYwp+YtDSCff/wQqHeUwTyAjBYTByIi6+8XH5HemPZs=; b=np8uv2v+WOYHhtzbM7QLtKkDFbk5ikKSB1lckySlU5dBmfCBLKFrSJZM6uUv4SPp8hlv 1ePa5kkBdL2Iv5hcUYJMzYuGeS8OsiHnuci1UtL5aWH7H+/fx8lctHY8QQHP4o5YRkAD PL6/i+xksY2WNIX9H4nhtSRYmKD6CpDqlo4KaAfvkaTLGw1Ja9k07G8/PnpW4nmqp2DE 1zKkz71XO3t/RXe0+7MwYwYcrzkJEgJpFunhuM+8RIsNXRceWDZMnCrUPm1CTgi/GMjA yLKPG2y9NIG5SsQ6XwitT+7NiS+vpULsnJsch12WhR5y5O06K72zbO38sVUIYV/p6XjK Ag== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h9974xtbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 16:50:24 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26CGLFOD007719; Tue, 12 Jul 2022 16:50:23 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3h71a8kr96-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 16:50:23 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26CGoK2c20906332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Jul 2022 16:50:20 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE66142042; Tue, 12 Jul 2022 16:50:19 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7021242045; Tue, 12 Jul 2022 16:50:19 +0000 (GMT) Received: from p-imbrenda (unknown [9.145.1.61]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Jul 2022 16:50:19 +0000 (GMT) Date: Tue, 12 Jul 2022 18:46:19 +0200 From: Claudio Imbrenda To: Steffen Eiden Cc: Heiko Carstens , Alexander Gordeev , Christian Borntraeger , Janosch Frank , Vasily Gorbik , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nrb@linux.ibm.com Subject: Re: [PATCH 1/3] s390/cpufeature: rework to allow more than only hwcap bits Message-ID: <20220712184619.45edd420@p-imbrenda> In-Reply-To: <20220712105220.325010-2-seiden@linux.ibm.com> References: <20220712105220.325010-1-seiden@linux.ibm.com> <20220712105220.325010-2-seiden@linux.ibm.com> Organization: IBM X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: -Uzcnb3egHVSEuImscYwNKO8H59-pgrt X-Proofpoint-ORIG-GUID: -Uzcnb3egHVSEuImscYwNKO8H59-pgrt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_10,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 clxscore=1011 impostorscore=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120065 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org On Tue, 12 Jul 2022 12:52:18 +0200 Steffen Eiden wrote: > Rework cpufeature implementation to allow for various cpu feature > indications, which is not only limited to hwcap bits. This is achieved > by adding a sequential list of cpu feature numbers, where each of them > is mapped to an entry which indicates what this number is about. > > Each entry contains a type member, which indicates what feature > name space to look into (e.g. hwcap, or cpu facility). If wanted this > allows also to automatically load modules only in e.g. z/VM > configurations. > > Signed-off-by: Steffen Eiden > Signed-off-by: Heiko Carstens [...] > + > +/* > + * cpu_have_feature - Test CPU features on module initialization > + */ > +int cpu_have_feature(unsigned int num) > +{ > + struct s390_cpu_feature *feature; > + > + feature = &s390_cpu_features[num]; I would put some check to make sure you are going past the end of the array. Maybe something like if (num >= MAX_CPU_FEATURES) { WARN(1, "Invalid feature %d", num); return 0; } > + switch (feature->type) { > + case TYPE_HWCAP: > + return !!(elf_hwcap & (1UL << feature->num)); > + default: > + WARN_ON_ONCE(1); > + return 0; > + } > +} > +EXPORT_SYMBOL(cpu_have_feature); > diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c > index aa0e0e7fc773..a194611ba88c 100644 > --- a/arch/s390/kernel/processor.c > +++ b/arch/s390/kernel/processor.c > @@ -8,7 +8,6 @@ > #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt > > #include > -#include > #include > #include > #include > @@ -96,15 +95,6 @@ void cpu_init(void) > enter_lazy_tlb(&init_mm, current); > } > > -/* > - * cpu_have_feature - Test CPU features on module initialization > - */ > -int cpu_have_feature(unsigned int num) > -{ > - return elf_hwcap & (1UL << num); > -} > -EXPORT_SYMBOL(cpu_have_feature); > - > static void show_facilities(struct seq_file *m) > { > unsigned int bit; > diff --git a/drivers/char/hw_random/s390-trng.c b/drivers/char/hw_random/s390-trng.c > index 2beaa35c0d74..12fbac0ed8ca 100644 > --- a/drivers/char/hw_random/s390-trng.c > +++ b/drivers/char/hw_random/s390-trng.c > @@ -261,5 +261,5 @@ static void __exit trng_exit(void) > trng_debug_exit(); > } > > -module_cpu_feature_match(MSA, trng_init); > +module_cpu_feature_match(S390_CPU_FEATURE_MSA, trng_init); > module_exit(trng_exit); > diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c > index 7329caa7d467..5a05d1cdfec2 100644 > --- a/drivers/s390/crypto/pkey_api.c > +++ b/drivers/s390/crypto/pkey_api.c > @@ -2115,5 +2115,5 @@ static void __exit pkey_exit(void) > pkey_debug_exit(); > } > > -module_cpu_feature_match(MSA, pkey_init); > +module_cpu_feature_match(S390_CPU_FEATURE_MSA, pkey_init); > module_exit(pkey_exit);