From patchwork Thu Mar 2 19:42:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157799 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD148C6FA8E for ; Thu, 2 Mar 2023 19:43:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbjCBTnL (ORCPT ); Thu, 2 Mar 2023 14:43:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjCBTnK (ORCPT ); Thu, 2 Mar 2023 14:43:10 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2041.outbound.protection.outlook.com [40.107.93.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9082FCE2; Thu, 2 Mar 2023 11:43:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JrxhcDWZXrEDIvZ4/ZMZvE2xYtdl0xxCHrEQdZxYHNWNLaG5bbwkLQCzkzLVOpvgWQINZ77HHXFqKkpZqVJ3EvFRlh7eF/WsiZRMbpGf9alk6VpvryprgwDZaMrjV1+PI7X/KhT/0E3Vm4EcUWqiqAdjzWM4BalH0abwNjGS2N5a8tTBq6mg8fwF1TG7CORQl0Zkp6itth29MOB3rHDBRzR946ZN2rU10mFYaX4JFbAHkcd8PtjuU529HPAyv+XU+enCmj33n9+9DgAI3mPlUQi0vTajAmEpxkyaltfj1Ln3sJ92X/CXfSY5PqzQ7JGZ4G0zTMmvdP0H+ea8TfK+wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FJxFANk3/KMRohDtDcgqgAGdf4Q8l9vNmxOY4NSlCKQ=; b=KqVYgIIg3MuKgP3VMMH3rhUzUPIaybW1k/PWFl+zvwWTV1pxEMz8bgwZREMmRgm/tp45L4KAGwk/9utSd6IWPA9Go04h6Fh2YZ/vnGeVyrZcNpQH9/kOulWMMcrvhCB0Zz+meywqzfrMSkAG+Q3ZTR5i32WNtO4DsnbxRlCRglnFqnukLP1wDbk6GdXt021FJ0DWSrUb4jXLTZ0PxlqcHT/vm5V4x6XmxdeMnu5l6/PGzeFPdaOK243/YOO1u2vU89cGUKoMHoGI7cqEglcxd94WDdZLKf7PYxz2gDZgRGLDXTMDOI2askoK3REbQqKuf2Q4HCHeuF066Mvy7zct1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FJxFANk3/KMRohDtDcgqgAGdf4Q8l9vNmxOY4NSlCKQ=; b=UHozP6ij40kgjMS9jUDwSIWkSwFlm1K5Yqx9aQvZD7I4I96XS2dFXA5AAFchJaed0I+aTiAVzyb/DTPvGitcz1yatJCGUVq8KtpuXIe0GSwmrACd1OTX83wlf3mTFxwxQculUzhX/1oltWar9O7XBeOnmrI67oOKmiy403kHMGI= Received: from BN9PR03CA0915.namprd03.prod.outlook.com (2603:10b6:408:107::20) by MN2PR12MB4405.namprd12.prod.outlook.com (2603:10b6:208:26d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18; Thu, 2 Mar 2023 19:43:05 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::23) by BN9PR03CA0915.outlook.office365.com (2603:10b6:408:107::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.21 via Frontend Transport; Thu, 2 Mar 2023 19:43:05 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:42:55 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" CC: Mario Limonciello , "David S. Miller" , , Subject: [PATCH v2 1/9] crypto: ccp: Drop TEE support for IRQ handler Date: Thu, 2 Mar 2023 13:42:24 -0600 Message-ID: <20230302194235.1724-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|MN2PR12MB4405:EE_ X-MS-Office365-Filtering-Correlation-Id: 883f331b-c8d9-4ecd-3fa2-08db1b565773 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lItEFqebjottIZCMaPoD384xSYlkZP0TlrHxfcLLL56KhrIbok3utBJXobWlen+V9i8hUN0UJ0xzKHmQL9EKqb9NcPVzjo1Rm9ynqdgamPIfrZs2AfvVotO1BCmogzHCc3Su9jMbyLiODDMr75COI/ofbHUEsA41RLoHiHhICTyKUbP1PBxx5IUtYi9A6l3Jq7BuAy9Qc4jQfVWmzP8pqR76t0Y1mW9Njjh85TVKiSIPufiKJeBGous/9Px2hhrM6+wNch9a4BbaXcquE1VmzJgFGzoLIw5j5lPjW357aSzE9T/xjIwwgmle4h3vK/+j7yPPRDwQUHQ52avNvuAmZFQmnFTJLZF4EfREUk6ABwm75Z9MthPB+p6XUgT8+oxm0Dy24KBNPUSqVDwmxihbr6JOXeZcPAf36PqEax6LHdMFAhYXWYvxTjHWhpfNo+jrGILWReWmGZD2YQOnqUMXyhviPVdWJOhOM14b3/U/vrLkPaey76Lsvw5O2vvz3oE1FDro8VLdtw8SwdYjKZ9ChhOeNJqVxNL6ISWHWOHAcy4PZ3hVKIU61pPtSw6i5fz9m5ic1eovFCtL3/jT/b0pDzcVIsuzi1UmN1A47MshFhYD2xJAWn59MiImNRnbtcEu6K5du0+zgdkdyn+8FiWgvKhtz3IKvdTEds5cuVwyg7oHNlAui+uemww0RvWG+5YWh+Fec4yBmiWcTLDYA35ujAiBUV1M3bRjRj2lKemC4//3jKsfdESLikhH2IwsUeRTrM/vL14iE/Usv95iIaW/mA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199018)(36840700001)(46966006)(40470700004)(36756003)(40460700003)(40480700001)(6666004)(336012)(43170500006)(2616005)(1076003)(16526019)(26005)(70586007)(316002)(4326008)(41300700001)(186003)(54906003)(6636002)(110136005)(7696005)(2906002)(8676002)(44832011)(70206006)(81166007)(82740400003)(478600001)(8936002)(5660300002)(82310400005)(356005)(86362001)(83380400001)(47076005)(36860700001)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:05.0896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 883f331b-c8d9-4ecd-3fa2-08db1b565773 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4405 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The only PSP mailbox that currently supports interrupt on completion is the SEV mailbox. Drop the dead code for the TEE subdriver to potentially call it. Signed-off-by: Mario Limonciello Acked-by: Rijo Thomas --- drivers/crypto/ccp/psp-dev.c | 15 --------------- drivers/crypto/ccp/psp-dev.h | 7 ------- 2 files changed, 22 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index c9c741ac8442..cd8d1974726a 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -46,9 +46,6 @@ static irqreturn_t psp_irq_handler(int irq, void *data) if (status) { if (psp->sev_irq_handler) psp->sev_irq_handler(irq, psp->sev_irq_data, status); - - if (psp->tee_irq_handler) - psp->tee_irq_handler(irq, psp->tee_irq_data, status); } /* Clear the interrupt status by writing the same value we read. */ @@ -219,18 +216,6 @@ void psp_clear_sev_irq_handler(struct psp_device *psp) psp_set_sev_irq_handler(psp, NULL, NULL); } -void psp_set_tee_irq_handler(struct psp_device *psp, psp_irq_handler_t handler, - void *data) -{ - psp->tee_irq_data = data; - psp->tee_irq_handler = handler; -} - -void psp_clear_tee_irq_handler(struct psp_device *psp) -{ - psp_set_tee_irq_handler(psp, NULL, NULL); -} - struct psp_device *psp_get_master_device(void) { struct sp_device *sp = sp_get_psp_master_device(); diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index d528eb04c3ef..06e1f317216d 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -40,9 +40,6 @@ struct psp_device { psp_irq_handler_t sev_irq_handler; void *sev_irq_data; - psp_irq_handler_t tee_irq_handler; - void *tee_irq_data; - void *sev_data; void *tee_data; @@ -53,10 +50,6 @@ void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler, void *data); void psp_clear_sev_irq_handler(struct psp_device *psp); -void psp_set_tee_irq_handler(struct psp_device *psp, psp_irq_handler_t handler, - void *data); -void psp_clear_tee_irq_handler(struct psp_device *psp); - struct psp_device *psp_get_master_device(void); #define PSP_CAPABILITY_SEV BIT(0) From patchwork Thu Mar 2 19:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157800 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84962C6FA8E for ; Thu, 2 Mar 2023 19:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbjCBTnh (ORCPT ); Thu, 2 Mar 2023 14:43:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjCBTnb (ORCPT ); Thu, 2 Mar 2023 14:43:31 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060.outbound.protection.outlook.com [40.107.244.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB63C55059; Thu, 2 Mar 2023 11:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eCi371iPk7jumAWMi3Of6ZVdSdh9owKv6v8GAQGMC7fQZc/WPMu9pHgjKZ/XrHfbG3NuCtc1CHUy1N8wloDOxMoC+7V7X3BF1TjcAmjGZN6Yn23KQUv22Rg9ELz916BOIy6x4qkIhRuMET7IFfgpiN0gFFIfjFCuTRS0VU45TrE9tLLJTxWCHSLp47xnxhilmA+Des9V7oFfkx3ni5eW6dtyr+bDpcY/Y3maas3ToldpFDbfKT3co0KS2vk4ReKHVcsVLp+JiqYvL7WMj+LW3sgHxvht8rBDKoSgkbhG+p/QJE/6mLc2u9jkIZUPCeS1pXjcWzRECbIM3RIASKngUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XExh6Qbc0HUbp4dAX6paQ+nw4APW447RRFeKajIQSIk=; b=QY6w/VsrZ8SuwOvVcOwgKtQqZCWRm/W22HPe53Zx9g+KbxY1zll2SFvlrxLpvbG9Rm4UrGHP5vujl0YqhDnzq76+WOTh5IeFhWMfXZoKBSdJyiZQ1cHa4rWI0MqIk0VjXC++hdEnjsmz+hpKwftHH0ax+xVyfSuJx8EGDEmo3Wzh9oy5OA/yF1rM8X1LNx0eqxbwvFkcs5MbMqYLay9an30k17WPwD1YJkueCio2lktxSysCX2YYibJnQBY03v234GvmSIqusianuJLkevjq13FrTnp3QqNCMXDCxofTSK5ISE/Fedf7+PKSmJXjbXJgq/atFdWptMX7RTizpQGXkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XExh6Qbc0HUbp4dAX6paQ+nw4APW447RRFeKajIQSIk=; b=gmqqyRTFe3lH4pZ1wkhM8yHwXHrnw935KAZ83AORDSxaAVyf/PSS/zSSQbb9BWQcZZQyCV8zRLcWCz94+CmpLn7+v34wgpm0tvBIBKb7vjSGtdVOXaNdFuxZf9dJgqi2rv/cSXvnodrVanptbPmrwmXLuxLr29qJ2NWiiW1RTKI= Received: from BN9PR03CA0913.namprd03.prod.outlook.com (2603:10b6:408:107::18) by SA1PR12MB5613.namprd12.prod.outlook.com (2603:10b6:806:23e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.25; Thu, 2 Mar 2023 19:43:16 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::ad) by BN9PR03CA0913.outlook.office365.com (2603:10b6:408:107::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18 via Frontend Transport; Thu, 2 Mar 2023 19:43:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.21 via Frontend Transport; Thu, 2 Mar 2023 19:43:16 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:04 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Sean Christopherson , "Paolo Bonzini" , Brijesh Singh , "Tom Lendacky" , John Allen , "Jarkko Nikula" , Andy Shevchenko , Mika Westerberg CC: Mario Limonciello , Sumit Garg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" , "David S. Miller" , Jens Wiklander , , , , , Subject: [PATCH v2 2/9] crypto: ccp: Add a header for multiple drivers to use `__psp_pa` Date: Thu, 2 Mar 2023 13:42:25 -0600 Message-ID: <20230302194235.1724-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|SA1PR12MB5613:EE_ X-MS-Office365-Filtering-Correlation-Id: 71897875-8820-43ce-6cb3-08db1b565e38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5q6j/cCEzSRShinju9YH8pMiIDVzQeKoST+NTDV1fOmqrwiEanSFgor9jXbZVtBkdxCDNwzrsSsNT5Z8AZakDQ5iEAWx8YvVFaqTJAUWbvZEbtUatOAYMd80+/UyyPNZHgWbFhwXFw7BZSpuAgdpAHNiJqNrftcpzMH3+6K4eHDB0vwMO7CRAD32n7nWLOYm01+zKGR/ISeU8fZeW+ftgzKxh76e17zy/2xcIPhFZ9D0raTLQtBbFwJijUDHnhZE61vzX9YU/+8fGNXk1erGIpLgJCkir59GVAcOYjV00mdBxGaDIwcd1mQ0LkTKrjmiEkcu/h5UL0f/VNiGIUET2W/xHwAumUO/NOT4cedC9Alj2FYtfOh/qDspngPjk/TwIxOrLqZKpswIURz+o25jMSfKCSxzkDIezw7tRQujXXKLMH/uRoN/KDoxNKIh2pln4HHN0QrJN3ztekQQq+a6ScCB6pzt0ryCYex5IORLNFsFEKsQlyiVedayLa8C/rt1NQmw1mIflAVxsr32S+jJUSoPaYZZ8YR77kEUFFGn2jbzW69S2RWj8d07WzSBVs7pOMifz+sKxfk4UdJ9sjohpCtnYIvdz6ymbAwKJINFidaSXa/5TyUUHM0xlaBs+FIc17B78aTQVUgk6PdsDCIRweEmhVOlTfeDWOE16Qqx3yvVG1lTq7qCDJUWwyjRGktgiLzLoOBj/5Vq+ABSgvbuEfwV/E6rPmRLtftVG5FW3wtpqqnpH7WLar9pQlkuwXVJ2kK+jpOdqZWTR2mQ5AK/Pw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199018)(40470700004)(36840700001)(46966006)(16526019)(36860700001)(40460700003)(186003)(40480700001)(81166007)(82740400003)(2906002)(83380400001)(921005)(356005)(44832011)(41300700001)(8936002)(70586007)(336012)(4326008)(7416002)(70206006)(8676002)(1076003)(478600001)(47076005)(2616005)(426003)(7696005)(6666004)(5660300002)(36756003)(54906003)(316002)(110136005)(86362001)(82310400005)(26005)(81973001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:16.4481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71897875-8820-43ce-6cb3-08db1b565e38 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5613 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The TEE subdriver for CCP, the amdtee driver and the i2c-designware-amdpsp drivers all include `psp-sev.h` even though they don't use SEV functionality. Move the definition of `__psp_pa` into a common header to be included by all of these drivers. Reviewed-by: Jan Dabros Acked-by: Jarkko Nikula # For the drivers/i2c/busses/i2c-designware-amdpsp.c Acked-by: Sumit Garg # For TEE subsystem bits Signed-off-by: Mario Limonciello --- v1->v2: * Add tags --- arch/x86/kvm/svm/sev.c | 1 + drivers/crypto/ccp/sev-dev.c | 1 + drivers/crypto/ccp/tee-dev.c | 2 +- drivers/i2c/busses/i2c-designware-amdpsp.c | 2 +- drivers/tee/amdtee/call.c | 2 +- drivers/tee/amdtee/shm_pool.c | 2 +- include/linux/psp-sev.h | 8 -------- include/linux/psp.h | 14 ++++++++++++++ 8 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 include/linux/psp.h diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index c25aeb550cd9..ec18a756b7c9 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index e2f25926eb51..28945ca7c856 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/drivers/crypto/ccp/tee-dev.c b/drivers/crypto/ccp/tee-dev.c index 5c9d47f3be37..f24fc953718a 100644 --- a/drivers/crypto/ccp/tee-dev.c +++ b/drivers/crypto/ccp/tee-dev.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include "psp-dev.h" diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c index 8f36167bce62..80f28a1bbbef 100644 --- a/drivers/i2c/busses/i2c-designware-amdpsp.c +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/tee/amdtee/call.c b/drivers/tee/amdtee/call.c index cec6e70f0ac9..e8cd9aaa3467 100644 --- a/drivers/tee/amdtee/call.c +++ b/drivers/tee/amdtee/call.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "amdtee_if.h" #include "amdtee_private.h" diff --git a/drivers/tee/amdtee/shm_pool.c b/drivers/tee/amdtee/shm_pool.c index f87f96a291c9..f0303126f199 100644 --- a/drivers/tee/amdtee/shm_pool.c +++ b/drivers/tee/amdtee/shm_pool.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include "amdtee_private.h" static int pool_op_alloc(struct tee_shm_pool *pool, struct tee_shm *shm, diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h index 1595088c428b..7fd17e82bab4 100644 --- a/include/linux/psp-sev.h +++ b/include/linux/psp-sev.h @@ -14,14 +14,6 @@ #include -#ifdef CONFIG_X86 -#include - -#define __psp_pa(x) __sme_pa(x) -#else -#define __psp_pa(x) __pa(x) -#endif - #define SEV_FW_BLOB_MAX_SIZE 0x4000 /* 16KB */ /** diff --git a/include/linux/psp.h b/include/linux/psp.h new file mode 100644 index 000000000000..202162487ec3 --- /dev/null +++ b/include/linux/psp.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PSP_H +#define __PSP_H + +#ifdef CONFIG_X86 +#include + +#define __psp_pa(x) __sme_pa(x) +#else +#define __psp_pa(x) __pa(x) +#endif + +#endif /* __PSP_H */ From patchwork Thu Mar 2 19:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157802 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C083C678D4 for ; Thu, 2 Mar 2023 19:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjCBTnj (ORCPT ); Thu, 2 Mar 2023 14:43:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjCBTnb (ORCPT ); Thu, 2 Mar 2023 14:43:31 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2085.outbound.protection.outlook.com [40.107.223.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEF3818163; Thu, 2 Mar 2023 11:43:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XDTF+TrUFc01ffxJ7CP6AYFSdnhTkPP8rjJKtnaCOYlwFr2J1ZNnWAlthiCN0yaVXVEzTJxdHz2w015kS8w+v03ITj8PclOBfXv7xr2GilMmEHj95nELgsyHoTBPWniYyNEmKLTQcwOFr58rLytA9g1EwshMRWynhz0oVIW0UICgAxPghZ3UBWznvmzIdLAOkaGIXCUz+MGgUpPCDVBDC0nDDjuxis8jzS7kU9x5w3DTKGrzOQj3zhIpQ0mLgng+Boqg1nwzacyZOQ7kjuEpcDq6m2BHnE0XHG9DLPtrqHNBRK7OklFrKj8sdzkmoADpgALL1vEvmIC9daPoq8ED1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4ldva1U0FnDIt0vo0SYbmtaF6GlGPv+WeONvDG7Udos=; b=CExmR0iVYlRacuT6r64HtGbF0LHcM8pNx/hu9JdfUcMq32cGBxU1nY0AhtIIzOy+T8LdjQ5v1/q/BMJ73CgTRXGgsiqBczJLCESgL01b4d4pnIWUn/HNoFahOEio4t6v4ok7/L0ciPvYmJ9VSiLbA1E4vv8Vmr+WiSozqL2VeKU6uOtQmfUO3SFf+sE5HNwP4IKjnf4f2e6ajXAjOtlCJfYuLDcQuLOls9QM2vOiEcOixswsf9QGRwxZCojuTjh4Ft73hY6U2JZXJ8z8qACLKJDDEl1pS5U6mBRDFK7Skdzp531mAn3rmmibRE5hffY9ECzvGc4ZntxQvFv18rYnxg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4ldva1U0FnDIt0vo0SYbmtaF6GlGPv+WeONvDG7Udos=; b=2JF2+apJQGbQKLutFsbpJY8j/Lmn+3ejCtX87uRdoD4iDju7datYTxn5wtxbg8lFdIdCMAe1zY6t40R+jtj3LHmvfzVp+rJVw8nCFYHfvqzlr1utvaCHB451hSXighjsBVB6arFMCsvlDcX1HNhSMgHjqr/zbGkr7mVT1GVu8Fg= Received: from BN9PR03CA0914.namprd03.prod.outlook.com (2603:10b6:408:107::19) by BL1PR12MB5993.namprd12.prod.outlook.com (2603:10b6:208:399::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Thu, 2 Mar 2023 19:43:17 +0000 Received: from BN8NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::22) by BN9PR03CA0914.outlook.office365.com (2603:10b6:408:107::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18 via Frontend Transport; Thu, 2 Mar 2023 19:43:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT025.mail.protection.outlook.com (10.13.177.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.21 via Frontend Transport; Thu, 2 Mar 2023 19:43:16 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:15 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" , Brijesh Singh , "Jarkko Nikula" , Andy Shevchenko , Mika Westerberg CC: Mario Limonciello , "David S. Miller" , , , Subject: [PATCH v2 3/9] crypto: ccp: Move some PSP mailbox bit definitions into common header Date: Thu, 2 Mar 2023 13:42:26 -0600 Message-ID: <20230302194235.1724-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT025:EE_|BL1PR12MB5993:EE_ X-MS-Office365-Filtering-Correlation-Id: 51b50da2-7dfa-41d0-a211-08db1b565e90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pp1A/EEdg32U+etz3hOnFrOvKj+ebQE3+8bb8DEHWgRt0HmM8a0ShFlSLInd9BLjuXJ8Nz16DYzhlZbGDL91ysHqGrvMhFpbVOBhKI0FKn+DSNO3Azb426fcH0p6yCx8TsGlGI7RnGGEHN3aosIL+1YWcsG02e8vfCPJ1Hb0p6kFTbA3ECkKf01SJk5YeSRFT+nbnb1n+D63DEqAktNJQmAHXxN8RlCqH54oQbhLbaSQQp4wgXBypkD6rDaCX32Q71WnDwagLZZNMlhOU79zSyo2Jnac5t7+k9k0EMrBAEof5+e40WQzU6R3QOgA+1rvaYI00uRcBfPJ6k4yHNM0oYYyIL4zPzBEittm0pRo09gZ+9kFcKZUEbPMSQqVh0QWs4bZB6wZ+KwTRzx99+N3g67oHj0o2+X9/8QY42wxor9BRM4RZ+c8I5mYkhuHmpTekAKPiLe+fjbQARF/O44FhmN5JA8lC23g52j+3+21dt99HTCrUkGRGJHdxQOFOztMrOXlaqJjdzFdSuVdcgFHPqdQ6yoWLMzmEQvHEN45XtD265RjpRuxT4fHUtYiSFoHNReovUQ3BhGCcWoCHlOe4fRZlTWjUennM6mz/CvEsJcJ9Q4LTKdxV6s65cOiVUQnOpm7wRgLBa3zEi3sUGRZcy4dWGbmEdyQ5ALGaKY5HWWx5HbgJxySa1ADNXdEdUwKJUFBp1FYgnL3P6hVNJ3J1dPMmvDHSJ06goNMGDoFSRRmvedmh/9VkKKhnmwjJL+g X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(82740400003)(2906002)(15650500001)(316002)(4326008)(478600001)(83380400001)(921005)(82310400005)(40460700003)(44832011)(7416002)(36756003)(5660300002)(86362001)(40480700001)(36860700001)(70206006)(356005)(8676002)(54906003)(81166007)(110136005)(41300700001)(70586007)(7696005)(6666004)(8936002)(47076005)(426003)(2616005)(16526019)(1076003)(336012)(26005)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:16.9950 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51b50da2-7dfa-41d0-a211-08db1b565e90 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5993 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some of the bits and fields used for mailboxes communicating with the PSP are common across all mailbox implementations (SEV, TEE, etc). Move these bits into the common `linux/psp.h` so they don't need to be re-defined for each implementation. Signed-off-by: Mario Limonciello Acked-by: Rijo Thomas --- v1->v2: * Update comment to indicate it's PSP response not PSP ready --- drivers/crypto/ccp/psp-dev.h | 3 --- drivers/crypto/ccp/sev-dev.c | 15 +++++++-------- drivers/crypto/ccp/sev-dev.h | 2 +- drivers/crypto/ccp/tee-dev.c | 15 ++++++++------- drivers/i2c/busses/i2c-designware-amdpsp.c | 16 +++++----------- include/linux/psp.h | 12 ++++++++++++ 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index 06e1f317216d..55f54bb2b3fb 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -17,9 +17,6 @@ #include "sp-dev.h" -#define PSP_CMDRESP_RESP BIT(31) -#define PSP_CMDRESP_ERR_MASK 0xffff - #define MAX_PSP_NAME_LEN 16 extern struct psp_device *psp_master; diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 28945ca7c856..6440d35dfa4e 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -7,6 +7,7 @@ * Author: Brijesh Singh */ +#include #include #include #include @@ -103,7 +104,7 @@ static void sev_irq_handler(int irq, void *data, unsigned int status) /* Check if it is SEV command completion: */ reg = ioread32(sev->io_regs + sev->vdata->cmdresp_reg); - if (reg & PSP_CMDRESP_RESP) { + if (FIELD_GET(PSP_CMDRESP_RESP, reg)) { sev->int_rcvd = 1; wake_up(&sev->int_queue); } @@ -347,9 +348,7 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) sev->int_rcvd = 0; - reg = cmd; - reg <<= SEV_CMDRESP_CMD_SHIFT; - reg |= SEV_CMDRESP_IOC; + reg = FIELD_PREP(SEV_CMDRESP_CMD, cmd) | SEV_CMDRESP_IOC; iowrite32(reg, sev->io_regs + sev->vdata->cmdresp_reg); /* wait for command completion */ @@ -367,11 +366,11 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret) psp_timeout = psp_cmd_timeout; if (psp_ret) - *psp_ret = reg & PSP_CMDRESP_ERR_MASK; + *psp_ret = FIELD_GET(PSP_CMDRESP_STS, reg); - if (reg & PSP_CMDRESP_ERR_MASK) { - dev_dbg(sev->dev, "sev command %#x failed (%#010x)\n", - cmd, reg & PSP_CMDRESP_ERR_MASK); + if (FIELD_GET(PSP_CMDRESP_STS, reg)) { + dev_dbg(sev->dev, "sev command %#x failed (%#010lx)\n", + cmd, FIELD_GET(PSP_CMDRESP_STS, reg)); ret = -EIO; } else { ret = sev_write_init_ex_file_if_required(cmd); diff --git a/drivers/crypto/ccp/sev-dev.h b/drivers/crypto/ccp/sev-dev.h index 666c21eb81ab..778c95155e74 100644 --- a/drivers/crypto/ccp/sev-dev.h +++ b/drivers/crypto/ccp/sev-dev.h @@ -25,8 +25,8 @@ #include #include +#define SEV_CMDRESP_CMD GENMASK(26, 16) #define SEV_CMD_COMPLETE BIT(1) -#define SEV_CMDRESP_CMD_SHIFT 16 #define SEV_CMDRESP_IOC BIT(0) struct sev_misc_dev { diff --git a/drivers/crypto/ccp/tee-dev.c b/drivers/crypto/ccp/tee-dev.c index f24fc953718a..5560bf8329a1 100644 --- a/drivers/crypto/ccp/tee-dev.c +++ b/drivers/crypto/ccp/tee-dev.c @@ -8,6 +8,7 @@ * Copyright (C) 2019,2021 Advanced Micro Devices, Inc. */ +#include #include #include #include @@ -69,7 +70,7 @@ static int tee_wait_cmd_poll(struct psp_tee_device *tee, unsigned int timeout, while (--nloop) { *reg = ioread32(tee->io_regs + tee->vdata->cmdresp_reg); - if (*reg & PSP_CMDRESP_RESP) + if (FIELD_GET(PSP_CMDRESP_RESP, *reg)) return 0; usleep_range(10000, 10100); @@ -149,9 +150,9 @@ static int tee_init_ring(struct psp_tee_device *tee) goto free_buf; } - if (reg & PSP_CMDRESP_ERR_MASK) { - dev_err(tee->dev, "tee: ring init command failed (%#010x)\n", - reg & PSP_CMDRESP_ERR_MASK); + if (FIELD_GET(PSP_CMDRESP_STS, reg)) { + dev_err(tee->dev, "tee: ring init command failed (%#010lx)\n", + FIELD_GET(PSP_CMDRESP_STS, reg)); tee_free_ring(tee); ret = -EIO; } @@ -179,9 +180,9 @@ static void tee_destroy_ring(struct psp_tee_device *tee) ret = tee_wait_cmd_poll(tee, TEE_DEFAULT_TIMEOUT, ®); if (ret) { dev_err(tee->dev, "tee: ring destroy command timed out\n"); - } else if (reg & PSP_CMDRESP_ERR_MASK) { - dev_err(tee->dev, "tee: ring destroy command failed (%#010x)\n", - reg & PSP_CMDRESP_ERR_MASK); + } else if (FIELD_GET(PSP_CMDRESP_STS, reg)) { + dev_err(tee->dev, "tee: ring destroy command failed (%#010lx)\n", + FIELD_GET(PSP_CMDRESP_STS, reg)); } free_ring: diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c index 80f28a1bbbef..652e6b64bd5f 100644 --- a/drivers/i2c/busses/i2c-designware-amdpsp.c +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c @@ -25,12 +25,6 @@ #define PSP_I2C_REQ_STS_BUS_BUSY 0x1 #define PSP_I2C_REQ_STS_INV_PARAM 0x3 -#define PSP_MBOX_FIELDS_STS GENMASK(15, 0) -#define PSP_MBOX_FIELDS_CMD GENMASK(23, 16) -#define PSP_MBOX_FIELDS_RESERVED GENMASK(29, 24) -#define PSP_MBOX_FIELDS_RECOVERY BIT(30) -#define PSP_MBOX_FIELDS_READY BIT(31) - struct psp_req_buffer_hdr { u32 total_size; u32 status; @@ -99,15 +93,15 @@ static int psp_check_mbox_recovery(struct psp_mbox __iomem *mbox) tmp = readl(&mbox->cmd_fields); - return FIELD_GET(PSP_MBOX_FIELDS_RECOVERY, tmp); + return FIELD_GET(PSP_CMDRESP_RECOVERY, tmp); } static int psp_wait_cmd(struct psp_mbox __iomem *mbox) { u32 tmp, expected; - /* Expect mbox_cmd to be cleared and ready bit to be set by PSP */ - expected = FIELD_PREP(PSP_MBOX_FIELDS_READY, 1); + /* Expect mbox_cmd to be cleared and the response bit to be set by PSP */ + expected = FIELD_PREP(PSP_CMDRESP_RESP, 1); /* * Check for readiness of PSP mailbox in a tight loop in order to @@ -124,7 +118,7 @@ static u32 psp_check_mbox_sts(struct psp_mbox __iomem *mbox) cmd_reg = readl(&mbox->cmd_fields); - return FIELD_GET(PSP_MBOX_FIELDS_STS, cmd_reg); + return FIELD_GET(PSP_CMDRESP_STS, cmd_reg); } static int psp_send_cmd(struct psp_i2c_req *req) @@ -148,7 +142,7 @@ static int psp_send_cmd(struct psp_i2c_req *req) writeq(req_addr, &mbox->i2c_req_addr); /* Write command register to trigger processing */ - cmd_reg = FIELD_PREP(PSP_MBOX_FIELDS_CMD, PSP_I2C_REQ_BUS_CMD); + cmd_reg = FIELD_PREP(PSP_CMDRESP_CMD, PSP_I2C_REQ_BUS_CMD); writel(cmd_reg, &mbox->cmd_fields); if (psp_wait_cmd(mbox)) diff --git a/include/linux/psp.h b/include/linux/psp.h index 202162487ec3..d3424790a70e 100644 --- a/include/linux/psp.h +++ b/include/linux/psp.h @@ -11,4 +11,16 @@ #define __psp_pa(x) __pa(x) #endif +/* + * Fields and bits used by most PSP mailboxes + * + * Note: Some mailboxes (such as SEV) have extra bits or different meanings + * and should include an appropriate local definition in their source file. + */ +#define PSP_CMDRESP_STS GENMASK(15, 0) +#define PSP_CMDRESP_CMD GENMASK(23, 16) +#define PSP_CMDRESP_RESERVED GENMASK(29, 24) +#define PSP_CMDRESP_RECOVERY BIT(30) +#define PSP_CMDRESP_RESP BIT(31) + #endif /* __PSP_H */ From patchwork Thu Mar 2 19:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157803 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13AE7C6FA8E for ; Thu, 2 Mar 2023 19:43:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbjCBTnn (ORCPT ); Thu, 2 Mar 2023 14:43:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjCBTnd (ORCPT ); Thu, 2 Mar 2023 14:43:33 -0500 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2063.outbound.protection.outlook.com [40.107.220.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C6A83CE3B; Thu, 2 Mar 2023 11:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJER63E1lzPXmE7/ec2lQZRVsTtzgh8l+QN/kN/M3x1qdaz1dxm06jsDUTANLbEMh5Nj1qkrfmazzrfpDXnSCxOy/GzGauqTx9BeysfW/100x40WnLv+dD5GOVnbJkD3/YmjLlEyU67fhI+7y5yQH4a6WhGox0rvhjPYYf86SLNt22JM3tT8c7wmCochlk/1232/Dvach39ND1Rsv3CbWh4A+owaWYA/jnwVzaQeq7gkk3axA7RIla3+bg0IG5+e8iK46By3VRxXGdFLD72d0Hlh/J751wKkTRKzAPsn+ohaxElHF/Dwi+KmlDhOH+rLnxfU4wXwZbRDt+TAofh76Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xUtmsny6cIQjS+9zsO6Cp3sxnM0wTqT91Jyn3CmEJKs=; b=iSUwNugmZtajvwrL0YhG1xEo/rlLrue7Ask4H+1dKtH/E299Q7UNetbRCUffL6qqlpO/27/kan8zbLiCUW5tNJKtLiqWRZYAw0MnbQHnSSJYAZ3zVeZgn9KmeSaGFQpTx3szAfeKTJQfEpNqntYIvEn+qKumuV0nyxE1POhKxKZoH9OYQXIIrwgPkGP6EDZruhBOHSVD/hfJwC9bDK0FfeGLujQzCdOA8GheLA+DbG/zJKFjbhWZlonmKVk30U2+/gOV9qjCaglu80OIWheQ8Lolzh4221NFPsTki2jbpa9jTglWyTe0vas3vxqygPNKb9AM3UHW/2y7vogIb4LwbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xUtmsny6cIQjS+9zsO6Cp3sxnM0wTqT91Jyn3CmEJKs=; b=hLDTGp4nZm2KORrEJgPEmFZfkqnMYxtbaOttE+J9UsBvSPeHjoRwWFKID07wR44DC0RkZYSI7yw2N2tHPurFHVhXWdfn4cm0QwSmivHgjIxRV/WOqjT93xaVzDhAlW5pJp63b2EBUBPVLBlC3Z+FXmiReF09zn5jj4QGhF7T/UM= Received: from BN8PR12CA0035.namprd12.prod.outlook.com (2603:10b6:408:60::48) by DS7PR12MB6238.namprd12.prod.outlook.com (2603:10b6:8:96::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17; Thu, 2 Mar 2023 19:43:19 +0000 Received: from BN8NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:408:60:cafe::1b) by BN8PR12CA0035.outlook.office365.com (2603:10b6:408:60::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT091.mail.protection.outlook.com (10.13.176.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 19:43:18 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:17 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" CC: Mario Limonciello , "David S. Miller" , , Subject: [PATCH v2 4/9] crypto: ccp: Add support for an interface for platform features Date: Thu, 2 Mar 2023 13:42:27 -0600 Message-ID: <20230302194235.1724-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT091:EE_|DS7PR12MB6238:EE_ X-MS-Office365-Filtering-Correlation-Id: 66764d5c-7b0e-4db2-f51b-08db1b565f90 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LvT2v8bBFMG4PmB92WeRxmIFSub5rb17ZZ7H8WB8tWp++I4AtrLEtmlL1Mho6h/gAW2AOstvaUuKEf5ua+R3zSm+m7VzhhuqWTC0UsgsahJC58wwOZjywACwCuoKx+he58/SPviQzOxi9IIwQEoBEc4yfeWlGnVDk70n0uWrmkbQtOf6WX4Md9l02grf5RttiLzMmwpEpR3ovrRHoFU8tjI2V01CKqTX544c4sMExiLfioT/X4BL1p6RGCE6AJtnSbRNQd+I2rukYK491vgjAcjogzl2wV/fhzeEfexyi317w8ZqgyWQyzeU/cDjDwvyYF1LftCL8MNnm1arHLH6Gt4kNHy8UeNz5YXlG7Zr7l92o2ikDrdmPd9b8pR9RAHANe5lM0y6XCxtnfTwKjoJqMtAJzuzK7DtIhq7oHkWtF6jUgBmoA7JLFeW4IBfx/4HjroKIaQkzeUm53RP1Hc3qOU01jKE6ltgHBPZWGoYX4mX0msMyqlWj0XhBL0GhG47+A+OUxeQfbaRwkYS81Jt7Biag/gZKZfk2IP6XZAZnCUngcgqsGs4nUBVxl05lNKyDOvvoFSNdw8fbz9k/iWYlTLCK12X2ynUQW4V7BNC6jy/Oruf9TioaeFldyjfpEPwCriaQ3N9fdDvjocRaprHwlQMdTT+QUNAYJTUQhBRdf7+m1mqj4WhPvTxQ9DgBkT8FQhgmJoY5DBaJrT9URVHxIQ01xptFHk6hcfT2WECJJa+1uZfB3Q0odEDFKyc220Es+5hoKl1mgygXSvsA+FB4w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199018)(36840700001)(46966006)(40470700004)(356005)(8676002)(81166007)(36860700001)(82740400003)(2906002)(44832011)(5660300002)(4326008)(36756003)(70206006)(30864003)(86362001)(8936002)(41300700001)(40480700001)(70586007)(186003)(2616005)(16526019)(336012)(40460700003)(26005)(1076003)(83380400001)(47076005)(426003)(316002)(6666004)(478600001)(6636002)(7696005)(54906003)(82310400005)(110136005)(36900700001)(134885004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:18.7061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66764d5c-7b0e-4db2-f51b-08db1b565f90 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6238 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some platforms with a PSP support an interface for features that interact directly with the PSP instead of through a SEV or TEE environment. Initialize this interface so that other drivers can consume it. These drivers may either be subdrivers for the ccp module or external modules. For external modules, export a symbol for them to utilize. Signed-off-by: Mario Limonciello --- v1->v2: * Fix comment text * Add safety check that register values were populated --- drivers/crypto/ccp/Makefile | 3 +- drivers/crypto/ccp/platform-access.c | 169 +++++++++++++++++++++++++++ drivers/crypto/ccp/platform-access.h | 34 ++++++ drivers/crypto/ccp/psp-dev.c | 17 +++ drivers/crypto/ccp/psp-dev.h | 1 + drivers/crypto/ccp/sp-dev.h | 7 ++ include/linux/psp-platform-access.h | 49 ++++++++ 7 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ccp/platform-access.c create mode 100644 drivers/crypto/ccp/platform-access.h create mode 100644 include/linux/psp-platform-access.h diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile index db362fe472ea..f6196495e862 100644 --- a/drivers/crypto/ccp/Makefile +++ b/drivers/crypto/ccp/Makefile @@ -10,7 +10,8 @@ ccp-$(CONFIG_CRYPTO_DEV_CCP_DEBUGFS) += ccp-debugfs.o ccp-$(CONFIG_PCI) += sp-pci.o ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \ sev-dev.o \ - tee-dev.o + tee-dev.o \ + platform-access.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o ccp-crypto-objs := ccp-crypto-main.o \ diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c new file mode 100644 index 000000000000..af3a1e97abfe --- /dev/null +++ b/drivers/crypto/ccp/platform-access.c @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Platform Security Processor (PSP) Platform Access interface + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello + * + * Some of this code is adapted from drivers/i2c/busses/i2c-designware-amdpsp.c + * developed by Jan Dabros and Copyright (C) 2022 Google Inc. + * + */ + +#include +#include +#include +#include + +#include "platform-access.h" + +#define PSP_CMD_TIMEOUT_US (500 * USEC_PER_MSEC) + +/* Recovery field should be equal 0 to start sending commands */ +static int check_recovery(u32 __iomem *cmd) +{ + return FIELD_GET(PSP_CMDRESP_RECOVERY, ioread32(cmd)); +} + +static int wait_cmd(u32 __iomem *cmd) +{ + u32 tmp, expected; + + /* Expect mbox_cmd to be cleared and ready bit to be set by PSP */ + expected = FIELD_PREP(PSP_CMDRESP_RESP, 1); + + /* + * Check for readiness of PSP mailbox in a tight loop in order to + * process further as soon as command was consumed. + */ + return readl_poll_timeout(cmd, tmp, (tmp & expected), 0, + PSP_CMD_TIMEOUT_US); +} + +int psp_check_platform_access_status(void) +{ + struct psp_device *psp = psp_get_master_device(); + + if (!psp || !psp->platform_access_data) + return -ENODEV; + + return 0; +} +EXPORT_SYMBOL(psp_check_platform_access_status); + +int psp_send_platform_access_msg(enum psp_platform_access_msg msg, + struct psp_request *req) +{ + struct psp_device *psp = psp_get_master_device(); + u32 __iomem *cmd, __iomem *lo, __iomem *hi; + struct psp_platform_access_device *pa_dev; + phys_addr_t req_addr; + u32 cmd_reg; + int ret; + + if (!psp || !psp->platform_access_data) + return -ENODEV; + + pa_dev = psp->platform_access_data; + cmd = psp->io_regs + pa_dev->vdata->cmdresp_reg; + lo = psp->io_regs + pa_dev->vdata->cmdbuff_addr_lo_reg; + hi = psp->io_regs + pa_dev->vdata->cmdbuff_addr_hi_reg; + + if (!cmd || !lo || !hi) + return -ENODEV; + + mutex_lock(&pa_dev->mutex); + + if (check_recovery(cmd)) { + dev_dbg(psp->dev, "in recovery\n"); + ret = -EBUSY; + goto unlock; + } + + if (wait_cmd(cmd)) { + dev_dbg(psp->dev, "not done processing command\n"); + ret = -EBUSY; + goto unlock; + } + + /* + * Fill mailbox with address of command-response buffer, which will be + * used for sending i2c requests as well as reading status returned by + * PSP. Use physical address of buffer, since PSP will map this region. + */ + req_addr = __psp_pa(req); + iowrite32(lower_32_bits(req_addr), lo); + iowrite32(upper_32_bits(req_addr), hi); + + print_hex_dump_debug("->psp ", DUMP_PREFIX_OFFSET, 16, 2, req, + req->header.payload_size, false); + + /* Write command register to trigger processing */ + cmd_reg = FIELD_PREP(PSP_CMDRESP_CMD, msg); + iowrite32(cmd_reg, cmd); + + if (wait_cmd(cmd)) { + ret = -ETIMEDOUT; + goto unlock; + } + + /* Ensure it was triggered by this driver */ + if (ioread32(lo) != lower_32_bits(req_addr) || + ioread32(hi) != upper_32_bits(req_addr)) { + ret = -EBUSY; + goto unlock; + } + + /* Store the status in request header for caller to investigate */ + cmd_reg = ioread32(cmd); + req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); + if (req->header.status) { + ret = -EIO; + goto unlock; + } + + print_hex_dump_debug("<-psp ", DUMP_PREFIX_OFFSET, 16, 2, req, + req->header.payload_size, false); + + ret = 0; + +unlock: + mutex_unlock(&pa_dev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(psp_send_platform_access_msg); + +void platform_access_dev_destroy(struct psp_device *psp) +{ + struct psp_platform_access_device *pa_dev = psp->platform_access_data; + + if (!pa_dev) + return; + + mutex_destroy(&pa_dev->mutex); + psp->platform_access_data = NULL; +} + +int platform_access_dev_init(struct psp_device *psp) +{ + struct device *dev = psp->dev; + struct psp_platform_access_device *pa_dev; + + pa_dev = devm_kzalloc(dev, sizeof(*pa_dev), GFP_KERNEL); + if (!pa_dev) + return -ENOMEM; + + psp->platform_access_data = pa_dev; + pa_dev->psp = psp; + pa_dev->dev = dev; + + pa_dev->vdata = (struct platform_access_vdata *)psp->vdata->platform_access; + + mutex_init(&pa_dev->mutex); + + dev_dbg(dev, "platform access enabled\n"); + + return 0; +} diff --git a/drivers/crypto/ccp/platform-access.h b/drivers/crypto/ccp/platform-access.h new file mode 100644 index 000000000000..56bc8eabeacc --- /dev/null +++ b/drivers/crypto/ccp/platform-access.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * AMD Platform Security Processor (PSP) Platform Access interface + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello + */ + +#ifndef __PSP_PLATFORM_ACCESS_H__ +#define __PSP_PLATFORM_ACCESS_H__ + +#include +#include +#include +#include + +#include "psp-dev.h" + +struct psp_platform_access_device { + struct device *dev; + struct psp_device *psp; + + struct platform_access_vdata *vdata; + + struct mutex mutex; + + void *platform_access_data; +}; + +void platform_access_dev_destroy(struct psp_device *psp); +int platform_access_dev_init(struct psp_device *psp); + +#endif /* __PSP_PLATFORM_ACCESS_H__ */ diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index cd8d1974726a..ec98f19800de 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -14,6 +14,7 @@ #include "psp-dev.h" #include "sev-dev.h" #include "tee-dev.h" +#include "platform-access.h" struct psp_device *psp_master; @@ -102,6 +103,17 @@ static int psp_check_tee_support(struct psp_device *psp) return 0; } +static void psp_init_platform_access(struct psp_device *psp) +{ + int ret; + + ret = platform_access_dev_init(psp); + if (ret) { + dev_warn(psp->dev, "platform access init failed: %d\n", ret); + return; + } +} + static int psp_init(struct psp_device *psp) { int ret; @@ -118,6 +130,9 @@ static int psp_init(struct psp_device *psp) return ret; } + if (psp->vdata->platform_access) + psp_init_platform_access(psp); + return 0; } @@ -198,6 +213,8 @@ void psp_dev_destroy(struct sp_device *sp) tee_dev_destroy(psp); + platform_access_dev_destroy(psp); + sp_free_psp_irq(sp, psp); if (sp->clear_psp_master_device) diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index 55f54bb2b3fb..505e4bdeaca8 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -39,6 +39,7 @@ struct psp_device { void *sev_data; void *tee_data; + void *platform_access_data; unsigned int capability; }; diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 20377e67f65d..5ec6c219a731 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -53,9 +53,16 @@ struct tee_vdata { const unsigned int ring_rptr_reg; }; +struct platform_access_vdata { + const unsigned int cmdresp_reg; + const unsigned int cmdbuff_addr_lo_reg; + const unsigned int cmdbuff_addr_hi_reg; +}; + struct psp_vdata { const struct sev_vdata *sev; const struct tee_vdata *tee; + const struct platform_access_vdata *platform_access; const unsigned int feature_reg; const unsigned int inten_reg; const unsigned int intsts_reg; diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h new file mode 100644 index 000000000000..977df5cfd494 --- /dev/null +++ b/include/linux/psp-platform-access.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __PSP_PLATFORM_ACCESS_H +#define __PSP_PLATFORM_ACCESS_H + +#include + +enum psp_platform_access_msg { + PSP_CMD_NONE = 0x0, +}; + +struct psp_req_buffer_hdr { + u32 payload_size; + u32 status; +} __packed; + +struct psp_request { + struct psp_req_buffer_hdr header; + void *buf; +} __packed; + +/** + * psp_send_platform_access_msg() - Send a message to control platform features + * + * This function is intended to be used by drivers outside of ccp to communicate + * with the platform. + * + * Returns: + * 0: success + * -%EBUSY: mailbox in recovery or in use + * -%ENODEV: driver not bound with PSP device + * -%ETIMEDOUT: request timed out + * -%EIO: unknown error (see kernel log) + */ +int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req); + +/** + * psp_check_platform_access_status() - Checks whether platform features is ready + * + * This function is intended to be used by drivers outside of ccp to determine + * if platform features has initialized. + * + * Returns: + * 0 platform features is ready + * -%ENODEV platform features is not ready or present + */ +int psp_check_platform_access_status(void); + +#endif /* __PSP_PLATFORM_ACCESS_H */ From patchwork Thu Mar 2 19:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157801 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64D59C7EE2F for ; Thu, 2 Mar 2023 19:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229835AbjCBTnm (ORCPT ); Thu, 2 Mar 2023 14:43:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbjCBTnf (ORCPT ); Thu, 2 Mar 2023 14:43:35 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A87A580C7; Thu, 2 Mar 2023 11:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oDnzqkMllSTi2cvDvzvjn4EQxPLtqN8E3cKc7eeTLxB2ge3N53yXEtoONoLrhjQX+t9AiNE/cgspQeuT2dcstlwS2QJ5TQeepAvmG+tu3E8M4GN/rL/bVQAExMJ8ZZ4BjVG9TWOscbW/V6Z/nhFIYY7kSPbeIVMIT4oVnAGPgQL/ygXuQbWGcyRRnu/AQHn5E1/PjEjJ6VkcoaH+PG5ZC29OEmPee2C7p4LdAFqadYo3vGxPdLccGBSyFRpia7lhzsGy1S2+rM+TbFfXjFUbf50WA/QLBbZRNMRS5uBM+hGHKhvdR9TwtbtwePTmlVOdZFfeCE+SzJkwgyXFqOeeQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=miIKd2uqEYODxld1Xk6KNcz1a3s+EFrV/93HLXFqcRk=; b=dPLOVjePcHjtLrhnm2/vE97YjG+fppJN+H01nSIlopuCzuta2cG0rVyr1d+azHFbT3jUiWpsIN4HXroFaKO4Q0BYH0igmSuPyVQFzQsJ/Qvl2gS5+Dn8726H5k4vJb0xcCo4WS4mQ7hy+B+VAagV2oVKtco3QPOJ6lpKFGKbzpwEgWO79P9bifR0bMG5kjJfP0bH6RxaZ1WX9VtyPRb0J9mdf03OcJHVaUa38LyJHeoQKfmzcbQAcHjuv1Ul2eS+26+7J683V6PToM79jffs30LJrG/tAtV63lDEVej1VQ76/L+qgJsL+Dbr9HMvsONOwQLUVq6Fz1AFP2QfAVhgmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=miIKd2uqEYODxld1Xk6KNcz1a3s+EFrV/93HLXFqcRk=; b=qhLzLBP3PRWcXfbsK7QlMFIb98jr4e1JUvjz/bG6+cb25gxuXv4Gw2c1xGzlGhOLejaMRPSlolwJhdRlQRzi8cG3w4NfzaPLgCd63EEyYhKDK7ngsJ/hELadFEqWH+D3cAPmKMVaBkIv4oiSJLt9Wynl930T8cqstkVideoQPcQ= Received: from BN9PR03CA0901.namprd03.prod.outlook.com (2603:10b6:408:107::6) by SA1PR12MB7368.namprd12.prod.outlook.com (2603:10b6:806:2b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Thu, 2 Mar 2023 19:43:20 +0000 Received: from BN8NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::37) by BN9PR03CA0901.outlook.office365.com (2603:10b6:408:107::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT026.mail.protection.outlook.com (10.13.177.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 19:43:19 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:18 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" CC: Mario Limonciello , "David S. Miller" , , Subject: [PATCH v2 5/9] crypto: ccp: Enable platform access interface on client PSP parts Date: Thu, 2 Mar 2023 13:42:28 -0600 Message-ID: <20230302194235.1724-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT026:EE_|SA1PR12MB7368:EE_ X-MS-Office365-Filtering-Correlation-Id: c08cbd6c-6de3-44b7-22c6-08db1b566037 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A85P2OTEDYetw+EabG0JACNnuVwrIfKi4xePco2lc1T3/quDsQf0fGm5xq85Xt2LtoIC7+Or7DbiIBt6hIxNLT/Nvut2jLRSHymRS/AzBKf41jDj18ldTlPxQm+Bs6u7iOLIwtqjHUwCcTw7ecuHkGJ26D5Wvbv9c8/d/nlzXLvSLa0SH4FFd0csL01MVTbx5TFLIs025CKEZ4O49Qdq/v0iGIh7kVV8b9kUjAqUXvrStIlmYFlqBeoNkLMDcfo2VhxJxhE1rjbGfk+3kMphlmSq8Fbjs52lscO+9L+dQWTZuq36DNaXGK4Oa7jp3W3IzktUDMjU7PIR95MqT2zO7ccvotWdslLRjrfJGniYxGmi7bhtB0GiQP7dHiPb7pSzyuLRUM5eUYt9p8TTe3hiAFLt1maibJHhvCxIIRk/zGg65m7LfkTs623dP+V78fIxGSc7I5tMArYPevHAIOkBVLn1Kd/BE1bYREh30B1TYUdEn4LYwlr9omFeBEmYoTKnxAiuSCft4lAi/Hfm1N9Fpf2qFlJmT15Y5ChSkH77oO+K5C6FGNSxQJ4ri8xdx7OeP2QCGjdEUfdDrCOg9/e5AqR+Q4bwtl3YDcozOE8B9a/gRiPOPkP13oupqC/2GcXBcM986seDdF+5jh4u5+0THxCpQAJHuArUA792yBuXJ4pht7cl8r2M7cKI01k+0HiI3Gc939n5SvQj7V62U29vSkBSx5LqJ1gquTInY8mWiSw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199018)(40470700004)(36840700001)(46966006)(356005)(81166007)(36860700001)(82740400003)(41300700001)(8936002)(4326008)(86362001)(2906002)(40480700001)(70206006)(5660300002)(36756003)(44832011)(8676002)(82310400005)(70586007)(336012)(40460700003)(1076003)(26005)(2616005)(186003)(83380400001)(426003)(16526019)(47076005)(110136005)(6636002)(478600001)(316002)(54906003)(7696005)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:19.7951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c08cbd6c-6de3-44b7-22c6-08db1b566037 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7368 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Client PSP parts support the platform access interface. Add the register offsets so that client parts will initialize this interface. Signed-off-by: Mario Limonciello --- drivers/crypto/ccp/sp-pci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index cde33b2ac71b..18aa902eb5ce 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -361,6 +361,12 @@ static const struct tee_vdata teev1 = { .ring_rptr_reg = 0x10554, /* C2PMSG_21 */ }; +static const struct platform_access_vdata pa_v1 = { + .cmdresp_reg = 0x10570, /* C2PMSG_28 */ + .cmdbuff_addr_lo_reg = 0x10574, /* C2PMSG_29 */ + .cmdbuff_addr_hi_reg = 0x10578, /* C2PMSG_30 */ +}; + static const struct psp_vdata pspv1 = { .sev = &sevv1, .feature_reg = 0x105fc, /* C2PMSG_63 */ @@ -377,6 +383,7 @@ static const struct psp_vdata pspv2 = { static const struct psp_vdata pspv3 = { .tee = &teev1, + .platform_access = &pa_v1, .feature_reg = 0x109fc, /* C2PMSG_63 */ .inten_reg = 0x10690, /* P2CMSG_INTEN */ .intsts_reg = 0x10694, /* P2CMSG_INTSTS */ From patchwork Thu Mar 2 19:42:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157808 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84DA9C7EE2F for ; Thu, 2 Mar 2023 19:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjCBToS (ORCPT ); Thu, 2 Mar 2023 14:44:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbjCBToC (ORCPT ); Thu, 2 Mar 2023 14:44:02 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957B258B4B; Thu, 2 Mar 2023 11:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhwUG7YbF8gl+rDrCE6RXYfKVnueiIaxdOo0KyU0OsbQm6Cg/N7XxUNy3DHNSH5sgNbN4svI3cvDG46v2umF0JH7sheAKwRcSnS7G2Rgvu7UToxcMwnOvvCuAkROkyn4r6kFg6TBePCAoIBWOZ76gO7NexzwLaWQeg5M0a4FJv3r+PMmyGTffF5IeKCiS6xWyc1oweK6MeyUK9/svdOFAQi4ebP8aQDDkKDYoNv3HDQRFUyZx2rRHtVtqrBQTK8PiZbNQAvCSGiyFa6x4KkMmV/1NC8tirsR6BAVL6XpX4mNKoqXUQP89w2GZkJQVa0GGAuQMhkeIYXM+F9e/LUPcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s37fTeFDkcK8QJ01FeyF0CA9erfiM7clF+ueBoMu37s=; b=BhEAJEJJ0g4Fx5O0OyfM4OxirAmL4n4ZEL2oX6fuplUs5ZBizuMEcKx2oT3YzxNoTdXPsx+/ikHN+tzokr6Yo7l/3Xk19NRncBbBO/csG2ubupb9hY/FptV+deqAmJmPFTbGZcsq9vT2MagC1KRXScgZl4nLGaGuwxg0F9iMFQCV4in5/wVsEpX3X+MF9wn0xt9t5zNn3ZmxGEG0gxizD1J9Ex1M1XsHBDLvpHpGNLK8Rzy3IUjKzHTzKW1bbTK36eWadZY4myYiUjGADXyhCPwvFxzKykju48bjcr6uPRXwO9c7Y9M6M2dpxsb49CR7HGAHv5PD56e1wJpa2+PZSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s37fTeFDkcK8QJ01FeyF0CA9erfiM7clF+ueBoMu37s=; b=N6v5VXtx6HRi7I/EuF2UlnImSAZIquD5Ga65DIk8LtIxcRe3x+OXR596bCdrEe1iyHWrM55PtBCYz6/6PqqAzP2rzdkKBK/Ia5U2PN8Nc8ETeliU6qBWxymCdGnxYRRMUaU7hYMrHRNXoDpezTtPoZ6BLSHTz4MM9y0EDXcKrDQ= Received: from BN9PR03CA0928.namprd03.prod.outlook.com (2603:10b6:408:107::33) by BL3PR12MB6475.namprd12.prod.outlook.com (2603:10b6:208:3bb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.25; Thu, 2 Mar 2023 19:43:22 +0000 Received: from BN8NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::a3) by BN9PR03CA0928.outlook.office365.com (2603:10b6:408:107::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT026.mail.protection.outlook.com (10.13.177.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 19:43:22 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:21 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" CC: Mario Limonciello , "David S. Miller" , , Subject: [PATCH v2 7/9] crypto: ccp: Add support for ringing a platform doorbell Date: Thu, 2 Mar 2023 13:42:30 -0600 Message-ID: <20230302194235.1724-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT026:EE_|BL3PR12MB6475:EE_ X-MS-Office365-Filtering-Correlation-Id: 1096de2f-4834-4269-c8e0-08db1b56620c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0AMaahyjxiCWh8xvSkiK5WjWjRVvgirBKQBidhyE78FhvEYqVqY2gA/Kr2KXyrb6i5Ay3utnmBSrnTD+hMUt71Sd1b+M9JrKuqXKGuP/YrchGcm6nC3CDzqmeIMAlRdV6BYXU48AYJPJbjLD/+D7aJIP1P3mTpGtVja3yMcn6qP2bknzP/JO38uptdMP4nTPh2hUCzsIkcOPHY2RqqMeD2sDXCA24Wh/VBnkFjdoGvkCxbmON0qSyDsT/tbekQr6LrvYkU7CYAi8hkkwus0QzPbFjzkEjYDnecGdypkmvUZNEA05CBNRInGFRwlg6OOAD8K8ar1CO4hiUmGyoYFDu0r5GB7U8hu6Q6qSmcjk82LrmzXN6m6S7nI1dKqNX+PBkmzHCIbY5Urrmefy0nH3NhbyMEEtJBCxUZUeTmFLHpXSwP5Ts/l9syCAwbcTqKcx9FiQ6ht7vJoDmEYAbGz23q6VSSi1g2EE1Gs9rO1aTI9ZJajq8pZRjnUJs2YYjlh5YVItuvUPN0j8V3QFkPTrDpp0C6JfwuRx1UWh9L5A9/6yC3IPs9J3kxRoPFVztU/VO9J2WQmnig34ejzDmqdRUEVeYMwM6g5ZYc0LsMumAceYI7XpIVWaPHr9c50Oh9/j1oWPwJBvolah9XgpJA2Ya+x0QmI8AcorpcV9wZCIk0ne9/wpfv5Zi0FeUR9xX4P2XaZqmO/0qWBzZGlNcpfW6IoLiqFVi+djZDTBwIVaFg2S2v4p3vAm5RlN2y7yp3RR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(346002)(376002)(39860400002)(451199018)(40470700004)(36840700001)(46966006)(478600001)(110136005)(83380400001)(6636002)(316002)(54906003)(426003)(86362001)(7696005)(2616005)(82310400005)(36860700001)(336012)(81166007)(47076005)(26005)(36756003)(966005)(186003)(82740400003)(16526019)(356005)(1076003)(40460700003)(6666004)(40480700001)(2906002)(70206006)(8936002)(44832011)(5660300002)(41300700001)(4326008)(70586007)(8676002)(36900700001)(134885004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:22.8887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1096de2f-4834-4269-c8e0-08db1b56620c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6475 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some platforms support using a doorbell to communicate. Export this feature for other drivers to utilize as well. Link: https://lore.kernel.org/linux-i2c/20220916131854.687371-3-jsd@semihalf.com/ Suggested-by: Jan Dabros Signed-off-by: Mario Limonciello --- v1->v2: * New patch --- drivers/crypto/ccp/platform-access.c | 47 ++++++++++++++++++++++++++++ drivers/crypto/ccp/sp-dev.h | 1 + include/linux/psp-platform-access.h | 15 +++++++++ include/linux/psp.h | 3 ++ 4 files changed, 66 insertions(+) diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c index af3a1e97abfe..0763389a2814 100644 --- a/drivers/crypto/ccp/platform-access.c +++ b/drivers/crypto/ccp/platform-access.c @@ -135,6 +135,53 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, } EXPORT_SYMBOL_GPL(psp_send_platform_access_msg); +int psp_ring_platform_doorbell(enum psp_platform_access_msg msg) +{ + struct psp_device *psp = psp_get_master_device(); + struct psp_platform_access_device *pa_dev; + u32 __iomem *drbl; + u32 drbl_reg; + int ret; + + if (!psp || !psp->platform_access_data) + return -ENODEV; + + pa_dev = psp->platform_access_data; + drbl = psp->io_regs + pa_dev->vdata->doorbell_reg; + + if (!drbl) + return -ENODEV; + + mutex_lock(&pa_dev->mutex); + + if (check_recovery(drbl)) { + dev_dbg(psp->dev, "in recovery\n"); + ret = -EBUSY; + goto unlock; + } + + if (wait_cmd(drbl)) { + dev_dbg(psp->dev, "not done processing command\n"); + ret = -EBUSY; + goto unlock; + } + + drbl_reg = FIELD_PREP(PSP_DRBL_MSG, msg) | PSP_DRBL_RING; + iowrite32(drbl_reg, drbl); + + if (wait_cmd(drbl)) { + ret = -ETIMEDOUT; + goto unlock; + } + + ret = 0; +unlock: + mutex_unlock(&pa_dev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(psp_ring_platform_doorbell); + void platform_access_dev_destroy(struct psp_device *psp) { struct psp_platform_access_device *pa_dev = psp->platform_access_data; diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 5ec6c219a731..87c0b9350bc2 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -54,6 +54,7 @@ struct tee_vdata { }; struct platform_access_vdata { + const unsigned int doorbell_reg; const unsigned int cmdresp_reg; const unsigned int cmdbuff_addr_lo_reg; const unsigned int cmdbuff_addr_hi_reg; diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h index f5a03cd11f10..1e1d0e077cec 100644 --- a/include/linux/psp-platform-access.h +++ b/include/linux/psp-platform-access.h @@ -35,6 +35,21 @@ struct psp_request { */ int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req); +/** + * psp_ring_platform_doorbell() - Ring platform doorbell + * + * This function is intended to be used by drivers outside of ccp to ring the + * platform doorbell with a message. + * + * Returns: + * 0: success + * -%EBUSY: mailbox in recovery or in use + * -%ENODEV: driver not bound with PSP device + * -%ETIMEDOUT: request timed out + * -%EIO: unknown error (see kernel log) + */ +int psp_ring_platform_doorbell(enum psp_platform_access_msg); + /** * psp_check_platform_access_status() - Checks whether platform features is ready * diff --git a/include/linux/psp.h b/include/linux/psp.h index d3424790a70e..92e60aeef21e 100644 --- a/include/linux/psp.h +++ b/include/linux/psp.h @@ -23,4 +23,7 @@ #define PSP_CMDRESP_RECOVERY BIT(30) #define PSP_CMDRESP_RESP BIT(31) +#define PSP_DRBL_MSG PSP_CMDRESP_CMD +#define PSP_DRBL_RING BIT(0) + #endif /* __PSP_H */ From patchwork Thu Mar 2 19:42:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13157807 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E23B2C6FA8E for ; Thu, 2 Mar 2023 19:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbjCBToR (ORCPT ); Thu, 2 Mar 2023 14:44:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbjCBToB (ORCPT ); Thu, 2 Mar 2023 14:44:01 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2065.outbound.protection.outlook.com [40.107.223.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15C6958B40; Thu, 2 Mar 2023 11:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eiqkYOmJ7X2lhozGIH7LoVZUwP30u5/l3jzPQdJRk+v5V+9OzJqZZAR5VCRex1KE+bGT4kq+TgRn+pAKWc6EYXoJjsgtPCVXlMEzez6UydS6jkIlCejgdQ6iT5JcB2cDbm0jPOM7t5l/q2p7HmuIM7DJfWsiDmlB/QPcs2N0xrWZKlmyEj5UZRfLQJ2FDHBdsdanNK6uH0pJHRKjhp1mPcJ+rsNZTcK6jUBZp2eZ7BtRk9Fjotou1lTIZxGirmTHoc1glMKvA18+U84KJi1HkB0hAhIzmIUqaJZBFqObM0powfOG2SKvt89dzsFnT3lv0FJHB1E3VgUmm8aPjmLe+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vJjl4U9f9M1PlF8eJitKvYrLFSvKtD6pA1f7j8WURyE=; b=ewHCg7oejd/zfEgddej0VvnWs4ZdRiSjPsEpX/rkI/PkFKQIUpuhbMbx3xPLtxy3NZrFe0iYoQgiLVg1wzKwtNy3x9clcsc5Ffv5s2FZNqWAWTcPeQ47Kj1p/8D5O73gWPGHn603Zhz5VmCOpsNqq2fYIG3pA8JK0PsMrOMoO1OgibFx6WDCrBev8r3UjawVMUpikHaoi5A1VBR4Jfj+9w+y4csy/H1doP2iActpNtOB583m4x1f/gRQ8T+bWq/cXreRvfP0G1n1qxgHtd4f3C4lmj1eqjGuZk0fUMapba6ixOztCixXEtvKHMvP+NHtqsKbn9CQCrIIFxu/5vNDhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vJjl4U9f9M1PlF8eJitKvYrLFSvKtD6pA1f7j8WURyE=; b=duTruEg2/6R+suRMBEClvM9BzQnuHyvhg82W/zRjb/vAjAAX+IvJjyuuL4oRGexDgN5+qdKz7OiNHkO+izRGe5A2IwuLDVsCG2vzd2jy+jIbcrQytpN8xN9vvaDMjIBZbsAmlNT99t8c2B/9q6kp32HEhyQqY05cvdWvJhL4nJM= Received: from BN8PR04CA0014.namprd04.prod.outlook.com (2603:10b6:408:70::27) by SA0PR12MB7464.namprd12.prod.outlook.com (2603:10b6:806:24b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19; Thu, 2 Mar 2023 19:43:25 +0000 Received: from BN8NAM11FT072.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::5c) by BN8PR04CA0014.outlook.office365.com (2603:10b6:408:70::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 19:43:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT072.mail.protection.outlook.com (10.13.176.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:24 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:23 -0600 From: Mario Limonciello To: =?utf-8?b?SmFuIETEhWJyb8Wb?= , Grzegorz Bernacki , , , , Tom Lendacky , "John Allen" CC: Mario Limonciello , "David S. Miller" , , Subject: [PATCH v2 9/9] crypto: ccp: Add doorbell register offset Date: Thu, 2 Mar 2023 13:42:32 -0600 Message-ID: <20230302194235.1724-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT072:EE_|SA0PR12MB7464:EE_ X-MS-Office365-Filtering-Correlation-Id: ad3a6095-9a37-444f-d578-08db1b566325 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 194QTItssUZX4tv+aMk3Q7tp/R4wHYy16a4sy0kiHdHEVdwgaxeOFNNGaOzHZM+HH0YMMzzQ1BJGFj4q2VC/INGoAiF5accIEtt+2m8zWps7v8Oib3eyC9T0RdmBWB1pktsq1SnokS+Y9eCOy9MmPfJFcRxErlVVTxs3lMHyPMi52PsT0um+IygzfQvqAVeqsAowJUX+EvxUEDryTQG60OpN0ooVcgxqa16z9CegBPSxjcmzH0aC6bsqbI1kEGwA9KIhGKsuqGeGktHj14fsxIqZjDLo+EG+ieqv3uFtF1HOoLkSLNm+Nycv/msAAzfT6DBorwQYatAUtyY1TQ8Kc2j4CeFbgtZMSx4ctbYxbpxngQGVBTzGfmVVX9c9QMIqWT19fXKr03bEp1FQ0OHvDtH4DSQ4Q++5c+P9Cquzq14rx9tbF+HWc+/fVQz0lLWDIqJy3reLnzGSWcgt13Hl/xwZBXFBtF+No4+dQvyE2IrgxcUFi707rvsGWhur5N9TGrjFFia04Z92tHb9zZspHEtYZco+QEuiQbLv1Fve514/p38IEwfj6OiUynujprdCD+9dT1kRnuty9G05kI7OZcwEAWZvnZ3U2fSB9gjoFWqxr0HeMOYXG9m82rMwHDL9nNPwYOd1X2GU3zrdhkO66UkxdnI7rufbSznBEfiX29eejXmdyD5B6+Ubtl6FTlpsyCYwB0Dm63LA3XerlogT7s52yckokP585qdXXoL9yqE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(376002)(39860400002)(346002)(451199018)(36840700001)(40470700004)(46966006)(83380400001)(70206006)(36860700001)(47076005)(426003)(6666004)(40460700003)(36756003)(356005)(81166007)(8936002)(478600001)(5660300002)(82740400003)(86362001)(82310400005)(40480700001)(44832011)(2616005)(336012)(26005)(16526019)(186003)(966005)(1076003)(7696005)(4744005)(8676002)(70586007)(2906002)(41300700001)(316002)(110136005)(4326008)(6636002)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:24.7149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad3a6095-9a37-444f-d578-08db1b566325 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT072.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7464 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The PSP in Skyrim uses i2c arbitration with a doorbell. Add this offset so that the communication can work. Link: Link: https://lore.kernel.org/linux-i2c/20220916131854.687371-3-jsd@semihalf.com/ Signed-off-by: Mario Limonciello --- v1->v2: * New patch --- drivers/crypto/ccp/sp-pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 18aa902eb5ce..a4efcaee43d8 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -365,6 +365,7 @@ static const struct platform_access_vdata pa_v1 = { .cmdresp_reg = 0x10570, /* C2PMSG_28 */ .cmdbuff_addr_lo_reg = 0x10574, /* C2PMSG_29 */ .cmdbuff_addr_hi_reg = 0x10578, /* C2PMSG_30 */ + .doorbell_reg = 0x10a40, /* C2PMSG_80 */ }; static const struct psp_vdata pspv1 = {