Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752717AbdGXUEI (ORCPT ); Mon, 24 Jul 2017 16:04:08 -0400 Received: from mail-dm3nam03on0066.outbound.protection.outlook.com ([104.47.41.66]:3232 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751942AbdGXUD2 (ORCPT ); Mon, 24 Jul 2017 16:03:28 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: Thomas Gleixner , Borislav Petkov , Joerg Roedel , "Michael S . Tsirkin" , Paolo Bonzini , =?UTF-8?q?=5C=22Radim=20Kr=C4=8Dm=C3=A1=C5=99=5C=22?= , Tom Lendacky , Brijesh Singh , Herbert Xu , "David S . Miller" , Gary Hook , linux-crypto@vger.kernel.org Subject: [RFC Part2 PATCH v3 02/26] crypto: ccp: Add Platform Security Processor (PSP) device support Date: Mon, 24 Jul 2017 15:02:39 -0500 Message-Id: <20170724200303.12197-3-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170724200303.12197-1-brijesh.singh@amd.com> References: <20170724200303.12197-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM3PR12CA0049.namprd12.prod.outlook.com (10.161.151.17) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf7b59a0-8185-4919-6992-08d4d2cf0a08 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:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;3:IJcYITi9ETG44y30YgDhARk1fYP8N5rQp6eRldh4aC93mquuxrIVE8eRtchjJ8nwcpLoyYxQJn+fpLQRQlZzpIldxdlBJ4vnKfC9gza+mLVROb5xwu+XhmjUwfgGhx+dy7mQl+fhPBj09nuRFr21iMOHDDy4a2EQ16ttUMNfQuS0Su/vC4h0bORxuLNGcIB6wGV+clZsodp77L7fn04iZKXf5poDdCEJO9fNFHOUr91vnDt362HA8WtCW3All4YyWsEbDVURP2NZ28/9KxJGI3W/M+/pn6nAe6S21vE9DVDNnVSIUOj3qIecNZSh0DXHjMjiewosM3GMjY2hpsRUcFspD8IGAOyRco+iPptyBFi/RGIyvul5KFuVbetYEHTshpIUZ5OouOeE7tkM5FZKATwargW4dP7lE0116dQKMS1zB5s8D+juT8m0AIT1DghWuONfu5XV2Im/cz0jPBZprSrY317uJytQWGz94zMUKwgLuJ84hBNSVP/4AWEKycPwELqT2JV5ZZvddYNMXbrIciZDH/mdcbLckbQzPWHrCTQBhShqOOcFufOPNQoqFdopPkhu2oGI1aTh+59nkSSQWzaIv+dp0kgOKsTZ2TYjZouttcIXjYYxaIrrwBiAuADRxLtfd2MCJFEIbqcXleSLzYDaianzvuE9jdvVMn0bt17cA7y+WDFZpclEi3fjuBJNgWyxlBq5BUSgugQ4VgWzvu4JdPoYFghAMSuNAuzkfYth+Sa/USqRfM6aOOPJ/V3m8oo5REVzfPfSgbAMWIEW3w== X-MS-TrafficTypeDiagnostic: BY2PR12MB0145: X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;25:64IgZlzD+/Uc67SR3QkGRMd6oZ4kiAD6LDkeIUi1Tlby7n+3/AMN4ipH8rS2/30oURKzZT8T+7mtu3Zzpyv7SQLWV4ZIL+2+NiLLIzYD62ZzCpN5/WTzdt8IZdGbkaNklgqNZ9VBRWdaRH7t2aOfNuHhYLYEOMJn1fq2Q8eTPwt+N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OMhmaYW0Tw9rksK92PSLGH0RF0VLeP53MBDF5YVO8vmXwMpI4/z/GfVNaXqDVE2EAX60Ml/mXqh7BYcfOdfmFPguEPBA0BC0fn192Seb3LsMeT72LWdNPkyMbXa4yUi4E9YO8dRXN0Dump0GrH6gZGWZonKhfIRY1j9Nvs2ETaYfLWYMzchKXEhgyNg77EIQpHpW/1lFS8iV8iiHRiMWfSMjKe3lvF+9xbGZFplx/jxOdlGX8U6HFqyE48MgmLJ6fPVZSeTn5Pj453Azee7Dhi7EfBbxsZt7kDWMODg62cvgC1XInwutqK2ZmhaAr6g2pMHgCwn0e+nDwd7d2uzWCXV2TqzRgIw6hepfElx252ScVmI+kyJrxTcTSPzUI1r0zRK+UKnvczOiMxdDTwVRY= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:grmyd3TcYeJtMIj1FLYQXx6vMK9wNNe4xPr116S4UYI5ZPRSR66ILG5J26kq2/lu+2AaUAJCvqJhqxlinFhUtDd/cJoiuuylS+G4ms84bdEU4YFI5im89um0mJQ0acw3bVbcs30dqYiz163WjPDK5Zt9HsrMN3T3re+F+1RzyzkiczxwefP363p3RW9SSqU5e/clgbbyNSreO1KoYHiPfClhXW4ntRYhSIzQNQH9Nhi2WW6YFw6HGtlvuDp86Y3hOYa+wrMEzpF1yvPXKFHDqM4dNC/sG9R9UWqMRrR7Ff+Op43wrFczVFEMSJuF3olALks1qG8jFnMpIPRcxtV/WI7so3YjAhUapUZ68Nj4JD8MjwXRiFxZyCvFG7B+QbAOM19FS5Vbh6Ya479GDN657RPqMf5bsWhgB1sV+tDmSTs0Lq5tiYBcIQ0zbhaZNrdA51q6ARq7tpZTl/2u8tWrogfZN47Vbzn2dQB0IAF87D7cG3qjDtp7P8Jpnp69IULu X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(9452136761055)(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0145;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;4:nc/pa22LB+dWYbC5fT5RlMpMt3t3fe1uvXFWuw8WA1?= =?us-ascii?Q?wkS4d9tTflpjangtFd7ldpxebeRB9uvBvcvcqOvS3WVW9vC+4ATue39bwVKR?= =?us-ascii?Q?iMdbDfZKzuUWPk79LPhVXFMUjPL9E+mdixiPNAn8ohZ/W8U9tqM42lUe9w+F?= =?us-ascii?Q?5Ry6EVoKRsc/uY5tadmjlYGjx8LBnNNV1cOx010VhOJR8gUQ8yfnZTiM11lQ?= =?us-ascii?Q?Cxc8x3NfavxHroA2vp7JbqLazREgXXRCfkT9ya3R3gr9Bvs07iuR+M1rosgK?= =?us-ascii?Q?R5v4HIWoC4rvxqoUQOdFdF5sTwlmpRnBlH2VZOL9hn6QbSG7zApbi5hQVOSq?= =?us-ascii?Q?Yi/2IBFlLKVZPR7zmu42LDGBWqWtc3cYN3xfXRKvU13sFL8VBdC5dg9obQYi?= =?us-ascii?Q?lf91YldRGVRypV5G2Po5qYuhpqSwOZHUqbXzeiQD48gcJNIqTOf8YdVfqmi1?= =?us-ascii?Q?KBCV7ahiXohnLeGwr1svIQXUQxERvVmpRoXpj1KSRIzAh9Olid7JbgzRH8Vf?= =?us-ascii?Q?jvRj0J7Qm+AvPOV7zFBQg/pxhZBFzbe5/qygZewLq4E4RZ+CgjVfHlnOD4al?= =?us-ascii?Q?fHwEuheTr5KEwXO+43L70i4EqKqW2S+40ssLUY/czR7MD0+DmIiNzZ+NYjfz?= =?us-ascii?Q?maiD2AHBuZSiFFURMjOG6A8a3lm3iU80hbaf6Nm4ytED/Ziv9dbaMbk6p3Q6?= =?us-ascii?Q?DFxaLYHN3QaDkCZ3mqRTichxxcTDCoWce1GYISPsD/xl9TStSGcva+E0O2yP?= =?us-ascii?Q?50QXlKYDC+2lESSpczpJ3NzRNrW8HY7qShSkVFQm/c7guYVF5zmRvihMK+T/?= =?us-ascii?Q?QHwvPFb/o0BwIKw5xbA/RuUHJUTojr/LO4SNJF3M0plWlng8FddUH2F8JJPo?= =?us-ascii?Q?0hJeRC5BDVtoRygxTcNoKfOcNJKgCKjrwotQ8IvMurKHEFY5hy8h8I/Ca587?= =?us-ascii?Q?zZd15lOzGACOPP5IqiqrJx6UV5awfK7NYNyPJ4co9hBV8NQGXe/OqLL9Gsh6?= =?us-ascii?Q?vZTL0z9Le3cpnip1LLpH3OYeVoGo/4Ew+sehuB0Z0Oi8xHmUVlivG+gBrBMV?= =?us-ascii?Q?6ZLwwgMbMqYkDrRC7Fxt5oyqe9QGDoXGwlNJrkFazr/sMEqb4izqbk5Ae9z1?= =?us-ascii?Q?E6lqRNDcf4X2CBxE6JXXbzKXqnKuo29vGlpg1Jv7v4Wp0akBTXTdPzQ6gdc7?= =?us-ascii?Q?tayKZWNYyt+AWKeCgLNCB9f2dXkJEIvwpFwQeDy5jjxqtM2mo3FHs3DKF7gU?= =?us-ascii?Q?+bKmKnCp0tZsVbYRNgO6UL6naa+LR8qwrDJPZQ?= X-Forefront-PRVS: 0378F1E47A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39450400003)(39410400002)(39400400002)(39850400002)(39860400002)(39840400002)(189002)(199003)(7350300001)(68736007)(53416004)(105586002)(54906002)(97736004)(50466002)(6486002)(48376002)(2906002)(106356001)(33646002)(6116002)(1076002)(53936002)(3846002)(189998001)(15650500001)(101416001)(6666003)(2950100002)(478600001)(50986999)(76176999)(81156014)(50226002)(38730400002)(47776003)(5003940100001)(7416002)(86362001)(25786009)(4326008)(36756003)(42186005)(8676002)(81166006)(110136004)(575784001)(5660300001)(66066001)(7736002)(305945005)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0145;H:ubuntu-010236106000.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;23:7c29iXQaF3om1VQkw/WHmPQpwpXIUaLQENYCicQe0?= =?us-ascii?Q?e7uXDxO5I5ixQxVXM9E3raaQRV61vrReH8+MhlHN4pKD2hDPibv+DB4M9nu7?= =?us-ascii?Q?lPeXO3dlu/8XkDxrD0+/gFBkXXQPdQ34LghMKsDo4KXRSNI7uYpJOWSwN9gj?= =?us-ascii?Q?QNlakDP9BzXD4/HDRqqAwk1zaDGLINqd7Kmia86FUOC/ZDDtXjbH/XfGCCg8?= =?us-ascii?Q?R8KfXH4TBjLBopvgZYfw5/QTbALMd4hS3aLtoaneb/3aQ+iOW53WFt6FvffD?= =?us-ascii?Q?+NKNB2NtrS+w5sbCHY+cKv04WDjJcSXnUeBbhok3uHl89hLn0RKBdZAj0gvY?= =?us-ascii?Q?zIQ9UB38lmNjGfy53ckOqFUzSGYu7LyMiBhAcbjkrB9FU+TcCPJ7gPEONgf7?= =?us-ascii?Q?bkmrAM8ysHL1DF9elB4uzAKeb1gULHVlHyiCrbUOJrJlJgEAjqXlHS2U8wX5?= =?us-ascii?Q?g3b2lIbXRR0Hdpx6IMFjCRStJf94ai+bOIig3Fb3+dNt/rJwlx4m0Gjv/+su?= =?us-ascii?Q?OfCiLHx0cgGk7LHZ/1F9IJrXqPRueqdc4SfdGJKAUvDPcJEgRrNfNqJCWURA?= =?us-ascii?Q?uKRd2Tj/ww0Qp8l7LUDgQhzXQ4MVONQ9Y6CnWL0PmQftxZfB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XOeqXIjtWDdhL0zNLMfmbFy0FzYmsrS5IMwedCACeHLDLZ/5Xl8IkOw2TPe0pv8TOfaCiR3fzLEKefagEY+Iy4PyuFEx4JEyuCbox9uiK8iADhN7cgsEy65qdffkdu80R887aGgJq7RxBKdSAd1vny7X9m2AlUQ/yHGLsClULwP5RJF1SHB6eZsXuHW6czmnCh6w/VNhj0RrR2kaA/+6iWu7F4DSWUXxphFUOe5V81t3r2FwP/3Ff4tmHjFAsnP/qefPq28GVhnoiwAK6DOrfAtYRrR2yu+9M93r54IId8EyFOaeMHeq9So57LHPjhHPsWTI7etJZwryUaU3tevZF516himDLnRlrj6X6ZLQ7aQkbFG4PHokZXfzY2NmJcMgf/9h3BKIbZ94SYH6zeM/1WU7AGD8QkIt3XIiRKR+kHzZZ1yxTBCDUKHW2marnND82PqKQGXL9V+OR4TVlIAKu4QNgecckhGaiJbsZNKqNKIBYrCZCPolSlbSrrHRvj6f0H6rt2DOno8FYBz21qNC1iMX2dGnfhJUu3fIiWeB0TplA= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:MXC9+LDeVUOXDFzIP/XeoIAiqXea2TXbLURlSPIWTQeUyrL3zjt36EhFnq0jh15g2hWp1Dd3i9ePiEM36+8roqAu3ryVqfg6MBlrX3unZOfstaqXhya8Cvo6b3y0QzHkIpKJri02Du+UPdPMGDGsmIzjvBerpIArfWXbv3ekA5ZDX9gGq/HWSMEzFOYKqKvPGncFwr8C7Q3xo3TyEYuhnYVgGUNUe7RXj9bJhxMgJMWKZPLh8h20GV5WBNTzLQN9 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 20:03:21.6187 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 14908 Lines: 613 Platform Security Processor (PSP) is part of AMD Secure Processor (AMD-SP), PSP is a dedicated processor that provides the support for key management commands in a Secure Encrypted Virtualiztion (SEV) mode, along with software-based Tursted Executation Environment (TEE) to enable the third-party tursted applications. Cc: Herbert Xu Cc: David S. Miller Cc: Gary Hook Cc: linux-crypto@vger.kernel.org Signed-off-by: Brijesh Singh --- drivers/crypto/ccp/Kconfig | 9 ++ drivers/crypto/ccp/Makefile | 1 + drivers/crypto/ccp/psp-dev.c | 226 +++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/psp-dev.h | 82 ++++++++++++++++ drivers/crypto/ccp/sp-dev.c | 43 ++++++++ drivers/crypto/ccp/sp-dev.h | 41 +++++++- drivers/crypto/ccp/sp-pci.c | 46 +++++++++ 7 files changed, 447 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ccp/psp-dev.c create mode 100644 drivers/crypto/ccp/psp-dev.h diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kconfig index 15b63fd..41c0ff5 100644 --- a/drivers/crypto/ccp/Kconfig +++ b/drivers/crypto/ccp/Kconfig @@ -31,3 +31,12 @@ config CRYPTO_DEV_CCP_CRYPTO Support for using the cryptographic API with the AMD Cryptographic Coprocessor. This module supports offload of SHA and AES algorithms. If you choose 'M' here, this module will be called ccp_crypto. + +config CRYPTO_DEV_SP_PSP + bool "Platform Security Processor device" + default y + depends on CRYPTO_DEV_CCP_DD + help + Provide the support for AMD Platform Security Processor (PSP) device + which can be used for communicating with Secure Encryption Virtualization + (SEV) firmware. diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile index 5f2adc5..8aae4ff 100644 --- a/drivers/crypto/ccp/Makefile +++ b/drivers/crypto/ccp/Makefile @@ -7,6 +7,7 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \ ccp-dmaengine.o \ ccp-debugfs.o ccp-$(CONFIG_PCI) += sp-pci.o +ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o ccp-crypto-objs := ccp-crypto-main.o \ diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c new file mode 100644 index 0000000..bb0ea9a --- /dev/null +++ b/drivers/crypto/ccp/psp-dev.c @@ -0,0 +1,226 @@ +/* + * AMD Platform Security Processor (PSP) interface + * + * Copyright (C) 2016 Advanced Micro Devices, Inc. + * + * 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 +#include +#include + +#include "sp-dev.h" +#include "psp-dev.h" + +static LIST_HEAD(psp_devs); +static DEFINE_SPINLOCK(psp_devs_lock); + +const struct psp_vdata psp_entry = { + .offset = 0x10500, +}; + +void psp_add_device(struct psp_device *psp) +{ + unsigned long flags; + + spin_lock_irqsave(&psp_devs_lock, flags); + + list_add_tail(&psp->entry, &psp_devs); + + spin_unlock_irqrestore(&psp_devs_lock, flags); +} + +void psp_del_device(struct psp_device *psp) +{ + unsigned long flags; + + spin_lock_irqsave(&psp_devs_lock, flags); + + list_del(&psp->entry); + spin_unlock_irqrestore(&psp_devs_lock, flags); +} + +static struct psp_device *psp_alloc_struct(struct sp_device *sp) +{ + struct device *dev = sp->dev; + struct psp_device *psp; + + psp = devm_kzalloc(dev, sizeof(*psp), GFP_KERNEL); + if (!psp) + return NULL; + + psp->dev = dev; + psp->sp = sp; + + snprintf(psp->name, sizeof(psp->name), "psp-%u", sp->ord); + + return psp; +} + +irqreturn_t psp_irq_handler(int irq, void *data) +{ + unsigned int status; + irqreturn_t ret = IRQ_HANDLED; + struct psp_device *psp = data; + + /* read the interrupt status */ + status = ioread32(psp->io_regs + PSP_P2CMSG_INTSTS); + + /* invoke subdevice interrupt handlers */ + if (status) { + if (psp->sev_irq_handler) + ret = psp->sev_irq_handler(irq, psp->sev_irq_data); + if (psp->tee_irq_handler) + ret = psp->tee_irq_handler(irq, psp->tee_irq_data); + } + + /* clear the interrupt status */ + iowrite32(status, psp->io_regs + PSP_P2CMSG_INTSTS); + + return ret; +} + +static int psp_init(struct psp_device *psp) +{ + psp_add_device(psp); + + return 0; +} + +int psp_dev_init(struct sp_device *sp) +{ + struct device *dev = sp->dev; + struct psp_device *psp; + int ret; + + ret = -ENOMEM; + psp = psp_alloc_struct(sp); + if (!psp) + goto e_err; + sp->psp_data = psp; + + psp->vdata = (struct psp_vdata *)sp->dev_vdata->psp_vdata; + if (!psp->vdata) { + ret = -ENODEV; + dev_err(dev, "missing driver data\n"); + goto e_err; + } + + psp->io_regs = sp->io_map + psp->vdata->offset; + + /* Disable and clear interrupts until ready */ + iowrite32(0, psp->io_regs + PSP_P2CMSG_INTEN); + iowrite32(0xffffffff, psp->io_regs + PSP_P2CMSG_INTSTS); + + dev_dbg(dev, "requesting an IRQ ...\n"); + /* Request an irq */ + ret = sp_request_psp_irq(psp->sp, psp_irq_handler, psp->name, psp); + if (ret) { + dev_err(dev, "psp: unable to allocate an IRQ\n"); + goto e_err; + } + + sp_set_psp_master(sp); + + dev_dbg(dev, "initializing psp\n"); + ret = psp_init(psp); + if (ret) { + dev_err(dev, "failed to init psp\n"); + goto e_irq; + } + + /* Enable interrupt */ + dev_dbg(dev, "Enabling interrupts ...\n"); + iowrite32(7, psp->io_regs + PSP_P2CMSG_INTEN); + + dev_notice(dev, "psp enabled\n"); + + return 0; + +e_irq: + sp_free_psp_irq(psp->sp, psp); +e_err: + sp->psp_data = NULL; + + dev_notice(dev, "psp initialization failed\n"); + + return ret; +} + +void psp_dev_destroy(struct sp_device *sp) +{ + struct psp_device *psp = sp->psp_data; + + sp_free_psp_irq(sp, psp); + + psp_del_device(psp); +} + +int psp_dev_resume(struct sp_device *sp) +{ + return 0; +} + +int psp_dev_suspend(struct sp_device *sp, pm_message_t state) +{ + return 0; +} + +int psp_request_tee_irq(struct psp_device *psp, irq_handler_t handler, + void *data) +{ + psp->tee_irq_data = data; + psp->tee_irq_handler = handler; + + return 0; +} + +int psp_free_tee_irq(struct psp_device *psp, void *data) +{ + if (psp->tee_irq_handler) { + psp->tee_irq_data = NULL; + psp->tee_irq_handler = NULL; + } + + return 0; +} + +int psp_request_sev_irq(struct psp_device *psp, irq_handler_t handler, + void *data) +{ + psp->sev_irq_data = data; + psp->sev_irq_handler = handler; + + return 0; +} + +int psp_free_sev_irq(struct psp_device *psp, void *data) +{ + if (psp->sev_irq_handler) { + psp->sev_irq_data = NULL; + psp->sev_irq_handler = NULL; + } + + return 0; +} + +struct psp_device *psp_get_master_device(void) +{ + struct sp_device *sp = sp_get_psp_master_device(); + + return sp ? sp->psp_data : NULL; +} diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h new file mode 100644 index 0000000..6e167b8 --- /dev/null +++ b/drivers/crypto/ccp/psp-dev.h @@ -0,0 +1,82 @@ +/* + * AMD Platform Security Processor (PSP) interface driver + * + * Copyright (C) 2017 Advanced Micro Devices, Inc. + * + * 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 __PSP_DEV_H__ +#define __PSP_DEV_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sp-dev.h" + +#define PSP_P2CMSG_INTEN 0x0110 +#define PSP_P2CMSG_INTSTS 0x0114 + +#define PSP_C2PMSG_ATTR_0 0x0118 +#define PSP_C2PMSG_ATTR_1 0x011c +#define PSP_C2PMSG_ATTR_2 0x0120 +#define PSP_C2PMSG_ATTR_3 0x0124 +#define PSP_P2CMSG_ATTR_0 0x0128 + +#define PSP_CMDRESP_CMD_SHIFT 16 +#define PSP_CMDRESP_IOC BIT(0) +#define PSP_CMDRESP_RESP BIT(31) +#define PSP_CMDRESP_ERR_MASK 0xffff + +#define MAX_PSP_NAME_LEN 16 + +struct psp_device { + struct list_head entry; + + struct psp_vdata *vdata; + char name[MAX_PSP_NAME_LEN]; + + struct device *dev; + struct sp_device *sp; + + void __iomem *io_regs; + + irq_handler_t sev_irq_handler; + void *sev_irq_data; + irq_handler_t tee_irq_handler; + void *tee_irq_data; + + void *sev_data; + void *tee_data; +}; + +void psp_add_device(struct psp_device *psp); +void psp_del_device(struct psp_device *psp); + +int psp_request_sev_irq(struct psp_device *psp, irq_handler_t handler, + void *data); +int psp_free_sev_irq(struct psp_device *psp, void *data); + +int psp_request_tee_irq(struct psp_device *psp, irq_handler_t handler, + void *data); +int psp_free_tee_irq(struct psp_device *psp, void *data); + +struct psp_device *psp_get_master_device(void); + +extern const struct psp_vdata psp_entry; + +#endif /* __PSP_DEV_H */ diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c index a017233..d263ba4 100644 --- a/drivers/crypto/ccp/sp-dev.c +++ b/drivers/crypto/ccp/sp-dev.c @@ -198,6 +198,8 @@ int sp_init(struct sp_device *sp) if (sp->dev_vdata->ccp_vdata) ccp_dev_init(sp); + if (sp->dev_vdata->psp_vdata) + psp_dev_init(sp); return 0; } @@ -206,6 +208,9 @@ void sp_destroy(struct sp_device *sp) if (sp->dev_vdata->ccp_vdata) ccp_dev_destroy(sp); + if (sp->dev_vdata->psp_vdata) + psp_dev_destroy(sp); + sp_del_device(sp); } @@ -219,6 +224,12 @@ int sp_suspend(struct sp_device *sp, pm_message_t state) return ret; } + if (sp->dev_vdata->psp_vdata) { + ret = psp_dev_suspend(sp, state); + if (ret) + return ret; + } + return 0; } @@ -232,9 +243,41 @@ int sp_resume(struct sp_device *sp) return ret; } + if (sp->dev_vdata->psp_vdata) { + ret = psp_dev_resume(sp); + if (ret) + return ret; + } return 0; } +struct sp_device *sp_get_psp_master_device(void) +{ + unsigned long flags; + struct sp_device *i, *ret = NULL; + + write_lock_irqsave(&sp_unit_lock, flags); + if (list_empty(&sp_units)) + goto unlock; + + list_for_each_entry(i, &sp_units, entry) { + if (i->psp_data) + break; + } + + if (i->get_psp_master_device) + ret = i->get_psp_master_device(); +unlock: + write_unlock_irqrestore(&sp_unit_lock, flags); + return ret; +} + +void sp_set_psp_master(struct sp_device *sp) +{ + if (sp->set_psp_master_device) + sp->set_psp_master_device(sp); +} + static int __init sp_mod_init(void) { #ifdef CONFIG_X86 diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 3520da4..f98a3f9 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -41,12 +41,19 @@ struct ccp_vdata { const struct ccp_actions *perform; const unsigned int offset; }; + +struct psp_vdata { + const unsigned int version; + const struct psp_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; + const struct psp_vdata *psp_vdata; }; struct sp_device { @@ -67,6 +74,10 @@ struct sp_device { /* DMA caching attribute support */ unsigned int axcache; + /* get and set master device */ + struct sp_device*(*get_psp_master_device)(void); + void(*set_psp_master_device)(struct sp_device *); + bool irq_registered; bool use_tasklet; @@ -102,6 +113,8 @@ void sp_free_ccp_irq(struct sp_device *sp, void *data); int sp_request_psp_irq(struct sp_device *sp, irq_handler_t handler, const char *name, void *data); void sp_free_psp_irq(struct sp_device *sp, void *data); +void sp_set_psp_master(struct sp_device *sp); +struct sp_device *sp_get_psp_master_device(void); #ifdef CONFIG_CRYPTO_DEV_SP_CCP @@ -129,4 +142,30 @@ static inline int ccp_dev_resume(struct sp_device *sp) } #endif /* CONFIG_CRYPTO_DEV_SP_CCP */ +#ifdef CONFIG_CRYPTO_DEV_SP_PSP + +int psp_dev_init(struct sp_device *sp); +void psp_dev_destroy(struct sp_device *sp); + +int psp_dev_suspend(struct sp_device *sp, pm_message_t state); +int psp_dev_resume(struct sp_device *sp); +#else /* !CONFIG_CRYPTO_DEV_SP_PSP */ + +static inline int psp_dev_init(struct sp_device *sp) +{ + return 0; +} +static inline void psp_dev_destroy(struct sp_device *sp) { } + +static inline int psp_dev_suspend(struct sp_device *sp, pm_message_t state) +{ + return 0; +} +static inline int psp_dev_resume(struct sp_device *sp) +{ + return 0; +} + +#endif /* CONFIG_CRYPTO_DEV_SP_PSP */ + #endif diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 9859aa6..e58b3ad 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -25,6 +25,7 @@ #include #include "ccp-dev.h" +#include "psp-dev.h" #define MSIX_VECTORS 2 @@ -32,6 +33,7 @@ struct sp_pci { int msix_count; struct msix_entry msix_entry[MSIX_VECTORS]; }; +static struct sp_device *sp_dev_master; static int sp_get_msix_irqs(struct sp_device *sp) { @@ -108,6 +110,45 @@ static void sp_free_irqs(struct sp_device *sp) sp->psp_irq = 0; } +static bool sp_pci_is_master(struct sp_device *sp) +{ + struct device *dev_cur, *dev_new; + struct pci_dev *pdev_cur, *pdev_new; + + dev_new = sp->dev; + dev_cur = sp_dev_master->dev; + + pdev_new = to_pci_dev(dev_new); + pdev_cur = to_pci_dev(dev_cur); + + if (pdev_new->bus->number < pdev_cur->bus->number) + return true; + + if (PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn)) + return true; + + if (PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn)) + return true; + + return false; +} + +static void psp_set_master(struct sp_device *sp) +{ + if (!sp_dev_master) { + sp_dev_master = sp; + return; + } + + if (sp_pci_is_master(sp)) + sp_dev_master = sp; +} + +static struct sp_device *psp_get_master(void) +{ + return sp_dev_master; +} + static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct sp_device *sp; @@ -166,6 +207,8 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto e_err; pci_set_master(pdev); + sp->set_psp_master_device = psp_set_master; + sp->get_psp_master_device = psp_get_master; ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48)); if (ret) { @@ -237,6 +280,9 @@ static const struct sp_dev_vdata dev_vdata[] = { #ifdef CONFIG_CRYPTO_DEV_SP_CCP .ccp_vdata = &ccpv5a, #endif +#ifdef CONFIG_CRYPTO_DEV_PSP + .psp_vdata = &psp_entry +#endif }, { .bar = 2, -- 2.9.4