From patchwork Thu Jul 6 14:59:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9828499 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 9EC9560317 for ; Thu, 6 Jul 2017 14:59:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AD2628671 for ; Thu, 6 Jul 2017 14:59:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2E02867D; Thu, 6 Jul 2017 14:59:47 +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,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham 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 9DB2028671 for ; Thu, 6 Jul 2017 14:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859AbdGFO7o (ORCPT ); Thu, 6 Jul 2017 10:59:44 -0400 Received: from mail-sn1nam01on0058.outbound.protection.outlook.com ([104.47.32.58]:2496 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750922AbdGFO7m (ORCPT ); Thu, 6 Jul 2017 10:59:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4GvDZHJpiU2Mddn/sDuvN1DhehNNMgsfIjEv4esD4Do=; b=Mzz3S+5l6VtQk9VKPwnLByvsKuv9pwep5K8RSUv5g9V0VOi4hTyHSwWeeIuu9s2X6lfE9M4IdCCJujjuCDC1ry2Ka/1At2RtDzTK5teG195W7UO3ai/3Swkb73JkUbyHRj8bxJ7bsJSJuuoMm0jfhQUBmPWvOS9dlVUlUk0IP20= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from ubuntu-010236106000.amd.com (165.204.78.1) by BY2PR12MB0146.namprd12.prod.outlook.com (10.162.82.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1240.13; Thu, 6 Jul 2017 14:59:38 +0000 From: Brijesh Singh To: linux-crypto@vger.kernel.org Cc: gary.hook@amd.com, herbert@gondor.apana.org.au, davem@davemloft.net, thomas.lendacky@amd.com, Brijesh Singh Subject: [PATCH v4 2/5] crypto: ccp - Introduce the AMD Secure Processor device Date: Thu, 6 Jul 2017 09:59:14 -0500 Message-Id: <20170706145917.98876-3-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170706145917.98876-1-brijesh.singh@amd.com> References: <20170706145917.98876-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM5PR17CA0031.namprd17.prod.outlook.com (10.173.128.145) To BY2PR12MB0146.namprd12.prod.outlook.com (10.162.82.19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 311147d6-64fb-4a61-8bc4-08d4c47fa017 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BY2PR12MB0146; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 3:NXUF4lV6zub1h21asi8b+CS0zpA0l64AHO7LN1RNBnCMNhRa3SLj19iEnfddm9p48FpIsz3IijCrGEtaL9ZM1JPQAu0DBGQUMaLfOAqn/1vbVRYsm5AettEssKIjniOiCqSnE3xlFFiqiZBbxBR/UTiyUYR4ZVfsM22fNIi6/5Os1C5YAcnbH4C03qwH0pEtUMmcqD9lsjgLRGnW+5GMUTTerKchbyW14P88ylMoUe8yF5K0r6l7U/bXJVNtj9o/SiJIJBHXFf9AdGAhwB2leMBP+1b/YtluS/izpkPZAF7foz8JZTHjbnXIAdJm/mwWRZqWfMMGHHtfoSc5tHyPUIzMVrx1FzjhCggrvITi2tUS2DLuk6UG74A5CPNCm+2LYpqGgn5x8ZyIfTn9yNPL5Fmg4qYGjobgSa2BPlDmf+RlVegbYwWHqyW1dYmg/u/T/o2MMH8VtkE1K8UlnyjwIf9eXiw9BkLTGAY5vCffvZGLZjYcSxNHDxbShs86JuadHZqX4MlPQKDhYB9PdK2AnFNiGDgmmGsKa9a1TWPPJNWMKARTiLiiPXu/ijbrKEAWTNZWX47tqKtdQtEJVlTqaCym6rfm/KelG265yypSysxpN35KICo+Yz5yAC4WwE8V5OakFAy8E+9TDOoOvlG70fQWZyN6xAGVIu24Dhrfs1rM0++mq1UfB8paQDAJS5Vb8D9/rns3c1TTN5K21uemid5NDyuUKxKwuU0cXCXos+YNXokfaLLEduiie1fniosMbVNnObVuPKxaFz49wBoc2g== X-MS-TrafficTypeDiagnostic: BY2PR12MB0146: X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 25:M7VFSFrZL3/pEf5ZrF/Yfm9rpFFheiEoQd1xE1DfAb1GTbCE/H5VRXIfQPXgjWbfZGFjrBMP8cFOQzILHscaXnFUNGK9ma4vsnBwhwjZqTlQfocbBngwtZV8rtBu5jAQCMjuW2qy6iMPaX5o7a54dzJhD8UVdKy0yTmU3Yb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452VFvrHzK+SOqySqeZtSxwMFku0MDErxnWZwv9R+qKbyoNJV42L/MSUH5aemab1Owt4bRfoCs0vXYUVAUOqvljZGbxkfE3hBWnWFOsQk//EI38U4E6tKhJXrS1zOJDkJ0U72s2qlVk+qxJ274JibRVT8jH4HakmqOng1r6RaeV+z93Mdvf8tjVxuNaooOspKL54CmV+t6jDE5H5bg7bov6+BjX+BOlkSaBoVmneHkGYCWbk9Bi0VN1bq1slmqAbbHzUDlUia3foLa027LDUudgh8/B7hQoZxbT3U+kumfiWyBKDOE246cUhzKsmnOjC+6HSD6yYpF51n+EHJVZ+1GxZQxA4taThK9w3+ee66GayikO9SyqdWPt7Ar9ap/EywhEmdFzVftemQZ6vY+Emzcbi/Om1jlJOtG4= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 20:YA2KTVT2J+vsNW061eGiNMZFJnbEHI7jg82kHki1DF+mwlhCdAx9TOvAkIXB9bYokhLsxfWrVfz7ChMAi0sgYg8rBJteOuaLKO1ohp5XHr0RodTDPkMKVzG4oDSZiSZ2RTvaNkL09qlmzC1BFOM0cfPQYcfBcdMcP4aQuMfoyOpQp18O8HYz0p/25lALRJRASyGRPUkLQDG7ChXNxvv2iKoPFF6awzJsH816lCG5Mz1rRB9QgYaq+cvF6fSHDK2hBQM4c7mFrlsxAdoPpqdJEjMGdZgj+1yPeQvKXeN/7QkVwdnT7iCHvSybSE8P1lOUIhc5pwPpBzbwmJfkoLOfUpKtNZvBGIuRKXmA0LNphtM1zmpJTapo1hrh/E1+BpPsPX89hJLYRdoaRYMrTAx2+vp7f9gXyoRfrcZ1jVXKF5Md/1yMJ9+67lspVooiejLKxSFhUzc4q6yvUZFUmgtUzY91R6uSL+AQkIcI4+mAdezMDBCbYrUHM3e+J9YSEgac X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(125551606395959)(133145235818549)(236129657087228)(192374486261705)(767451399110)(148574349560750); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(2017060910049)(8121501046)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123564025)(20161123560025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY2PR12MB0146; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY2PR12MB0146; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0146; 4:VLc2KLcYDZpPpgM1VywI8h6QZl+TWRU5ACzrcJm3qK?= =?us-ascii?Q?0MdvhCvkVDI4vnIhveuik6+7qxB7JcMYCgZhFuc5VizHM2eGG4awoFG+N8mS?= =?us-ascii?Q?XNAMdKExpQUN9aTC1mbNxOz1n/y3Ep7ZMW4TBZC5uJV+3n1nYgTPlvcC/W/f?= =?us-ascii?Q?COcDVSJieyu18oAem7rkQ5ugk2Xj6cEQY3KlJ7AuVX+F5OJ7JVMUETNekRz7?= =?us-ascii?Q?QX+JcMxD/A5JwTNokvLryCtKds83Fc7usg5K1dovJUfvUi+FmhD1DE4aPVyV?= =?us-ascii?Q?PSbuv4g4mPwC6j74GbP2RTdYQqr2XpmgkK++vMHxNOTrxYI7eQuEtViHt0xE?= =?us-ascii?Q?RmkiLXn5JcqqJzsfv/+guf9IwRFx5n20mXrY/uqAyKjMxKjStnwf9P1lJig6?= =?us-ascii?Q?tNizM2dFrn5oUbk2c1tRLovT2fOsMBg/3ePH/Odq95IECGsQazV5hVC1FMbB?= =?us-ascii?Q?kYjle1RJ6YgqQ7JQTZgrvLTMHWc2Er5uXdD+bYW6NKp/we3Qs695lxJRaAYp?= =?us-ascii?Q?xqeRPSiMbHt2CYrieOFGQixp3LackonFR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?Q?V0vGkAsg=3D=3D?= X-Forefront-PRVS: 03607C04F0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39410400002)(39400400002)(39850400002)(39450400003)(39840400002)(39860400002)(38730400002)(53936002)(110136004)(53946003)(7736002)(305945005)(6486002)(1076002)(189998001)(47776003)(575784001)(2906002)(3846002)(86362001)(5660300001)(6116002)(66066001)(36756003)(50986999)(50226002)(76176999)(48376002)(81166006)(478600001)(8676002)(5003940100001)(6916009)(6666003)(2950100002)(2351001)(50466002)(2361001)(53416004)(42186005)(4326008)(33646002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0146; H:ubuntu-010236106000.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0146; 23:5WwI7u882R7q8bpHJdpKTQISee4aJVKPJI49JiMk1?= =?us-ascii?Q?YMW343QsZ24G7xoRl/o1ZOf0Zo1OmWFR96J2fMmA9rq1MmIt9fbEz1ud3xnm?= =?us-ascii?Q?jo2MlAvhOeH/M4SzujI5q/4MVDE7HjARaBE2eGR+EVu4y7YK8hjC231k2bD6?= =?us-ascii?Q?AS0Bm9DP1SuTkrv86pzA3vbhqJ3RPo30y5X51OhH3bxRSinxdWvVT+EQaGFd?= =?us-ascii?Q?5xNBC96Xa6plRIBErOMHx3/5KWWs/Loo4tWonG7ijarkkMTfPAHFFwQtHgGA?= =?us-ascii?Q?QvtxjWZ8SqfQwjg1cFin2zeM5XO/heh1ybhu3KpOMMPgYW3W2HJzCArUuxBR?= =?us-ascii?Q?R3MUBrbZd45Agvs4rDNjIzshDW9fyNDi6p8RMLj9VhMwknP/osfz31wFt8SA?= =?us-ascii?Q?XFJHqOloGe4Tj9/CCC3oKxgllTPGVi028Ol8tFv6KRO8lsQy86UmIXD1hwRe?= =?us-ascii?Q?bOfG6E/UYVU+Qcc9qdgCH7e3kFa7A/+RC2re0Swj5gTKjE47A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uzl2qFTYIGKh6NU1QMnxYgEE4SRewvcyd6DoMPOpEZaQjh53s1mohN5PocKtE7Okij9gbJgw1AoEga5NQv8a8xumBsod8yxRhOKhqEVxil6ZJDQBQrRn397eTFEuVBURL1HZz+aUGVC/lIcJiAqd2IdV7Z/FiwkEEM7tghAvLMVYZlbR9ZphXz0PfkgZoBIiHhdSxBJXh7+ENkjCZXJMOnGmnaIdIhgv7N89X/UIvb52vHdRJObxPZbH7jDuFP+GQCNxtKsxMVNCM8hi6OTqJpB+UOBv7YkUqFqFAuMCIdpDVl518eZL8VbfY3HRbBOV0jgjnOhA2Ir1/oTH3iv3LkD30iGb2PVW1c/cjpqghJKXNNsHwuG4FF83DiVf8bF1F9lGlAbJ6qVUyCq2b0fw1rIEIdGy8veegJkDPub6B4jfPY= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0146; 20:V+O3I83nNkf41084i2MT9eup3nUUvY1p90s2/jpZzNNQnI1e9VloyIWh1lNawv4GUwNB6MRjmakJXZDDumgRMD9yanSKIHwo6aqyty91VH0MftmET5axP56+hH6juRmpzmPEWtwSYoAHtQ+DtjeYnNnhJz6iXjnwpobpyIh4Wbc/iNL5ZX1+u68bDrtFUjbnJWAudvScnLrhZ2jEJUoYHwhOfikOBJ50qzENNuE0YAlPkhX91SlqLqH0OTIhzVV7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2017 14:59:38.6006 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0146 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 The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD Secure Processor to be initialized and handled appropriately. Signed-off-by: Brijesh Singh Acked-by: Gary R Hook --- drivers/crypto/Kconfig | 6 +- drivers/crypto/ccp/Kconfig | 21 +++-- drivers/crypto/ccp/Makefile | 4 +- drivers/crypto/ccp/ccp-dev-v3.c | 4 +- drivers/crypto/ccp/ccp-dev-v5.c | 5 +- drivers/crypto/ccp/ccp-dev.c | 106 +++++++++------------- drivers/crypto/ccp/ccp-dev.h | 21 +---- drivers/crypto/ccp/ccp-pci.c | 81 +++++++++++------ drivers/crypto/ccp/ccp-platform.c | 70 ++++++++------- drivers/crypto/ccp/sp-dev.c | 182 ++++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/sp-dev.h | 120 +++++++++++++++++++++++++ include/linux/ccp.h | 7 +- 12 files changed, 463 insertions(+), 164 deletions(-) create mode 100644 drivers/crypto/ccp/sp-dev.c create mode 100644 drivers/crypto/ccp/sp-dev.h diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 0528a62..3f4c326 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -513,11 +513,11 @@ config CRYPTO_DEV_ATMEL_SHA will be called atmel-sha. config CRYPTO_DEV_CCP - bool "Support for AMD Cryptographic Coprocessor" + bool "Support for AMD Secure Processor" depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && HAS_IOMEM help - The AMD Cryptographic Coprocessor provides hardware offload support - for encryption, hashing and related operations. + The AMD Secure Processor provides support for the Cryptographic Coprocessor + (CCP) and the Platform Security Processor (PSP) devices. if CRYPTO_DEV_CCP source "drivers/crypto/ccp/Kconfig" diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kconfig index 2238f77..15b63fd 100644 --- a/drivers/crypto/ccp/Kconfig +++ b/drivers/crypto/ccp/Kconfig @@ -1,22 +1,29 @@ config CRYPTO_DEV_CCP_DD - tristate "Cryptographic Coprocessor device driver" - depends on CRYPTO_DEV_CCP + tristate "Secure Processor device driver" default m + help + Provides AMD Secure Processor device driver. + If you choose 'M' here, this module will be called ccp. + +config CRYPTO_DEV_SP_CCP + bool "Cryptographic Coprocessor device" + default y + depends on CRYPTO_DEV_CCP_DD select HW_RANDOM select DMA_ENGINE select DMADEVICES select CRYPTO_SHA1 select CRYPTO_SHA256 help - Provides the interface to use the AMD Cryptographic Coprocessor - which can be used to offload encryption operations such as SHA, - AES and more. If you choose 'M' here, this module will be called - ccp. + Provides the support for AMD Cryptographic Coprocessor (CCP) device + which can be used to offload encryption operations such as SHA, AES + and more. config CRYPTO_DEV_CCP_CRYPTO tristate "Encryption and hashing offload support" - depends on CRYPTO_DEV_CCP_DD default m + depends on CRYPTO_DEV_CCP_DD + depends on CRYPTO_DEV_SP_CCP select CRYPTO_HASH select CRYPTO_BLKCIPHER select CRYPTO_AUTHENC diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile index 59493fd..d2f1b52 100644 --- a/drivers/crypto/ccp/Makefile +++ b/drivers/crypto/ccp/Makefile @@ -1,9 +1,9 @@ obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o -ccp-objs := ccp-dev.o \ +ccp-objs := sp-dev.o ccp-platform.o +ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \ ccp-ops.o \ ccp-dev-v3.o \ ccp-dev-v5.o \ - ccp-platform.o \ ccp-dmaengine.o \ ccp-debugfs.o ccp-$(CONFIG_PCI) += ccp-pci.o diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c index 52aa88b..57179034 100644 --- a/drivers/crypto/ccp/ccp-dev-v3.c +++ b/drivers/crypto/ccp/ccp-dev-v3.c @@ -359,8 +359,7 @@ static void ccp_irq_bh(unsigned long data) static irqreturn_t ccp_irq_handler(int irq, void *data) { - struct device *dev = data; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct ccp_device *ccp = (struct ccp_device *)data; ccp_disable_queue_interrupts(ccp); if (ccp->use_tasklet) @@ -597,6 +596,5 @@ const struct ccp_vdata ccpv3 = { .version = CCP_VERSION(3, 0), .setup = NULL, .perform = &ccp3_actions, - .bar = 2, .offset = 0x20000, }; diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c index b10d2d2..8ed2b37 100644 --- a/drivers/crypto/ccp/ccp-dev-v5.c +++ b/drivers/crypto/ccp/ccp-dev-v5.c @@ -769,8 +769,7 @@ static void ccp5_irq_bh(unsigned long data) static irqreturn_t ccp5_irq_handler(int irq, void *data) { - struct device *dev = data; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct ccp_device *ccp = (struct ccp_device *)data; ccp5_disable_queue_interrupts(ccp); ccp->total_interrupts++; @@ -1113,7 +1112,6 @@ const struct ccp_vdata ccpv5a = { .version = CCP_VERSION(5, 0), .setup = ccp5_config, .perform = &ccp5_actions, - .bar = 2, .offset = 0x0, }; @@ -1122,6 +1120,5 @@ const struct ccp_vdata ccpv5b = { .dma_chan_attr = DMA_PRIVATE, .setup = ccp5other_config, .perform = &ccp5_actions, - .bar = 2, .offset = 0x0, }; diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index abb3d68..8a1674a 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -111,13 +111,6 @@ static LIST_HEAD(ccp_units); static DEFINE_SPINLOCK(ccp_rr_lock); static struct ccp_device *ccp_rr; -/* Ever-increasing value to produce unique unit numbers */ -static atomic_t ccp_unit_ordinal; -static unsigned int ccp_increment_unit_ordinal(void) -{ - return atomic_inc_return(&ccp_unit_ordinal); -} - /** * ccp_add_device - add a CCP device to the list * @@ -464,14 +457,17 @@ int ccp_cmd_queue_thread(void *data) * * @dev: device struct of the CCP */ -struct ccp_device *ccp_alloc_struct(struct device *dev) +struct ccp_device *ccp_alloc_struct(struct sp_device *sp) { + struct device *dev = sp->dev; struct ccp_device *ccp; ccp = devm_kzalloc(dev, sizeof(*ccp), GFP_KERNEL); if (!ccp) return NULL; ccp->dev = dev; + ccp->sp = sp; + ccp->axcache = sp->axcache; INIT_LIST_HEAD(&ccp->cmd); INIT_LIST_HEAD(&ccp->backlog); @@ -486,9 +482,8 @@ struct ccp_device *ccp_alloc_struct(struct device *dev) init_waitqueue_head(&ccp->sb_queue); init_waitqueue_head(&ccp->suspend_queue); - ccp->ord = ccp_increment_unit_ordinal(); - snprintf(ccp->name, MAX_CCP_NAME_LEN, "ccp-%u", ccp->ord); - snprintf(ccp->rngname, MAX_CCP_NAME_LEN, "ccp-%u-rng", ccp->ord); + snprintf(ccp->name, MAX_CCP_NAME_LEN, "ccp-%u", sp->ord); + snprintf(ccp->rngname, MAX_CCP_NAME_LEN, "ccp-%u-rng", sp->ord); return ccp; } @@ -539,8 +534,9 @@ bool ccp_queues_suspended(struct ccp_device *ccp) return ccp->cmd_q_count == suspended; } -int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state) +int ccp_dev_suspend(struct sp_device *sp, pm_message_t state) { + struct ccp_device *ccp = sp->ccp_data; unsigned long flags; unsigned int i; @@ -562,8 +558,9 @@ int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state) return 0; } -int ccp_dev_resume(struct ccp_device *ccp) +int ccp_dev_resume(struct sp_device *sp) { + struct ccp_device *ccp = sp->ccp_data; unsigned long flags; unsigned int i; @@ -583,71 +580,54 @@ int ccp_dev_resume(struct ccp_device *ccp) } #endif -int ccp_dev_init(struct ccp_device *ccp) +int ccp_dev_init(struct sp_device *sp) { - ccp->io_regs = ccp->io_map + ccp->vdata->offset; - - if (ccp->vdata->setup) - ccp->vdata->setup(ccp); - - return ccp->vdata->perform->init(ccp); -} + struct device *dev = sp->dev; + struct ccp_device *ccp; + int ret; -void ccp_dev_destroy(struct ccp_device *ccp) -{ + ret = -ENOMEM; + ccp = ccp_alloc_struct(sp); if (!ccp) - return; + goto e_err; + sp->ccp_data = ccp; + + ccp->vdata = (struct ccp_vdata *)sp->dev_vdata->ccp_vdata; + if (!ccp->vdata || !ccp->vdata->version) { + ret = -ENODEV; + dev_err(dev, "missing driver data\n"); + goto e_err; + } - ccp->vdata->perform->destroy(ccp); -} + ccp->get_irq = sp->get_irq; + ccp->free_irq = sp->free_irq; -static int __init ccp_mod_init(void) -{ -#ifdef CONFIG_X86 - int ret; + ccp->io_regs = sp->io_map + ccp->vdata->offset; + if (ccp->vdata->setup) + ccp->vdata->setup(ccp); - ret = ccp_pci_init(); + ret = ccp->vdata->perform->init(ccp); if (ret) - return ret; + goto e_err; - /* Don't leave the driver loaded if init failed */ - if (ccp_present() != 0) { - ccp_pci_exit(); - return -ENODEV; - } + dev_notice(dev, "ccp enabled\n"); return 0; -#endif - -#ifdef CONFIG_ARM64 - int ret; - ret = ccp_platform_init(); - if (ret) - return ret; +e_err: + sp->ccp_data = NULL; - /* Don't leave the driver loaded if init failed */ - if (ccp_present() != 0) { - ccp_platform_exit(); - return -ENODEV; - } - - return 0; -#endif + dev_notice(dev, "ccp initialization failed\n"); - return -ENODEV; + return ret; } -static void __exit ccp_mod_exit(void) +void ccp_dev_destroy(struct sp_device *sp) { -#ifdef CONFIG_X86 - ccp_pci_exit(); -#endif + struct ccp_device *ccp = sp->ccp_data; -#ifdef CONFIG_ARM64 - ccp_platform_exit(); -#endif -} + if (!ccp) + return; -module_init(ccp_mod_init); -module_exit(ccp_mod_exit); + ccp->vdata->perform->destroy(ccp); +} diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h index df2e76e..ca44821 100644 --- a/drivers/crypto/ccp/ccp-dev.h +++ b/drivers/crypto/ccp/ccp-dev.h @@ -27,6 +27,8 @@ #include #include +#include "sp-dev.h" + #define MAX_CCP_NAME_LEN 16 #define MAX_DMAPOOL_NAME_LEN 32 @@ -344,6 +346,7 @@ struct ccp_device { char rngname[MAX_CCP_NAME_LEN]; struct device *dev; + struct sp_device *sp; /* Bus specific device information */ @@ -362,7 +365,6 @@ struct ccp_device { * them. */ struct mutex req_mutex ____cacheline_aligned; - void __iomem *io_map; void __iomem *io_regs; /* Master lists that all cmds are queued on. Because there can be @@ -637,7 +639,7 @@ void ccp_del_device(struct ccp_device *ccp); extern void ccp_log_error(struct ccp_device *, int); -struct ccp_device *ccp_alloc_struct(struct device *dev); +struct ccp_device *ccp_alloc_struct(struct sp_device *sp); bool ccp_queues_suspended(struct ccp_device *ccp); int ccp_cmd_queue_thread(void *data); int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait); @@ -652,11 +654,6 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp); void ccp5_debugfs_setup(struct ccp_device *ccp); void ccp5_debugfs_destroy(void); -int ccp_dev_init(struct ccp_device *ccp); -void ccp_dev_destroy(struct ccp_device *ccp); -int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state); -int ccp_dev_resume(struct ccp_device *ccp); - /* Structure for computation functions that are device-specific */ struct ccp_actions { int (*aes)(struct ccp_op *); @@ -674,16 +671,6 @@ struct ccp_actions { irqreturn_t (*irqhandler)(int, void *); }; -/* Structure to hold CCP version-specific values */ -struct ccp_vdata { - const unsigned int version; - const unsigned int dma_chan_attr; - void (*setup)(struct ccp_device *); - const struct ccp_actions *perform; - const unsigned int bar; - const unsigned int offset; -}; - extern const struct ccp_vdata ccpv3_platform; extern const struct ccp_vdata ccpv3; extern const struct ccp_vdata ccpv5a; diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c index 490ad0a..ab2df96 100644 --- a/drivers/crypto/ccp/ccp-pci.c +++ b/drivers/crypto/ccp/ccp-pci.c @@ -40,7 +40,8 @@ struct ccp_pci { static int ccp_get_msix_irqs(struct ccp_device *ccp) { - struct ccp_pci *ccp_pci = ccp->dev_specific; + struct sp_device *sp = ccp->sp; + struct ccp_pci *ccp_pci = sp->dev_specific; struct device *dev = ccp->dev; struct pci_dev *pdev = to_pci_dev(dev); struct msix_entry msix_entry[MSIX_VECTORS]; @@ -58,11 +59,11 @@ static int ccp_get_msix_irqs(struct ccp_device *ccp) for (v = 0; v < ccp_pci->msix_count; v++) { /* Set the interrupt names and request the irqs */ snprintf(ccp_pci->msix[v].name, name_len, "%s-%u", - ccp->name, v); + sp->name, v); ccp_pci->msix[v].vector = msix_entry[v].vector; ret = request_irq(ccp_pci->msix[v].vector, ccp->vdata->perform->irqhandler, - 0, ccp_pci->msix[v].name, dev); + 0, ccp_pci->msix[v].name, ccp); if (ret) { dev_notice(dev, "unable to allocate MSI-X IRQ (%d)\n", ret); @@ -86,6 +87,7 @@ static int ccp_get_msix_irqs(struct ccp_device *ccp) static int ccp_get_msi_irq(struct ccp_device *ccp) { + struct sp_device *sp = ccp->sp; struct device *dev = ccp->dev; struct pci_dev *pdev = to_pci_dev(dev); int ret; @@ -96,7 +98,7 @@ static int ccp_get_msi_irq(struct ccp_device *ccp) ccp->irq = pdev->irq; ret = request_irq(ccp->irq, ccp->vdata->perform->irqhandler, 0, - ccp->name, dev); + sp->name, ccp); if (ret) { dev_notice(dev, "unable to allocate MSI IRQ (%d)\n", ret); goto e_msi; @@ -134,17 +136,18 @@ static int ccp_get_irqs(struct ccp_device *ccp) static void ccp_free_irqs(struct ccp_device *ccp) { - struct ccp_pci *ccp_pci = ccp->dev_specific; + struct sp_device *sp = ccp->sp; + struct ccp_pci *ccp_pci = sp->dev_specific; struct device *dev = ccp->dev; struct pci_dev *pdev = to_pci_dev(dev); if (ccp_pci->msix_count) { while (ccp_pci->msix_count--) free_irq(ccp_pci->msix[ccp_pci->msix_count].vector, - dev); + ccp); pci_disable_msix(pdev); } else if (ccp->irq) { - free_irq(ccp->irq, dev); + free_irq(ccp->irq, ccp); pci_disable_msi(pdev); } ccp->irq = 0; @@ -152,7 +155,7 @@ static void ccp_free_irqs(struct ccp_device *ccp) static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - struct ccp_device *ccp; + struct sp_device *sp; struct ccp_pci *ccp_pci; struct device *dev = &pdev->dev; void __iomem * const *iomap_table; @@ -160,23 +163,23 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) int ret; ret = -ENOMEM; - ccp = ccp_alloc_struct(dev); - if (!ccp) + sp = sp_alloc_struct(dev); + if (!sp) goto e_err; ccp_pci = devm_kzalloc(dev, sizeof(*ccp_pci), GFP_KERNEL); if (!ccp_pci) goto e_err; - ccp->dev_specific = ccp_pci; - ccp->vdata = (struct ccp_vdata *)id->driver_data; - if (!ccp->vdata || !ccp->vdata->version) { + sp->dev_specific = ccp_pci; + sp->dev_vdata = (struct sp_dev_vdata *)id->driver_data; + if (!sp->dev_vdata) { ret = -ENODEV; dev_err(dev, "missing driver data\n"); goto e_err; } - ccp->get_irq = ccp_get_irqs; - ccp->free_irq = ccp_free_irqs; + sp->get_irq = ccp_get_irqs; + sp->free_irq = ccp_free_irqs; ret = pcim_enable_device(pdev); if (ret) { @@ -198,8 +201,8 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto e_err; } - ccp->io_map = iomap_table[ccp->vdata->bar]; - if (!ccp->io_map) { + sp->io_map = iomap_table[sp->dev_vdata->bar]; + if (!sp->io_map) { dev_err(dev, "ioremap failed\n"); ret = -ENOMEM; goto e_err; @@ -217,9 +220,9 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) } } - dev_set_drvdata(dev, ccp); + dev_set_drvdata(dev, sp); - ret = ccp_dev_init(ccp); + ret = sp_init(sp); if (ret) goto e_err; @@ -235,12 +238,12 @@ static int ccp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) static void ccp_pci_remove(struct pci_dev *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - if (!ccp) + if (!sp) return; - ccp_dev_destroy(ccp); + sp_destroy(sp); dev_notice(dev, "disabled\n"); } @@ -249,24 +252,44 @@ static void ccp_pci_remove(struct pci_dev *pdev) static int ccp_pci_suspend(struct pci_dev *pdev, pm_message_t state) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_suspend(ccp, state); + return sp_suspend(sp, state); } static int ccp_pci_resume(struct pci_dev *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_resume(ccp); + return sp_resume(sp); } #endif +static const struct sp_dev_vdata dev_vdata[] = { + { + .bar = 2, +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + .ccp_vdata = &ccpv3, +#endif + }, + { + .bar = 2, +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + .ccp_vdata = &ccpv5a, +#endif + }, + { + .bar = 2, +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + .ccp_vdata = &ccpv5b, +#endif + }, +}; static const struct pci_device_id ccp_pci_table[] = { - { PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&ccpv3 }, - { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&ccpv5a }, - { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&ccpv5b }, + { PCI_VDEVICE(AMD, 0x1537), (kernel_ulong_t)&dev_vdata[0] }, + { PCI_VDEVICE(AMD, 0x1456), (kernel_ulong_t)&dev_vdata[1] }, + { PCI_VDEVICE(AMD, 0x1468), (kernel_ulong_t)&dev_vdata[2] }, /* Last entry must be zero */ { 0, } }; diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c index 4a970b1..17e75fd 100644 --- a/drivers/crypto/ccp/ccp-platform.c +++ b/drivers/crypto/ccp/ccp-platform.c @@ -35,26 +35,26 @@ struct ccp_platform { static const struct acpi_device_id ccp_acpi_match[]; static const struct of_device_id ccp_of_match[]; -static struct ccp_vdata *ccp_get_of_version(struct platform_device *pdev) +static struct sp_dev_vdata *ccp_get_of_version(struct platform_device *pdev) { #ifdef CONFIG_OF const struct of_device_id *match; match = of_match_node(ccp_of_match, pdev->dev.of_node); if (match && match->data) - return (struct ccp_vdata *)match->data; + return (struct sp_dev_vdata *)match->data; #endif return NULL; } -static struct ccp_vdata *ccp_get_acpi_version(struct platform_device *pdev) +static struct sp_dev_vdata *ccp_get_acpi_version(struct platform_device *pdev) { #ifdef CONFIG_ACPI const struct acpi_device_id *match; match = acpi_match_device(ccp_acpi_match, &pdev->dev); if (match && match->driver_data) - return (struct ccp_vdata *)match->driver_data; + return (struct sp_dev_vdata *)match->driver_data; #endif return NULL; } @@ -71,7 +71,7 @@ static int ccp_get_irq(struct ccp_device *ccp) ccp->irq = ret; ret = request_irq(ccp->irq, ccp->vdata->perform->irqhandler, 0, - ccp->name, dev); + ccp->name, ccp); if (ret) { dev_notice(dev, "unable to allocate IRQ (%d)\n", ret); return ret; @@ -97,14 +97,12 @@ static int ccp_get_irqs(struct ccp_device *ccp) static void ccp_free_irqs(struct ccp_device *ccp) { - struct device *dev = ccp->dev; - - free_irq(ccp->irq, dev); + free_irq(ccp->irq, ccp); } static int ccp_platform_probe(struct platform_device *pdev) { - struct ccp_device *ccp; + struct sp_device *sp; struct ccp_platform *ccp_platform; struct device *dev = &pdev->dev; enum dev_dma_attr attr; @@ -112,32 +110,31 @@ static int ccp_platform_probe(struct platform_device *pdev) int ret; ret = -ENOMEM; - ccp = ccp_alloc_struct(dev); - if (!ccp) + sp = sp_alloc_struct(dev); + if (!sp) goto e_err; ccp_platform = devm_kzalloc(dev, sizeof(*ccp_platform), GFP_KERNEL); if (!ccp_platform) goto e_err; - ccp->dev_specific = ccp_platform; - ccp->vdata = pdev->dev.of_node ? ccp_get_of_version(pdev) + sp->dev_specific = ccp_platform; + sp->dev_vdata = pdev->dev.of_node ? ccp_get_of_version(pdev) : ccp_get_acpi_version(pdev); - if (!ccp->vdata || !ccp->vdata->version) { + if (!sp->dev_vdata) { ret = -ENODEV; dev_err(dev, "missing driver data\n"); goto e_err; } - ccp->get_irq = ccp_get_irqs; - ccp->free_irq = ccp_free_irqs; + sp->get_irq = ccp_get_irqs; + sp->free_irq = ccp_free_irqs; ior = platform_get_resource(pdev, IORESOURCE_MEM, 0); - ccp->io_map = devm_ioremap_resource(dev, ior); - if (IS_ERR(ccp->io_map)) { - ret = PTR_ERR(ccp->io_map); + sp->io_map = devm_ioremap_resource(dev, ior); + if (IS_ERR(sp->io_map)) { + ret = PTR_ERR(sp->io_map); goto e_err; } - ccp->io_regs = ccp->io_map; attr = device_get_dma_attr(dev); if (attr == DEV_DMA_NOT_SUPPORTED) { @@ -147,9 +144,9 @@ static int ccp_platform_probe(struct platform_device *pdev) ccp_platform->coherent = (attr == DEV_DMA_COHERENT); if (ccp_platform->coherent) - ccp->axcache = CACHE_WB_NO_ALLOC; + sp->axcache = CACHE_WB_NO_ALLOC; else - ccp->axcache = CACHE_NONE; + sp->axcache = CACHE_NONE; ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); if (ret) { @@ -157,9 +154,9 @@ static int ccp_platform_probe(struct platform_device *pdev) goto e_err; } - dev_set_drvdata(dev, ccp); + dev_set_drvdata(dev, sp); - ret = ccp_dev_init(ccp); + ret = sp_init(sp); if (ret) goto e_err; @@ -175,9 +172,9 @@ static int ccp_platform_probe(struct platform_device *pdev) static int ccp_platform_remove(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - ccp_dev_destroy(ccp); + sp_destroy(sp); dev_notice(dev, "disabled\n"); @@ -189,23 +186,32 @@ static int ccp_platform_suspend(struct platform_device *pdev, pm_message_t state) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_suspend(ccp, state); + return sp_suspend(sp, state); } static int ccp_platform_resume(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct ccp_device *ccp = dev_get_drvdata(dev); + struct sp_device *sp = dev_get_drvdata(dev); - return ccp_dev_resume(ccp); + return sp_resume(sp); } #endif +static const struct sp_dev_vdata dev_vdata[] = { + { + .bar = 0, +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + .ccp_vdata = &ccpv3_platform, +#endif + }, +}; + #ifdef CONFIG_ACPI static const struct acpi_device_id ccp_acpi_match[] = { - { "AMDI0C00", (kernel_ulong_t)&ccpv3 }, + { "AMDI0C00", (kernel_ulong_t)&dev_vdata[0] }, { }, }; MODULE_DEVICE_TABLE(acpi, ccp_acpi_match); @@ -214,7 +220,7 @@ MODULE_DEVICE_TABLE(acpi, ccp_acpi_match); #ifdef CONFIG_OF static const struct of_device_id ccp_of_match[] = { { .compatible = "amd,ccp-seattle-v1a", - .data = (const void *)&ccpv3_platform }, + .data = (const void *)&dev_vdata[0] }, { }, }; MODULE_DEVICE_TABLE(of, ccp_of_match); diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c new file mode 100644 index 0000000..63cc74e --- /dev/null +++ b/drivers/crypto/ccp/sp-dev.c @@ -0,0 +1,182 @@ +/* + * AMD Secure Processor driver + * + * Copyright (C) 2017 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + * Author: Gary R Hook + * Author: Brijesh Singh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ccp-dev.h" +#include "sp-dev.h" + +MODULE_AUTHOR("Tom Lendacky "); +MODULE_AUTHOR("Gary R Hook "); +MODULE_LICENSE("GPL"); +MODULE_VERSION("1.1.0"); +MODULE_DESCRIPTION("AMD Secure Processor driver"); + +/* List of SPs, SP count, read-write access lock, and access functions + * + * Lock structure: get sp_unit_lock for reading whenever we need to + * examine the SP list. + */ +static DEFINE_RWLOCK(sp_unit_lock); +static LIST_HEAD(sp_units); + +/* Ever-increasing value to produce unique unit numbers */ +static atomic_t sp_ordinal; + +static void sp_add_device(struct sp_device *sp) +{ + unsigned long flags; + + write_lock_irqsave(&sp_unit_lock, flags); + + list_add_tail(&sp->entry, &sp_units); + + write_unlock_irqrestore(&sp_unit_lock, flags); +} + +static void sp_del_device(struct sp_device *sp) +{ + unsigned long flags; + + write_lock_irqsave(&sp_unit_lock, flags); + + list_del(&sp->entry); + + write_unlock_irqrestore(&sp_unit_lock, flags); +} + +/** + * sp_alloc_struct - allocate and initialize the sp_device struct + * + * @dev: device struct of the SP + */ +struct sp_device *sp_alloc_struct(struct device *dev) +{ + struct sp_device *sp; + + sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL); + if (!sp) + return NULL; + + sp->dev = dev; + sp->ord = atomic_inc_return(&sp_ordinal); + snprintf(sp->name, SP_MAX_NAME_LEN, "sp-%u", sp->ord); + + return sp; +} + +int sp_init(struct sp_device *sp) +{ + sp_add_device(sp); + + if (sp->dev_vdata->ccp_vdata) + ccp_dev_init(sp); + + return 0; +} + +void sp_destroy(struct sp_device *sp) +{ + if (sp->dev_vdata->ccp_vdata) + ccp_dev_destroy(sp); + + sp_del_device(sp); +} + +#ifdef CONFIG_PM +int sp_suspend(struct sp_device *sp, pm_message_t state) +{ + int ret; + + if (sp->dev_vdata->ccp_vdata) { + ret = ccp_dev_suspend(sp, state); + if (ret) + return ret; + } + + return 0; +} + +int sp_resume(struct sp_device *sp) +{ + int ret; + + if (sp->dev_vdata->ccp_vdata) { + ret = ccp_dev_resume(sp); + if (ret) + return ret; + } + + return 0; +} +#endif + +static int __init sp_mod_init(void) +{ +#ifdef CONFIG_X86 + int ret; + + ret = ccp_pci_init(); + if (ret) + return ret; + + /* Don't leave the driver loaded if init failed */ + if (ccp_present() != 0) { + ccp_pci_exit(); + return -ENODEV; + } + + return 0; +#endif + +#ifdef CONFIG_ARM64 + int ret; + + ret = ccp_platform_init(); + if (ret) + return ret; + + /* Don't leave the driver loaded if init failed */ + if (ccp_present() != 0) { + ccp_platform_exit(); + return -ENODEV; + } + + return 0; +#endif + + return -ENODEV; +} + +static void __exit sp_mod_exit(void) +{ +#ifdef CONFIG_X86 + ccp_pci_exit(); +#endif + +#ifdef CONFIG_ARM64 + ccp_platform_exit(); +#endif +} + +module_init(sp_mod_init); +module_exit(sp_mod_exit); diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h new file mode 100644 index 0000000..189e57e --- /dev/null +++ b/drivers/crypto/ccp/sp-dev.h @@ -0,0 +1,120 @@ +/* + * AMD Secure Processor driver + * + * Copyright (C) 2017 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + * Author: Gary R Hook + * Author: Brijesh Singh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __SP_DEV_H__ +#define __SP_DEV_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SP_MAX_NAME_LEN 32 + +#define CACHE_NONE 0x00 +#define CACHE_WB_NO_ALLOC 0xb7 + +/* Structure to hold CCP device data */ +struct ccp_device; +struct ccp_vdata { + const unsigned int version; + const unsigned int dma_chan_attr; + void (*setup)(struct ccp_device *); + const struct ccp_actions *perform; + const unsigned int offset; +}; +/* Structure to hold SP device data */ +struct sp_dev_vdata { + const unsigned int bar; + + const struct ccp_vdata *ccp_vdata; + void *psp_vdata; +}; + +struct sp_device { + struct list_head entry; + + struct device *dev; + + struct sp_dev_vdata *dev_vdata; + unsigned int ord; + char name[SP_MAX_NAME_LEN]; + + /* Bus specific device information */ + void *dev_specific; + + /* I/O area used for device communication. */ + void __iomem *io_map; + + /* DMA caching attribute support */ + unsigned int axcache; + + bool irq_registered; + + int (*get_irq)(struct ccp_device *ccp); + void (*free_irq)(struct ccp_device *ccp); + + void *ccp_data; + void *psp_data; +}; + +int sp_pci_init(void); +void sp_pci_exit(void); + +int sp_platform_init(void); +void sp_platform_exit(void); + +struct sp_device *sp_alloc_struct(struct device *dev); + +int sp_init(struct sp_device *sp); +void sp_destroy(struct sp_device *sp); +struct sp_device *sp_get_master(void); + +int sp_suspend(struct sp_device *sp, pm_message_t state); +int sp_resume(struct sp_device *sp); + +#ifdef CONFIG_CRYPTO_DEV_SP_CCP + +int ccp_dev_init(struct sp_device *sp); +void ccp_dev_destroy(struct sp_device *sp); + +int ccp_dev_suspend(struct sp_device *sp, pm_message_t state); +int ccp_dev_resume(struct sp_device *sp); + +#else /* !CONFIG_CRYPTO_DEV_SP_CCP */ + +static inline int ccp_dev_init(struct sp_device *sp) +{ + return 0; +} +static inline void ccp_dev_destroy(struct sp_device *sp) { } + +static inline int ccp_dev_suspend(struct sp_device *sp, pm_message_t state) +{ + return 0; +} +static inline int ccp_dev_resume(struct sp_device *sp) +{ + return 0; +} +#endif /* CONFIG_CRYPTO_DEV_SP_CCP */ + +#endif diff --git a/include/linux/ccp.h b/include/linux/ccp.h index 3285c94..523a579 100644 --- a/include/linux/ccp.h +++ b/include/linux/ccp.h @@ -24,8 +24,7 @@ struct ccp_device; struct ccp_cmd; -#if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \ - defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE) +#if defined(CONFIG_CRYPTO_DEV_SP_CCP) /** * ccp_present - check if a CCP device is present @@ -71,7 +70,7 @@ unsigned int ccp_version(void); */ int ccp_enqueue_cmd(struct ccp_cmd *cmd); -#else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */ +#else /* CONFIG_CRYPTO_DEV_CCP_SP_DEV is not enabled */ static inline int ccp_present(void) { @@ -88,7 +87,7 @@ static inline int ccp_enqueue_cmd(struct ccp_cmd *cmd) return -ENODEV; } -#endif /* CONFIG_CRYPTO_DEV_CCP_DD */ +#endif /* CONFIG_CRYPTO_DEV_SP_CCP */ /***** AES engine *****/