From patchwork Wed Jul 13 05:47:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alastair D'Silva X-Patchwork-Id: 9226809 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DAA126075D for ; Wed, 13 Jul 2016 05:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAC642787D for ; Wed, 13 Jul 2016 05:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF94727C38; Wed, 13 Jul 2016 05:50:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E85BD27BFF for ; Wed, 13 Jul 2016 05:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751091AbcGMFsc (ORCPT ); Wed, 13 Jul 2016 01:48:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48206 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751035AbcGMFs3 (ORCPT ); Wed, 13 Jul 2016 01:48:29 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6D5i3jH086411 for ; Wed, 13 Jul 2016 01:48:13 -0400 Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by mx0a-001b2d01.pphosted.com with ESMTP id 24567cf6pg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 13 Jul 2016 01:48:12 -0400 Received: from localhost by e23smtp04.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Jul 2016 15:48:09 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp04.au.ibm.com (202.81.31.210) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 13 Jul 2016 15:48:04 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: alastair@au1.ibm.com X-IBM-RcptTo: linux-crypto@vger.kernel.org;linux-kernel@vger.kernel.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id AEF602CE805B; Wed, 13 Jul 2016 15:48:03 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6D5m3s028508406; Wed, 13 Jul 2016 15:48:03 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6D5m2Nb028309; Wed, 13 Jul 2016 15:48:03 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u6D5m29O028302; Wed, 13 Jul 2016 15:48:02 +1000 Received: from adsilva.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 13946A01AD; Wed, 13 Jul 2016 15:48:02 +1000 (AEST) From: alastair@au1.ibm.com To: mpe@ellerman.id.au Cc: benh@kernel.crashing.org, paulus@samba.org, herbert@gondor.apana.org.au, davem@davemloft.net, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, "Alastair D'Silva" Subject: [PATCH 1/2] powerpc: Add module autoloading based on CPU features Date: Wed, 13 Jul 2016 15:47:18 +1000 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468388840-12068-1-git-send-email-alastair@au1.ibm.com> References: <1468388840-12068-1-git-send-email-alastair@au1.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16071305-0012-0000-0000-000001AA0418 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16071305-0013-0000-0000-000005917126 Message-Id: <1468388840-12068-3-git-send-email-alastair@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-13_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607130064 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alastair D'Silva This patch provides the necessary infrastructure to allow drivers to be automatically loaded via UDEV. It implements the minimum required to be able to use module_cpu_feature_match to trigger the GENERIC_CPU_AUTOPROBE mechanisms. The features exposed are a mirror of the cpu_user_features (converted to an offset from a mask). This decision was made to ensure that the behavior between features for module loading and userspace are consistent. Signed-off-by: Alastair D'Silva --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/cpufeature.h | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 arch/powerpc/include/asm/cpufeature.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 0a9d439..a6e49db 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -164,6 +164,7 @@ config PPC select ARCH_HAS_UBSAN_SANITIZE_ALL select ARCH_SUPPORTS_DEFERRED_STRUCT_PAGE_INIT select HAVE_LIVEPATCH if HAVE_DYNAMIC_FTRACE_WITH_REGS + select GENERIC_CPU_AUTOPROBE config GENERIC_CSUM def_bool CPU_LITTLE_ENDIAN diff --git a/arch/powerpc/include/asm/cpufeature.h b/arch/powerpc/include/asm/cpufeature.h new file mode 100644 index 0000000..df31627 --- /dev/null +++ b/arch/powerpc/include/asm/cpufeature.h @@ -0,0 +1,70 @@ +/* CPU feature definitions for module loading, used by + * module_cpu_feature_match(), see asm/cputable.h for powerpc CPU features + * + * Copyright 2016 Alastair D'Silva, IBM Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef __ASM_CPUFEATURE_H +#define __ASM_POWERPC_CPUFEATURE_H + +#include + +/* Keep these in step with powerpc/include/asm/cputable.h */ +#define MAX_CPU_FEATURES (2 * 32) + +#define PPC_MODULE_FEATURE_32 (ilog2(PPC_FEATURE_32)) +#define PPC_MODULE_FEATURE_64 (ilog2(PPC_FEATURE_64)) +#define PPC_MODULE_FEATURE_601_INSTR (ilog2(PPC_FEATURE_601_INSTR)) +#define PPC_MODULE_FEATURE_HAS_ALTIVEC (ilog2(PPC_FEATURE_HAS_ALTIVEC)) +#define PPC_MODULE_FEATURE_HAS_FPU (ilog2(PPC_FEATURE_HAS_FPU)) +#define PPC_MODULE_FEATURE_HAS_MMU (ilog2(PPC_FEATURE_HAS_MMU)) +#define PPC_MODULE_FEATURE_HAS_4xxMAC (ilog2(PPC_FEATURE_HAS_4xxMAC)) +#define PPC_MODULE_FEATURE_UNIFIED_CACHE ilog2(PPC_FEATURE_UNIFIED_CACHE)) +#define PPC_MODULE_FEATURE_HAS_SPE (ilog2(PPC_FEATURE_HAS_SPE)) +#define PPC_MODULE_FEATURE_HAS_EFP_SINGLE (ilog2(PPC_FEATURE_HAS_EFP_SINGLE)) +#define PPC_MODULE_FEATURE_HAS_EFP_DOUBLE (ilog2(PPC_FEATURE_HAS_EFP_DOUBLE)) +#define PPC_MODULE_FEATURE_NO_TB (ilog2(PPC_FEATURE_NO_TB)) +#define PPC_MODULE_FEATURE_POWER4 (ilog2(PPC_FEATURE_POWER4)) +#define PPC_MODULE_FEATURE_POWER5 (ilog2(PPC_FEATURE_POWER5)) +#define PPC_MODULE_FEATURE_POWER5_PLUS (ilog2(PPC_FEATURE_POWER5_PLUS)) +#define PPC_MODULE_FEATURE_CELL (ilog2(PPC_FEATURE_CELL)) +#define PPC_MODULE_FEATURE_BOOKE (ilog2(PPC_FEATURE_BOOKE)) +#define PPC_MODULE_FEATURE_SMT (ilog2(PPC_FEATURE_SMT)) +#define PPC_MODULE_FEATURE_ICACHE_SNOOP (ilog2(PPC_FEATURE_ICACHE_SNOOP)) +#define PPC_MODULE_FEATURE_ARCH_2_05 (ilog2(PPC_FEATURE_ARCH_2_05)) +#define PPC_MODULE_FEATURE_PA6T (ilog2(PPC_FEATURE_PA6T)) +#define PPC_MODULE_FEATURE_HAS_DFP (ilog2(PPC_FEATURE_HAS_DFP)) +#define PPC_MODULE_FEATURE_POWER6_EXT (ilog2(PPC_FEATURE_POWER6_EXT)) +#define PPC_MODULE_FEATURE_ARCH_2_06 (ilog2(PPC_FEATURE_ARCH_2_06)) +#define PPC_MODULE_FEATURE_HAS_VSX (ilog2(PPC_FEATURE_HAS_VSX)) +#define PPC_MODULE_FEATURE_PSERIES_PERFMON_COMPAT (ilog2(PPC_FEATURE_PSERIES_PERFMON_COMPAT)) +#define PPC_MODULE_FEATURE_TRUE_LE (ilog2(PPC_FEATURE_TRUE_LE)) +#define PPC_MODULE_FEATURE_PPC_LE (ilog2(PPC_FEATURE_PPC_LE)) + +#define PPC_MODULE_FEATURE_ARCH_2_07 (32 + ilog2(PPC_FEATURE2_ARCH_2_07)) +#define PPC_MODULE_FEATURE_HTM (32 + ilog2(PPC_FEATURE2_HTM)) +#define PPC_MODULE_FEATURE_DSCR (32 + ilog2(PPC_FEATURE2_DSCR)) +#define PPC_MODULE_FEATURE_EBB (32 + ilog2(PPC_FEATURE2_EBB)) +#define PPC_MODULE_FEATURE_ISEL (32 + ilog2(PPC_FEATURE2_ISEL)) +#define PPC_MODULE_FEATURE_TAR (32 + ilog2(PPC_FEATURE2_TAR)) +#define PPC_MODULE_FEATURE_VEC_CRYPTO (32 + ilog2(PPC_FEATURE2_VEC_CRYPTO)) +#define PPC_MODULE_FEATURE_HTM_NOSC (32 + ilog2(PPC_FEATURE2_HTM_NOSC)) +#define PPC_MODULE_FEATURE_ARCH_3_00 (32 + ilog2(PPC_FEATURE2_ARCH_3_00)) +#define PPC_MODULE_FEATURE_HAS_IEEE128 (32 + ilog2(PPC_FEATURE2_HAS_IEEE128)) + +#define cpu_feature(x) (x) + +static inline bool cpu_have_feature(unsigned int num) +{ + if (num < 32) + return !!(cur_cpu_spec->cpu_user_features & 1UL << num); + else + return !!(cur_cpu_spec->cpu_user_features2 & 1UL << (num - 32)); +} + +#endif /* __ASM_POWERPC_CPUFEATURE_H */