From patchwork Fri May 19 03:24:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684043 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 13CA1C77B7A for ; Fri, 19 May 2023 17:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbjESR3n (ORCPT ); Fri, 19 May 2023 13:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbjESR3m (ORCPT ); Fri, 19 May 2023 13:29:42 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2075.outbound.protection.outlook.com [40.107.220.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0820E52; Fri, 19 May 2023 10:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LeCnaNHZ7WxrQzTS3iQjhN1TnAHC/WM7NFabKn2FxTo83Rk/QtuGENuDspwQXWcpEiDvdpk0SouPgBEDEDdS3vHQaG8STm6PL1i0UTAjNQR30h0CrWXccYNxHizB6gIHDOqWJ+JfHqFxaUMBkwuk00K0CwBC4p7M7lMiEo5ErLeMkpXoLQ49wthE6qhjRO45o9kDJeww1SoPwRcsXDiGyPvdv2AwacJjkAZz396sD/uxU22Lz2BPoeUPuW+ckOoBu7WxBMHCBRb9/0l9gjpdx5izXZeSLwRbhHlbzkxOFldP99uBkBbYaWCE0btIlDXXQhpkC1ELX7iNEReD8yW6vA== 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=McArOqsmUatZT0/1PIvPXrql42CsdIl3qB5N0XrfNIg=; b=RV3o2DvYBwQmFDFz56n76cTYmg4pf6or0kSIYeV1T6ySsFt+g5Bpx9D+gCY6g8IGyktOj+sydHRAHhG8xlHzLEOPAG0k1dWY2OipVctz3GVV3CrYWlKsj89yM6UxQ5yrXTxVFTN9o6YErRYXwPb9TAZ6YZAfr1JX0mYjEpY6kGjbW8sU3w6nm+uZuWWxpL/raVj/uuRvlYKmWmV8kzNtIbdrfxIdXK0uqAKa2ALi30J+tS8bQl5vRsbx88huzyTinI8RvvM4o5QOUs23VoK36fl60wtxSbbF1saG90coz1VSRKKK0LAP6ld7raUzPPWm5OkT6Hi5IW5G83JF5V/3FA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=McArOqsmUatZT0/1PIvPXrql42CsdIl3qB5N0XrfNIg=; b=e85q6l3hk8XXlVSlrcwgcoKb0xV9HP08Zfs0/IOKY8A9EXl47aBZ8ac2OGkI2E0Lfk7dVFiggLywrSdt0z9+n0THn5nErwQWzfATyw2TZDAlA7yEcOQuc4VEC98yG0gii344/mcd2qHfHDH1g2phJo1Ui8bivbfkW1IBiwom7os= Received: from DS7PR05CA0013.namprd05.prod.outlook.com (2603:10b6:5:3b9::18) by SA1PR12MB8859.namprd12.prod.outlook.com (2603:10b6:806:37c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:01 +0000 Received: from DM6NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::32) by DS7PR05CA0013.outlook.office365.com (2603:10b6:5:3b9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 17:29:01 +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 DM6NAM11FT079.mail.protection.outlook.com (10.13.173.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:01 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:28:58 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 01/10] crypto: ccp: Rename macro for security attributes Date: Thu, 18 May 2023 22:24:39 -0500 Message-ID: <20230519032448.94279-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT079:EE_|SA1PR12MB8859:EE_ X-MS-Office365-Filtering-Correlation-Id: 429cc0b5-f168-4ee6-2567-08db588e895b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zBaJb/hbPJI2UytMrXvrkML55kLb13wj/dvZHhXuUFYcJrwsMb0jbe9J9Z9xCMOB7GUxgmbruAeVmlTH4q4yMc8TOf38jBNUBdkWemw68/aQy3b8Y4Yfl9P0GGBSIXwr3k301N3v8w7EQnSgTC69FwlmATZPtmA06fVYpd/+v+wm0D3gL7rnZx97636n/SxfqeLUfAbl2VGiAQmvP1boexfIOHBOZPkUOc+n+VFCgeh+tLVo33qy3z2v/eny2Jh1z4dAinfMtlE7C8pqP2v5XmMb02n5QDnr/ymCLk5fAvBKQHPAjijKtoXnR4J5pTbW7hVykyn/mwS5kRGRTUvzHy9nYFTsVDFz54BYlNmfQ0BKNvTbPRXU3CbhauhcewrvqvzWbar/Hky8SjDzgiO+BkcBtXr5Pwz4BGuvQH1v/HK+AiMcrUGevVFokL4dIwx25Ag8eJan5LV6dSOmtCSvAbCir1WOHxYFTw5VOOJwMwTvjvDAbk4N766fi046oBH/1cjoaECjRlQ5a5YQmTyk9AdEOaLiBAVsDo5lCRtw13Sf79HnI8WmZ3ruHN9qzewAObnyzrp5TpJIxVtGWmdZmVDbwl17P4TxvADkVB5b8cJByN3r7ANx14rJmTxHxaI1ajz5QwOnkuDuQoqqWTwYzea6Uv8Cpbngfm2wLGYQDZTHbEUIAf4PxX89NoEdRC86qjXa/DrLNCDvN8U27cmYw/yhXo67RcASN0lbo5IUxtNcGmXxiU+sPaG0X1sohwhTXsUwyQ8W9rEU8LSgGF54og== 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:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(70206006)(70586007)(4326008)(110136005)(54906003)(82740400003)(8676002)(8936002)(40480700001)(478600001)(316002)(6666004)(41300700001)(7696005)(40460700003)(2906002)(86362001)(15650500001)(81166007)(356005)(26005)(44832011)(47076005)(2616005)(83380400001)(1076003)(36860700001)(186003)(426003)(336012)(36756003)(5660300002)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:01.5484 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 429cc0b5-f168-4ee6-2567-08db588e895b 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: DM6NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8859 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The attribute_show() macro is only valid for determining the availability of security related sysfs entries. Rename the macro to better show this relationship. Acked-by: Tom Lendacky Signed-off-by: Mario Limonciello --- v2->v3: * Pick up tag --- drivers/crypto/ccp/sp-pci.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index b603ad9b8341..c8f075a7f49f 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -32,7 +32,7 @@ struct sp_pci { }; static struct sp_device *sp_dev_master; -#define attribute_show(name, def) \ +#define security_attribute_show(name, def) \ static ssize_t name##_show(struct device *d, struct device_attribute *attr, \ char *buf) \ { \ @@ -42,24 +42,24 @@ static ssize_t name##_show(struct device *d, struct device_attribute *attr, \ return sysfs_emit(buf, "%d\n", (psp->capability & bit) > 0); \ } -attribute_show(fused_part, FUSED_PART) +security_attribute_show(fused_part, FUSED_PART) static DEVICE_ATTR_RO(fused_part); -attribute_show(debug_lock_on, DEBUG_LOCK_ON) +security_attribute_show(debug_lock_on, DEBUG_LOCK_ON) static DEVICE_ATTR_RO(debug_lock_on); -attribute_show(tsme_status, TSME_STATUS) +security_attribute_show(tsme_status, TSME_STATUS) static DEVICE_ATTR_RO(tsme_status); -attribute_show(anti_rollback_status, ANTI_ROLLBACK_STATUS) +security_attribute_show(anti_rollback_status, ANTI_ROLLBACK_STATUS) static DEVICE_ATTR_RO(anti_rollback_status); -attribute_show(rpmc_production_enabled, RPMC_PRODUCTION_ENABLED) +security_attribute_show(rpmc_production_enabled, RPMC_PRODUCTION_ENABLED) static DEVICE_ATTR_RO(rpmc_production_enabled); -attribute_show(rpmc_spirom_available, RPMC_SPIROM_AVAILABLE) +security_attribute_show(rpmc_spirom_available, RPMC_SPIROM_AVAILABLE) static DEVICE_ATTR_RO(rpmc_spirom_available); -attribute_show(hsp_tpm_available, HSP_TPM_AVAILABLE) +security_attribute_show(hsp_tpm_available, HSP_TPM_AVAILABLE) static DEVICE_ATTR_RO(hsp_tpm_available); -attribute_show(rom_armor_enforced, ROM_ARMOR_ENFORCED) +security_attribute_show(rom_armor_enforced, ROM_ARMOR_ENFORCED) static DEVICE_ATTR_RO(rom_armor_enforced); -static struct attribute *psp_attrs[] = { +static struct attribute *psp_security_attrs[] = { &dev_attr_fused_part.attr, &dev_attr_debug_lock_on.attr, &dev_attr_tsme_status.attr, @@ -83,13 +83,13 @@ static umode_t psp_security_is_visible(struct kobject *kobj, struct attribute *a return 0; } -static struct attribute_group psp_attr_group = { - .attrs = psp_attrs, +static struct attribute_group psp_security_attr_group = { + .attrs = psp_security_attrs, .is_visible = psp_security_is_visible, }; static const struct attribute_group *psp_groups[] = { - &psp_attr_group, + &psp_security_attr_group, NULL, }; From patchwork Fri May 19 03:24:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684776 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 94037C77B7A for ; Fri, 19 May 2023 17:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbjESRaQ (ORCPT ); Fri, 19 May 2023 13:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjESR3u (ORCPT ); Fri, 19 May 2023 13:29:50 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20630.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F3110D4; Fri, 19 May 2023 10:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WtHA6pCTX8HLx0rh5SWmSDAQUUFl3K4cLhlAP8dib2Cn2V7IBnoS3Qdg/RWXUSTqucQ6FbAaqVawFyb651zOmdTktGkVBrjIty3rlPviqggj/zwFvp9/Lzozb23QiKEEtJJs0IGjJv+hLuFDwg3g9PNpX1vT8QTUEKkBlC9oVGnGnafuI+DGSL1fEoPXUc2zQ9OjzibEDPmYv0Vp7H/JL4e6NZw9iX3rORgBU9wwFViNYxyDwmY5LxLOcpEl0pI37eBnQ27tRYQPbcfpStCufk7R+QP9b13I7d4F3kVNhNoNWqw5lVZQDOfgwgsybikYflT7ib3JZgmVEml0xKZ/3g== 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=fmmTnMcgBjF4jGvS3U3PBKUF7f02iPt5jZlaYir3rNw=; b=DuIKq/NHGeRffLGzw5BJAu0ssE5YPBfkVsoGcysgM+L3oVNvUGvMto6DeWk/xHKZxxCu57BeUyiX9iKSUa2uzF4Unt1myNOlIXdkXvAD3/7K9BDJj4JcPpvRow1SAhr73HyVxlKmzM5Zg+S4SMYY91eubmPDy05fxvk8hHKQgxNIC3fAxM9U9L4NS7v6mYH2hDCyVlrqeaSfq/OiX1U5fwzD7muDV9ZMKRgh3H8qKUmhinmdZO8mywfZ1B6UCDE3kuCqY6GP1t0zL0hiTCHDaloosmvs9U3KqTOwHKgS8tGOa69X9m3pshhHAo0e7UgQGNtC6KdxpzZBjbPoPmWnVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=fmmTnMcgBjF4jGvS3U3PBKUF7f02iPt5jZlaYir3rNw=; b=G6fpXJsO6LQ1+dt62xWjSMrKGkJQFmyZFBxp4boBDgbhV45CUSW9GV1X+PGbcvmZZmTeU48YNjXWIK9Yq7ixy7z/vqO21aHIeEvkJOwQXLbeHTsQVNTS63xBCzSIbV6v6DPl7GA28DUuRJF/wzyPufLIQFcM7twTTvHHWqCQOkI= Received: from DS7PR05CA0015.namprd05.prod.outlook.com (2603:10b6:5:3b9::20) by BY5PR12MB4998.namprd12.prod.outlook.com (2603:10b6:a03:1d4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:02 +0000 Received: from DM6NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::9a) by DS7PR05CA0015.outlook.office365.com (2603:10b6:5:3b9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17 via Frontend Transport; Fri, 19 May 2023 17:29:02 +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 DM6NAM11FT079.mail.protection.outlook.com (10.13.173.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:01 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:00 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 02/10] crypto: ccp: Add support for displaying PSP firmware versions Date: Thu, 18 May 2023 22:24:40 -0500 Message-ID: <20230519032448.94279-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT079:EE_|BY5PR12MB4998:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b6144a0-b669-46b4-83be-08db588e899b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bEqZHsS0w2MEuJ92GoRjWvcXFHCp61QR3IMoXsY3aqtXdwFhpzgd1d12bAWx1MozAPq94ALT2+ZRpPoDXhHX+ieWKhubxwvG0S+c9tXcgh2HfiTVDqU5OFiZJ/5xBtf3C2Q52AJG2GitwwX0SRCXTJkt2DyDXyWd43whgCm3mzcb4dvDjXnsPOwSqwoQdtAs8O1aKBBaLgyJOhSGwUA3gxgBbXII9bO6a4giyuUJGcBmwTkbCBUwqYIe7PjTfRdlCwDx7NXnXB69ldjG4GAmbQy4Z/8/NfxZVAt4MeOYNFpiKqMbXE/1eRPzLToUySPcp90atovzWBGpZ8xpLtc+YjXy7LtvOHBvAw0t8YocmRJqUJtWbmdFEVxde6CCC3WU1Ja1PXXmoi+8xef/eU29soK+Ud2S3761+LSfqrLhoOILHDY7W2iyyDPek1T+Bb76GaY7M97+Ru27tQZToYlsd64MjithpeXHiUM4jtjD9n5SzmYNT9z/PYvPAkNtxF3Iq6CQ6lxCGF30wcQL+jW7rzdIMNWOZ14jrPaW5QYGmBvG2n/crolwHhqx87aSu2r9+9XSHB21qBP83PlhCuvQ9ZarIIxmOdmf9OXOMNzo760y8DOAGWtVwUHUbUttz1nrHIDtaeOHeJW8wrbtdyoq7zSnEutG9IDqCCe/gEkoVqBUeUtYXrsamKQxfpcalnOePso2PKq2gEtKHD+OkhiLioze2eDerSwYTkqtmKR8gMcR+7XHnfHU0ijF8rNT0RGCywlC9B/2K+BOl9sxE1Pgtg== 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:(13230028)(4636009)(39860400002)(136003)(396003)(376002)(346002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(70206006)(70586007)(4326008)(110136005)(54906003)(82740400003)(8936002)(8676002)(40480700001)(478600001)(316002)(6666004)(41300700001)(7696005)(40460700003)(2906002)(86362001)(356005)(81166007)(26005)(1076003)(44832011)(47076005)(186003)(36756003)(336012)(82310400005)(426003)(36860700001)(5660300002)(2616005)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:01.9546 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b6144a0-b669-46b4-83be-08db588e899b 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: DM6NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4998 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org As it's not always obvious what PSP bootloader or TEE version are present in OEM systems, add the ability to get this information from sysfs for supported platforms. Acked-by: Tom Lendacky Signed-off-by: Mario Limonciello --- v2->v3: * Pick up tag v1->v2: * Move GENMASK declarations to top of the file * Add comment to support why checking for 0xffffffff --- Documentation/ABI/testing/sysfs-driver-ccp | 18 ++++++ drivers/crypto/ccp/sp-dev.h | 2 + drivers/crypto/ccp/sp-pci.c | 64 ++++++++++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-ccp b/Documentation/ABI/testing/sysfs-driver-ccp index 7aded9b75553..ee6b787eee7a 100644 --- a/Documentation/ABI/testing/sysfs-driver-ccp +++ b/Documentation/ABI/testing/sysfs-driver-ccp @@ -85,3 +85,21 @@ Description: Possible values: 0: Not enforced 1: Enforced + +What: /sys/bus/pci/devices//bootloader_version +Date: June 2023 +KernelVersion: 6.4 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//bootloader_version + file reports the firmware version of the AMD AGESA + bootloader. + +What: /sys/bus/pci/devices//tee_version +Date: June 2023 +KernelVersion: 6.4 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//tee_version + file reports the firmware version of the AMD Trusted + Execution Environment (TEE). diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 1253a0217985..76c32ee6bd65 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -51,6 +51,7 @@ struct tee_vdata { const unsigned int cmdbuff_addr_hi_reg; const unsigned int ring_wptr_reg; const unsigned int ring_rptr_reg; + const unsigned int info_reg; }; struct platform_access_vdata { @@ -69,6 +70,7 @@ struct psp_vdata { const unsigned int feature_reg; const unsigned int inten_reg; const unsigned int intsts_reg; + const unsigned int bootloader_info_reg; }; /* Structure to hold SP device data */ diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index c8f075a7f49f..6c93577950c7 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -8,6 +8,7 @@ * Author: Gary R Hook */ +#include #include #include #include @@ -24,6 +25,12 @@ #include "ccp-dev.h" #include "psp-dev.h" +/* used for version string AA.BB.CC.DD */ +#define AA GENMASK(31, 24) +#define BB GENMASK(23, 16) +#define CC GENMASK(15, 8) +#define DD GENMASK(7, 0) + #define MSIX_VECTORS 2 struct sp_pci { @@ -88,8 +95,65 @@ static struct attribute_group psp_security_attr_group = { .is_visible = psp_security_is_visible, }; +#define version_attribute_show(name, _offset) \ +static ssize_t name##_show(struct device *d, struct device_attribute *attr, \ + char *buf) \ +{ \ + struct sp_device *sp = dev_get_drvdata(d); \ + struct psp_device *psp = sp->psp_data; \ + unsigned int val = ioread32(psp->io_regs + _offset); \ + return sysfs_emit(buf, "%02lx.%02lx.%02lx.%02lx\n", \ + FIELD_GET(AA, val), \ + FIELD_GET(BB, val), \ + FIELD_GET(CC, val), \ + FIELD_GET(DD, val)); \ +} + +version_attribute_show(bootloader_version, psp->vdata->bootloader_info_reg) +static DEVICE_ATTR_RO(bootloader_version); +version_attribute_show(tee_version, psp->vdata->tee->info_reg) +static DEVICE_ATTR_RO(tee_version); + +static struct attribute *psp_firmware_attrs[] = { + &dev_attr_bootloader_version.attr, + &dev_attr_tee_version.attr, + NULL, +}; + +static umode_t psp_firmware_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + struct device *dev = kobj_to_dev(kobj); + struct sp_device *sp = dev_get_drvdata(dev); + struct psp_device *psp = sp->psp_data; + unsigned int val = 0xffffffff; + + if (!psp) + return 0; + + if (attr == &dev_attr_bootloader_version.attr && + psp->vdata->bootloader_info_reg) + val = ioread32(psp->io_regs + psp->vdata->bootloader_info_reg); + + if (attr == &dev_attr_tee_version.attr && + psp->capability & PSP_CAPABILITY_TEE && + psp->vdata->tee->info_reg) + val = ioread32(psp->io_regs + psp->vdata->tee->info_reg); + + /* If platform disallows accessing this register it will be all f's */ + if (val != 0xffffffff) + return 0444; + + return 0; +} + +static struct attribute_group psp_firmware_attr_group = { + .attrs = psp_firmware_attrs, + .is_visible = psp_firmware_is_visible, +}; + static const struct attribute_group *psp_groups[] = { &psp_security_attr_group, + &psp_firmware_attr_group, NULL, }; From patchwork Fri May 19 03:24:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684041 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 B0218C77B75 for ; Fri, 19 May 2023 17:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231448AbjESRaN (ORCPT ); Fri, 19 May 2023 13:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231500AbjESR3u (ORCPT ); Fri, 19 May 2023 13:29:50 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20615.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::615]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D77C710C9; Fri, 19 May 2023 10:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K26lTHZwOAZK3NxyqzOMyU3b/lclWaFB+kPijXEGT3KfqQhJrVZC0mPde+irfOErWb2liJlaHKLM4tyiFe01OxbrBQPVfRY+TT7hQ9fEFq0r00NgJ4oLGUNoz6Phfd7SJh5uJo2AIRVjz7dF7/EqP2MH0NwG72Fevc7sd4U9K2O9V7DZqNRMFq8d2JRl6AZ95pmMCSTBrmkmviDsMI/3ESL/2Mo2j67KAuGFZmplApw9vhI3+78y9k6axQb8f33XrmXGfQHljrg0jIV4tcAAlHaZH3iIdv3lspJ+zFVqQf4mt5rUV442DnsIOSczeQsF7spibLc9SCl4MjG2qhVh+g== 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=W82qJd2urM+ggblv7C0vROXQELzMMDGeNbobmssEdeY=; b=M7cn/ebLCWn0gtCxn/hzK3by4qcnCk2d9S6lSt71AkqHfNeVxBtizdDvSQZlxVosZf4uYcflfj1dSrcDmSYbVriQsk5l99kiMaDeyJAQzU/5JmC7PjH5BPzJLFQHdQHm29Mr68qZGwljsChtaTMWz93p7Uev6V1dkjBaPLSoV/oAVfsehbPZGVv8t/cTuk8Yg9cuaUdTLkoth+LBQMkk8CtKuTR0xAabUef5ePfEKsY7bci9NXzc1Ukj1jD6o9nMKKWXquzHwYjrqnobpa6Jwnaq1Loq1OE5rcSrBxSJG2zvYRvz7uI+cTVoRZODIvtYuDkzfmyoYi39pfSPx4wH0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=W82qJd2urM+ggblv7C0vROXQELzMMDGeNbobmssEdeY=; b=tq5SV1Pk5OgREH/RsJ5etNoOkPmDfEB4uDCFMTyqbeC5bXguoG+15pwbIT8YK0eng7hrcV0FHBaDhYkNVxR+CeujyFqGr3FnEGBST8DuKXPJpfMtdeDq64YaiRMFq0QTsqiHh8cVJliKO9CfudPplrsx0YKTMIK7fK1NKVWVm4E= Received: from DS7PR05CA0016.namprd05.prod.outlook.com (2603:10b6:5:3b9::21) by DS7PR12MB5741.namprd12.prod.outlook.com (2603:10b6:8:70::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:02 +0000 Received: from DM6NAM11FT079.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::20) by DS7PR05CA0016.outlook.office365.com (2603:10b6:5:3b9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.6 via Frontend Transport; Fri, 19 May 2023 17:29:02 +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 DM6NAM11FT079.mail.protection.outlook.com (10.13.173.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:02 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:01 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 03/10] crypto: ccp: Add bootloader and TEE version offsets Date: Thu, 18 May 2023 22:24:41 -0500 Message-ID: <20230519032448.94279-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT079:EE_|DS7PR12MB5741:EE_ X-MS-Office365-Filtering-Correlation-Id: 318f5943-bb26-4ca9-08ea-08db588e89e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YMyhXC9xrwAuE5ysFJUw4evH8Xyq5OG+EGin4KJxCQmY6xu3Pr3wfb+2vu/V+5ABv3rm+n6CL1nHrB4bDhP2BzsKnJUrloCzAara8oq/CgRIPqWzPey2KKqaSJ3NrLjuYw+dgp8hH0rO5kftTNYrCIGytvsnY3FY2lG/30ISGOt+tFE5tO7iS5SSZC6vFcHGSykMizngcDx6yLLK1agltSAEYJsQak4Cy5DwM3/jE/WM6pcN/0Uj3CGuTW+5QG1YgpYhPvbP297KH8DQcuFiZJsSz60rW3DOCvpINtCi57Cs4Glb3o+xq7wZw/1gwBo0Ec8aEn1N/0bdPXQrJXGJzYUb6Uk7LY6NQYkAOg3GzeM9MRkdQAY92RFj7VGa2Qp4giiGS9oKmqu++d5AhBOnY8aqd4za3dUUdM7x/BKhp4BqFKZcWvsNomdQRPnGPo7LunYcJQqKzu3eQl/KWtxfMwQzfqKiL27Y2PghYqhG4ZwZiVqQK84GgMwNh4n+B//JKMbm1HHraD5MI5gEHDLAe2lOzmR5oV5W2giXYtT/YoVDe3DXQxrCGqo/qfn/zJGM8czKUfhvNodrgflMAGKrrNBVpKv3QKL2tENv6sA2/YhIfyp4LBYropaxUtqRNdkY1CXP/MZA6AGysBCQoUFkBrM5P4xDVKeqiyjWQPCwk7HW3hh2IdmeR7z5CklfBf6QpQGl2V3+Cl8SvER/h8UQyExT5JePtR/G48FwU7yhxr+F+RMewQBwleu1q26IiAnS+3tYtkExa9cp8Hvv0/N3pQ== 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:(13230028)(4636009)(376002)(346002)(396003)(39860400002)(136003)(451199021)(36840700001)(40470700004)(46966006)(2906002)(16526019)(86362001)(186003)(70206006)(70586007)(26005)(1076003)(110136005)(36756003)(40480700001)(54906003)(478600001)(40460700003)(6666004)(7696005)(356005)(81166007)(82310400005)(2616005)(47076005)(336012)(41300700001)(426003)(44832011)(36860700001)(5660300002)(83380400001)(8676002)(8936002)(82740400003)(4326008)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:02.4233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 318f5943-bb26-4ca9-08ea-08db588e89e3 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: DM6NAM11FT079.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5741 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The bootloader and TEE versions are stored in registers that can be accessed from sysfs. This exports the information for recent client and datacenter parts. Acked-by: Tom Lendacky Signed-off-by: Mario Limonciello --- v2->v3: * Pick up tag --- drivers/crypto/ccp/sp-pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 6c93577950c7..205b93d229a9 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -423,6 +423,7 @@ static const struct tee_vdata teev1 = { .cmdbuff_addr_hi_reg = 0x1054c, /* C2PMSG_19 */ .ring_wptr_reg = 0x10550, /* C2PMSG_20 */ .ring_rptr_reg = 0x10554, /* C2PMSG_21 */ + .info_reg = 0x109e8, /* C2PMSG_58 */ }; static const struct tee_vdata teev2 = { @@ -448,6 +449,7 @@ static const struct platform_access_vdata pa_v2 = { static const struct psp_vdata pspv1 = { .sev = &sevv1, + .bootloader_info_reg = 0x105ec, /* C2PMSG_59 */ .feature_reg = 0x105fc, /* C2PMSG_63 */ .inten_reg = 0x10610, /* P2CMSG_INTEN */ .intsts_reg = 0x10614, /* P2CMSG_INTSTS */ @@ -455,6 +457,7 @@ static const struct psp_vdata pspv1 = { static const struct psp_vdata pspv2 = { .sev = &sevv2, + .bootloader_info_reg = 0x109ec, /* C2PMSG_59 */ .feature_reg = 0x109fc, /* C2PMSG_63 */ .inten_reg = 0x10690, /* P2CMSG_INTEN */ .intsts_reg = 0x10694, /* P2CMSG_INTSTS */ @@ -463,6 +466,7 @@ static const struct psp_vdata pspv2 = { static const struct psp_vdata pspv3 = { .tee = &teev1, .platform_access = &pa_v1, + .bootloader_info_reg = 0x109ec, /* C2PMSG_59 */ .feature_reg = 0x109fc, /* C2PMSG_63 */ .inten_reg = 0x10690, /* P2CMSG_INTEN */ .intsts_reg = 0x10694, /* P2CMSG_INTSTS */ @@ -471,6 +475,7 @@ static const struct psp_vdata pspv3 = { static const struct psp_vdata pspv4 = { .sev = &sevv2, .tee = &teev1, + .bootloader_info_reg = 0x109ec, /* C2PMSG_59 */ .feature_reg = 0x109fc, /* C2PMSG_63 */ .inten_reg = 0x10690, /* P2CMSG_INTEN */ .intsts_reg = 0x10694, /* P2CMSG_INTSTS */ From patchwork Fri May 19 03:24:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684038 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 01DC5C77B75 for ; Fri, 19 May 2023 17:30:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbjESRaw (ORCPT ); Fri, 19 May 2023 13:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbjESR3v (ORCPT ); Fri, 19 May 2023 13:29:51 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2053.outbound.protection.outlook.com [40.107.220.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3764D10E7; Fri, 19 May 2023 10:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DUXhncL4hRTJQSoYCPnpixnyLT2B66nZPHDQM0cDS4lAxRfo6INg3Ep55ecZkqQ3EF3mhRCzCOIEzQMTF/DfphihpLxsL9MQQz8ATGghd0TEyzSZQSAxYTX1kPSTz7nXr08V0Vyvo4+Lx7RJZ4qgljDqhTJzXBPxnATrcWUHN5wcYZXdl2dcP83alDQeV3xpOwqApGwrhERCRCF/u4b2RfXkS3Nx5/LDgLOxUzC8N3MdShBxVw6JdhDpDU1o/k09rRYSwnBRqhxxdJ07SGHS0VenEYMne20S0tnTB/laqK5v1vBJzojOZw2eTW1fBUC8ZB7xRWNWfR1C7ks36/u5eA== 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=uksMuvkHaQ2TyTvo4yDqIpiAZyC6gKRoWCNv996UReE=; b=AjihvanmZC5NfhJ+eFyGxuW0U39u13mtwRp8H1E6NfFoM4sKLOjZx06ulcnwrgZ2MRZ/nWAHjh4w84OJC+bEfEDkVDnlXcSEqFueGpMohLpII5oGeixrQdiyhYiX4WBI2CXsZPtDs1w9f5qF1r8r/a5G+rOyxlN1nAuH8LY1FZQjoWfjMbaU3dUgm+Xw71uLEGTRLmyMKemCUts88X8feb+Ymr65QYEw+3/htkRMeIV/fG0vv9EvkVEuSVyVPgkCeBABHOS0dhAr4RqUm3bjamES2KKN1t8JCZMkLVAKTxqCmY6lkRrgGnyhjibXsF2RSfi8c4ha8FTgDncBgA0Tvw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=uksMuvkHaQ2TyTvo4yDqIpiAZyC6gKRoWCNv996UReE=; b=gpNCo4eVVYGXBerMysK3ufe2rEPIUP1/pqHaBph7/SEcVEEN1sZjIrCpTs3V7qcS+GNqmIl3dyPaBw4HdiQvu8J2dqvmYPYVw8EgXFfme7VkFIwqD7+ZH1zyo+bStrY3awwLcxgz9zoIrN8csj6Xj0KbMiJXOp4Y0/ptJsuGZrE= Received: from DS7PR05CA0098.namprd05.prod.outlook.com (2603:10b6:8:56::8) by BY5PR12MB4886.namprd12.prod.outlook.com (2603:10b6:a03:1c5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 17:29:05 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::9f) by DS7PR05CA0098.outlook.office365.com (2603:10b6:8:56::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29: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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:03 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:02 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 04/10] crypto: ccp: move setting PSP master to earlier in the init Date: Thu, 18 May 2023 22:24:42 -0500 Message-ID: <20230519032448.94279-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|BY5PR12MB4886:EE_ X-MS-Office365-Filtering-Correlation-Id: 45473252-e1f4-46bb-97c6-08db588e8ab6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YtpNz7pXpJO4qUsWbrBKjiVPDCmfx5vN+bOgU9/LGUP4o51qJhOqbp2Es3+oEEkUo+wpfxJEo4uY8ghKaAoFNJgpMA1fS7aNH/M2+cs2diwJRBoqP0R6wuY6DBfNGKSF6SQFaqxNNQT6psmStNhtkcY/ETTo/twtvmodCxqyx8erBJXElurtGCWY7ULVKDDHBmyrpCUVpaqAk8daKpP/BgL2ZQJlJGS1QkhD0kawAnP/JNnyoRSNN9psxJgrkl3oRBe6FKOSOv/zCt2k1xf7aoo5qNnpfq36Gd/DeSd486RQh9PIR4d6G90naxUaZQNTxCBQkwO6wutXEzNIGlqog8fCiOs6irMCAFYGec+/pVf63NgMnB0pOZwXcm6PDMFCTDzXxtWd5Juw1XvrbJoA5JHRsdiVQ4xxCoVeAK/XTBYwieAtVKSO9iMvkpIx7+R0lVQyLVVcsHIT6koKNfhFC3eTM90tQtOQmPFg9M+vxowbgbDp77ed3Xbnl+6XooaDUN9zj2BzvWdsCUMJdoY5xQj/2oK7uEmlC03UL/frJNrOGbXGGofRApQonKuWG8211rrOFdK+WuT9ysYHsoLPMEqCy7V74+p10KcRrf54RchezlrLT93yuEXjPEUAbAIxpQvSph4JOZLk000hRI6Dg5r2vWcY5xhe/7DDLkudjxR+hH87FNJ3mJbNFaQ4u6TF2Cqhf2Rzx3KwxgnNSkkm12eupAhF1c7t5d6W2sQRNnO3F45bW2DLfy2Sf+Pt92GpXHAlaQeyw+hyJjnZ5sYgpQ== 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:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(6666004)(7696005)(41300700001)(44832011)(36756003)(1076003)(5660300002)(82310400005)(47076005)(186003)(83380400001)(426003)(336012)(2616005)(16526019)(26005)(86362001)(36860700001)(2906002)(356005)(81166007)(8936002)(40480700001)(8676002)(82740400003)(70206006)(4326008)(54906003)(70586007)(110136005)(478600001)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:03.8098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45473252-e1f4-46bb-97c6-08db588e8ab6 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4886 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Dynamic boost control needs to use platform access symbols that look for the PSP master as part of initialization. So move the PSP master before psp_init() so that dynamic boost control can be initialized properly. Signed-off-by: Mario Limonciello Reviewed-by: Tom Lendacky --- v2->v3: * Clean up master device if psp_init() failed --- drivers/crypto/ccp/psp-dev.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e3d6955d3265..3390f0bd6408 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -173,13 +173,14 @@ int psp_dev_init(struct sp_device *sp) goto e_err; } + /* master device must be set for platform access */ + if (psp->sp->set_psp_master_device) + psp->sp->set_psp_master_device(psp->sp); + ret = psp_init(psp); if (ret) goto e_irq; - if (sp->set_psp_master_device) - sp->set_psp_master_device(sp); - /* Enable interrupt */ iowrite32(-1, psp->io_regs + psp->vdata->inten_reg); @@ -188,6 +189,9 @@ int psp_dev_init(struct sp_device *sp) return 0; e_irq: + if (sp->clear_psp_master_device) + sp->clear_psp_master_device(sp); + sp_free_psp_irq(psp->sp, psp); e_err: sp->psp_data = NULL; From patchwork Fri May 19 03:24:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684042 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 8732FC7EE29 for ; Fri, 19 May 2023 17:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbjESRaN (ORCPT ); Fri, 19 May 2023 13:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbjESR3u (ORCPT ); Fri, 19 May 2023 13:29:50 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F8F10D2; Fri, 19 May 2023 10:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kQO/v8S9SgNjh7oq6165sleUwtbC0HHKufFd4V8y7/npPn5lAQz+uZIODVwMRrLf8PXUCtM8aPN0nYATGmB9W/L8yO+W7AMpRqkg/aYE7qSirTdeu5ApcrHGdpFBvQ2NFwEt0t7QMhjfW8Lx1eJptWe6zkvJpk7S546146iuDk/FsyGienbVeTa/gh7fIHeyFrGO0wR23wVhLzZYD6ZM+nQRnyeXDKdgWRp7bGxL1RxX4zuHFfqqD3zL5T0YzKH6bEjVdCeQ2qUAhFcIqXsqJv9S/K3CZJrwJX2M50oONTWHoJQdt9tdp/vRfDvNua8DN0eOJLAy3KObALNP8z0/pg== 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=0E/zhW87o3zuytWivtmejN7CvDwRrb3jSLk1a/a7Hso=; b=J9hB3XMJn70mvR9clG6Wr/oftvbii3uWYqgIsZukxrHYYL/o/dHhThJR8SOq4K3VEjjmq638aDjFGmontHUkifBjULE8WUeYcBz0q7H63c5Ij7G3FwxxNkfhmKKduBd1PA6igR11OOZu8uXP6vFFQ5QRQS20LshFONecbHIlulDET5hHvgsfyg9n7X33vEpxmkJMGTKOfTIWC1RDLqZ+ZNsKnbNwpWuX5HH+MmBLN4zZHPKNatmXYO20UkTWOi1I9kd0Oe2erAj0iVwWLfZeRrpT7Qwas49B14L34wn+Gw0E37S0wvrjl/bJZX8/Br3EUoKvsgyZnbTCkmgjfEy3lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=0E/zhW87o3zuytWivtmejN7CvDwRrb3jSLk1a/a7Hso=; b=F+sJujKsERJ+Dk+viLC+Bd/YsDPU2VdwHAiN9qj/4cFaDaQlhWzmPRjeJd8xjcj6Oy+LVR6OgCHxV9la3smrdD3Lwo7arvWqUcfP3a8yVpF4gM4uRcmebLqiZ/3GnNigUS0QnhCjH0/aMiAM5Y3kgGmf9eCi1kM9mMRBKhRgSlU= Received: from DS7PR05CA0095.namprd05.prod.outlook.com (2603:10b6:8:56::29) by CH2PR12MB4969.namprd12.prod.outlook.com (2603:10b6:610:68::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Fri, 19 May 2023 17:29:05 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::a4) by DS7PR05CA0095.outlook.office365.com (2603:10b6:8:56::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29: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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:05 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:03 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 05/10] crypto: ccp: Add support for fetching a nonce for dynamic boost control Date: Thu, 18 May 2023 22:24:43 -0500 Message-ID: <20230519032448.94279-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|CH2PR12MB4969:EE_ X-MS-Office365-Filtering-Correlation-Id: 7286d261-df64-4b62-4b0c-08db588e8bd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8eFbTNHzIZD4i83+dFOZN7KD7+M48V4Sd1/04x5mVjuX42bcaSh29nA/8L88nL+NQWT1GQ101Mm8CNl/fInU2EfY70KKZnVl8DrXjLlDNuaOs7zzgJOQDt8Pw+zY5F74/cxJ0e4YHR5bhHABcoCrPceUVMfmuVKbtgz2POV/YQpvqFNG8/3YYMHHTZQk4rWnJDycqNbzUARHZhf2xAQ+GO1ked/08op7SKXeQbY4S6zXA4p4itY5ENS4XhIX3a6a6HdevY9FNCyeuEwgC0toq6c9TGitHU72X/jq9y8Gank9e3lUn9OOnJ9SCJQQ578a98WXZDEHvTK5OKyPtzH3yN7mxPIdXCbrRDdE+VW6fEBFkPEUOkWB5fCJi0ZIO5ejtrUtWotMQTSDiHO4ZNs1RKNK0EW/k8gT/sIMkOvCZlH1pNyA6LP9cvYvf3QesoypjNUhkwr4eUoUkh57CIfyvSXiDwJ3kFw5uc4p2RNPrJTpKFqRXcf8nfisC2GeYX5rdWpKprD3rByM1ZeTPQS/enhG49+/EDLNt33Q/rJbXZAHriRjsZbTrlz1Z+hJ92eEFg28Wuf0DH3dSbJcbiIQjmzFU1PXXm2aLN9bnJuo/LeDwXqOHiMGy77vP9ZJvWIAb09SdlwT2O5/KXul9nOaFWA6wwlOaA+zcekXGFi/yjvzku70chdaP9DGHssi5Da1NOPnxBZ/G34YGyeS8YadJBP+kSKlkmfGgqHM9bZmdzJ1Np+QfVSoRY75feHex+nDSMEicnpHE4zMyb2KrUjhZQ== 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:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199021)(36840700001)(46966006)(40470700004)(7696005)(6666004)(70206006)(70586007)(4326008)(316002)(110136005)(478600001)(54906003)(66899021)(41300700001)(5660300002)(40460700003)(1076003)(44832011)(16526019)(26005)(40480700001)(186003)(8676002)(8936002)(30864003)(2906002)(2616005)(47076005)(83380400001)(36756003)(336012)(426003)(36860700001)(82740400003)(356005)(86362001)(81166007)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:05.6690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7286d261-df64-4b62-4b0c-08db588e8bd2 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4969 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Dynamic Boost Control is a feature offered on AMD client platforms that allows software to request and set power or frequency limits. Only software that has authenticated with the PSP can retrieve or set these limits. Create a character device and ioctl for fetching the nonce. This ioctl supports optionally passing authentication information which will influence how many calls the nonce is valid for. Signed-off-by: Mario Limonciello --- drivers/crypto/ccp/Makefile | 3 +- drivers/crypto/ccp/dbc.c | 191 ++++++++++++++++++++++++++++ drivers/crypto/ccp/dbc.h | 44 +++++++ drivers/crypto/ccp/psp-dev.c | 9 ++ drivers/crypto/ccp/psp-dev.h | 1 + drivers/crypto/ccp/sp-dev.h | 5 + drivers/crypto/ccp/sp-pci.c | 1 + include/linux/psp-platform-access.h | 1 + include/uapi/linux/psp-dbc.h | 67 ++++++++++ 9 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 drivers/crypto/ccp/dbc.c create mode 100644 drivers/crypto/ccp/dbc.h create mode 100644 include/uapi/linux/psp-dbc.h diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile index f6196495e862..aa0ba2d17e1e 100644 --- a/drivers/crypto/ccp/Makefile +++ b/drivers/crypto/ccp/Makefile @@ -11,7 +11,8 @@ ccp-$(CONFIG_PCI) += sp-pci.o ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \ sev-dev.o \ tee-dev.o \ - platform-access.o + platform-access.o \ + dbc.o obj-$(CONFIG_CRYPTO_DEV_CCP_CRYPTO) += ccp-crypto.o ccp-crypto-objs := ccp-crypto-main.o \ diff --git a/drivers/crypto/ccp/dbc.c b/drivers/crypto/ccp/dbc.c new file mode 100644 index 000000000000..7afeca903136 --- /dev/null +++ b/drivers/crypto/ccp/dbc.c @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * AMD Secure Processor Dynamic Boost Control interface + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello + */ + +#include "dbc.h" + +struct error_map { + u32 psp; + int ret; +}; + +#define DBC_ERROR_ACCESS_DENIED 0x0001 +#define DBC_ERROR_EXCESS_DATA 0x0004 +#define DBC_ERROR_BAD_PARAMETERS 0x0006 +#define DBC_ERROR_BAD_STATE 0x0007 +#define DBC_ERROR_NOT_IMPLEMENTED 0x0009 +#define DBC_ERROR_BUSY 0x000D +#define DBC_ERROR_MESSAGE_FAILURE 0x0307 +#define DBC_ERROR_OVERFLOW 0x300F +#define DBC_ERROR_SIGNATURE_INVALID 0x3072 + +static struct error_map error_codes[] = { + {DBC_ERROR_ACCESS_DENIED, -EACCES}, + {DBC_ERROR_EXCESS_DATA, -E2BIG}, + {DBC_ERROR_BAD_PARAMETERS, -EINVAL}, + {DBC_ERROR_BAD_STATE, -EAGAIN}, + {DBC_ERROR_MESSAGE_FAILURE, -ENOENT}, + {DBC_ERROR_NOT_IMPLEMENTED, -ENOENT}, + {DBC_ERROR_BUSY, -EBUSY}, + {DBC_ERROR_OVERFLOW, -ENFILE}, + {DBC_ERROR_SIGNATURE_INVALID, -EPERM}, + {0x0, 0x0}, +}; + +static int send_dbc_cmd(struct psp_dbc_device *dbc_dev, + enum psp_platform_access_msg msg) +{ + int ret; + + dbc_dev->mbox->req.header.status = 0; + ret = psp_send_platform_access_msg(msg, (struct psp_request *)dbc_dev->mbox); + if (ret == -EIO) { + int i; + + dev_dbg(dbc_dev->dev, + "msg 0x%x failed with PSP error: 0x%x\n", + msg, dbc_dev->mbox->req.header.status); + + for (i = 0; error_codes[i].psp; i++) { + if (dbc_dev->mbox->req.header.status == error_codes[i].psp) + return error_codes[i].ret; + } + } + + return ret; +} + +static int send_dbc_nonce(struct psp_dbc_device *dbc_dev) +{ + int ret; + + dbc_dev->mbox->req.header.payload_size = sizeof(dbc_dev->mbox->dbc_nonce); + ret = send_dbc_cmd(dbc_dev, PSP_DYNAMIC_BOOST_GET_NONCE); + if (ret == -EAGAIN) { + dev_dbg(dbc_dev->dev, "retrying get nonce\n"); + ret = send_dbc_cmd(dbc_dev, PSP_DYNAMIC_BOOST_GET_NONCE); + } + + return ret; +} + +void dbc_dev_destroy(struct psp_device *psp) +{ + struct psp_dbc_device *dbc_dev = psp->dbc_data; + + if (!dbc_dev) + return; + + misc_deregister(&dbc_dev->char_dev); + mutex_destroy(&dbc_dev->ioctl_mutex); + psp->dbc_data = NULL; +} + +static long dbc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +{ + struct psp_device *psp_master = psp_get_master_device(); + void __user *argp = (void __user *)arg; + struct psp_dbc_device *dbc_dev; + int ret; + + if (!psp_master || !psp_master->dbc_data) + return -ENODEV; + dbc_dev = psp_master->dbc_data; + + mutex_lock(&dbc_dev->ioctl_mutex); + + switch (cmd) { + case DBCIOCNONCE: + if (copy_from_user(&dbc_dev->mbox->dbc_nonce.user, argp, + sizeof(struct dbc_user_nonce))) { + ret = -EFAULT; + goto unlock; + } + + ret = send_dbc_nonce(dbc_dev); + if (ret) + goto unlock; + + if (copy_to_user(argp, &dbc_dev->mbox->dbc_nonce.user, + sizeof(struct dbc_user_nonce))) { + ret = -EFAULT; + goto unlock; + } + break; + default: + ret = -EINVAL; + + } +unlock: + mutex_unlock(&dbc_dev->ioctl_mutex); + + return ret; +} + +const struct file_operations dbc_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = dbc_ioctl, +}; + +int dbc_dev_init(struct psp_device *psp) +{ + struct device *dev = psp->dev; + struct psp_dbc_device *dbc_dev; + int ret; + + if (!PSP_FEATURE(psp, DBC)) + return 0; + + dbc_dev = devm_kzalloc(dev, sizeof(*dbc_dev), GFP_KERNEL); + if (!dbc_dev) + return -ENOMEM; + + BUILD_BUG_ON(sizeof(union dbc_buffer) > PAGE_SIZE); + dbc_dev->mbox = (void *)devm_get_free_pages(dev, GFP_KERNEL, 0); + if (!dbc_dev->mbox) { + ret = -ENOMEM; + goto cleanup_dev; + } + + psp->dbc_data = dbc_dev; + dbc_dev->dev = dev; + + ret = send_dbc_nonce(dbc_dev); + if (ret == -EACCES) { + dev_dbg(dbc_dev->dev, + "dynamic boost control was previously authenticated\n"); + ret = 0; + } + dev_dbg(dbc_dev->dev, "dynamic boost control is %savailable\n", + ret ? "un" : ""); + if (ret) { + ret = 0; + goto cleanup_mbox; + } + + dbc_dev->char_dev.minor = MISC_DYNAMIC_MINOR; + dbc_dev->char_dev.name = "dbc"; + dbc_dev->char_dev.fops = &dbc_fops; + dbc_dev->char_dev.mode = 0600; + ret = misc_register(&dbc_dev->char_dev); + if (ret) + goto cleanup_mbox; + + mutex_init(&dbc_dev->ioctl_mutex); + + return 0; + +cleanup_mbox: + devm_free_pages(dev, (unsigned long)dbc_dev->mbox); + +cleanup_dev: + psp->dbc_data = NULL; + devm_kfree(dev, dbc_dev); + + return ret; +} diff --git a/drivers/crypto/ccp/dbc.h b/drivers/crypto/ccp/dbc.h new file mode 100644 index 000000000000..1c3a0a078d15 --- /dev/null +++ b/drivers/crypto/ccp/dbc.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * AMD Platform Security Processor (PSP) Dynamic Boost Control support + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello + */ + +#ifndef __DBC_H__ +#define __DBC_H__ + +#include + +#include +#include +#include + +#include "psp-dev.h" + +struct psp_dbc_device { + struct device *dev; + + union dbc_buffer *mbox; + + struct mutex ioctl_mutex; + + struct miscdevice char_dev; +}; + +struct dbc_nonce { + struct psp_req_buffer_hdr header; + struct dbc_user_nonce user; +} __packed; + +union dbc_buffer { + struct psp_request req; + struct dbc_nonce dbc_nonce; +}; + +void dbc_dev_destroy(struct psp_device *psp); +int dbc_dev_init(struct psp_device *psp); + +#endif /* __DBC_H */ diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 3390f0bd6408..d42d7bc62352 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -15,6 +15,7 @@ #include "sev-dev.h" #include "tee-dev.h" #include "platform-access.h" +#include "dbc.h" struct psp_device *psp_master; @@ -112,6 +113,12 @@ static void psp_init_platform_access(struct psp_device *psp) dev_warn(psp->dev, "platform access init failed: %d\n", ret); return; } + + /* dbc must come after platform access as it tests the feature */ + ret = dbc_dev_init(psp); + if (ret) + dev_warn(psp->dev, "failed to init dynamic boost control: %d\n", + ret); } static int psp_init(struct psp_device *psp) @@ -217,6 +224,8 @@ void psp_dev_destroy(struct sp_device *sp) tee_dev_destroy(psp); + dbc_dev_destroy(psp); + platform_access_dev_destroy(psp); sp_free_psp_irq(sp, psp); diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index 505e4bdeaca8..8a4de69399c5 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -40,6 +40,7 @@ struct psp_device { void *sev_data; void *tee_data; void *platform_access_data; + void *dbc_data; unsigned int capability; }; diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 76c32ee6bd65..2329ad524b49 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -28,6 +28,10 @@ #define CACHE_NONE 0x00 #define CACHE_WB_NO_ALLOC 0xb7 +#define PLATFORM_FEATURE_DBC 0x1 + +#define PSP_FEATURE(psp, feat) (psp->vdata && psp->vdata->platform_features & PLATFORM_FEATURE_##feat) + /* Structure to hold CCP device data */ struct ccp_device; struct ccp_vdata { @@ -71,6 +75,7 @@ struct psp_vdata { const unsigned int inten_reg; const unsigned int intsts_reg; const unsigned int bootloader_info_reg; + const unsigned int platform_features; }; /* Structure to hold SP device data */ diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 205b93d229a9..b6ab56abeb68 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -470,6 +470,7 @@ static const struct psp_vdata pspv3 = { .feature_reg = 0x109fc, /* C2PMSG_63 */ .inten_reg = 0x10690, /* P2CMSG_INTEN */ .intsts_reg = 0x10694, /* P2CMSG_INTSTS */ + .platform_features = PLATFORM_FEATURE_DBC, }; static const struct psp_vdata pspv4 = { diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h index 75da8f5f7ad8..53b4a1df5180 100644 --- a/include/linux/psp-platform-access.h +++ b/include/linux/psp-platform-access.h @@ -8,6 +8,7 @@ enum psp_platform_access_msg { PSP_CMD_NONE = 0x0, PSP_I2C_REQ_BUS_CMD = 0x64, + PSP_DYNAMIC_BOOST_GET_NONCE, }; struct psp_req_buffer_hdr { diff --git a/include/uapi/linux/psp-dbc.h b/include/uapi/linux/psp-dbc.h new file mode 100644 index 000000000000..d032f78934e2 --- /dev/null +++ b/include/uapi/linux/psp-dbc.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ +/* + * Userspace interface for AMD Dynamic Boost Control (DBC) + * + * Copyright (C) 2023 Advanced Micro Devices, Inc. + * + * Author: Mario Limonciello + */ + +#ifndef __PSP_DBC_USER_H__ +#define __PSP_DBC_USER_H__ + +#include + +/** + * DOC: AMD Dynamic Boost Control (DBC) interface + */ + +#define DBC_NONCE_SIZE 16 +#define DBC_SIG_SIZE 32 + +/** + * struct dbc_user_nonce - Nonce exchange structure (input/output). + * @auth_needed: Whether the PSP should authenticate this request (input). + * 0: no authentication, PSP will return single use nonce. + * 1: authentication: PSP will return multi-use nonce. + * @nonce: 8 byte value used for future authentication (output). + * @signature: Optional 32 byte signature created by software using a + * previous nonce (input). + */ +struct dbc_user_nonce { + __u32 auth_needed; + __u8 nonce[DBC_NONCE_SIZE]; + __u8 signature[DBC_SIG_SIZE]; +} __packed; + +/** + * Dynamic Boost Control (DBC) IOC + * + * possible return codes for all DBC IOCTLs: + * 0: success + * -EINVAL: invalid input + * -E2BIG: excess data passed + * -EFAULT: failed to copy to/from userspace + * -EBUSY: mailbox in recovery or in use + * -ENODEV: driver not bound with PSP device + * -EACCES: request isn't authorized + * -EINVAL: invalid parameter + * -ETIMEDOUT: request timed out + * -EAGAIN: invalid request for state machine + * -ENOENT: not implemented + * -ENFILE: overflow + * -EPERM: invalid signature + * -EIO: unknown error + */ +#define DBC_IOC_TYPE 'D' + +/** + * DBCIOCNONCE - Fetch a nonce from the PSP for authenticating commands. + * If a nonce is fetched without authentication it can only + * be utilized for one command. + * If a nonce is fetched with authentication it can be used + * for multiple requests. + */ +#define DBCIOCNONCE _IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce) + +#endif /* __PSP_DBC_USER_H__ */ From patchwork Fri May 19 03:24:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684777 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 BE6D7C7EE2E for ; Fri, 19 May 2023 17:30:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbjESRaO (ORCPT ); Fri, 19 May 2023 13:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbjESR3v (ORCPT ); Fri, 19 May 2023 13:29:51 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2074.outbound.protection.outlook.com [40.107.96.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF92810E6; Fri, 19 May 2023 10:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UHZrWaW6PV0xS4OPG/fTj5zujrEuwjEhWrtYfXfiPSeEofgXwetnRbfIagb957oWvxnIvnF3LVFc5syDgkk/7VgyuawnlDd4XmZldijMs+n79DgEN1hU7d4iqdGwDwvTnJWJdwL9JWRIN4PrPkwziX9KY1ACrBzLz/ZTIGi6t34YcI7n5xF1vdRoSa/eG5VjhDH969LwHXNy4MLlZ2xv9BxRvYL9P9rID2mwTOwMYjQZ1nfCFJmY4eUwvNeSpj42DLyvftKMMZEwgF27btyuR6fzncTkJA/JOXDVh8R1aLL3//fFFiD3eJrFDNeucIpmmgtDjcpPZ4oRZgOs5nR50A== 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=bdJT8NGzTdhfAe7TuVGd6FYb32oOl+oCsBjc9y2oR04=; b=gCW1VBippQRyYZibfkjMkv+O+X+MjID0JIMKg4B6I06N2PIj8wZ33I+ZfSMOTROIR9cAZlcqUl5VCh8BjxlEDuH7a9WHd92Y0XNSt+qcYBmVvZNCj36pnj3zOjelUUtnWLFOyWvYOcPybE7HHaG6JO/k7V8eH4830yjaS2wb3DD/kup/OL6/l+A9EXXTWhWksODGNSEjPs45MEuAESyufn1aXzNCCUSYz9f0+Rm5n/E1NgfvXSh5uaPmm/6ozO+LB1iEGEGRoKiQQSys/XcBxONeXC7CAyDN5qG5k87oXHEQ9lY8WI+FFRQ+UazxDrJtx8j6ELwI3usOsKhaYDampA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=bdJT8NGzTdhfAe7TuVGd6FYb32oOl+oCsBjc9y2oR04=; b=TWJHE0TMOk43X5NMJVnjH00ESJ0OlyjAsjZ5UNJQzaEoIPbS96IVL6qZCkeB555oamrH7lTIyEhuuF3873SivaLBzFps+GWupVpyPaK2y8UR+tUMqZGNzga+ew99JbDVLW5++y60/4jiV6ReKde0jP226aLl5AXLUlOK2IV0FDU= Received: from DS7PR05CA0104.namprd05.prod.outlook.com (2603:10b6:8:56::16) by PH0PR12MB5607.namprd12.prod.outlook.com (2603:10b6:510:142::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:06 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::1a) by DS7PR05CA0104.outlook.office365.com (2603:10b6:8:56::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29:06 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:06 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:04 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 06/10] crypto: ccp: Add support for setting user ID for dynamic boost control Date: Thu, 18 May 2023 22:24:44 -0500 Message-ID: <20230519032448.94279-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|PH0PR12MB5607:EE_ X-MS-Office365-Filtering-Correlation-Id: 02f8b4e9-db03-4f7b-905e-08db588e8c5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1MWCTCQ0JpnQNv652O/974rpsYHUA77PBzB2tapZ/exex671Dhxw+SQPWvS4FR5725jOJn1RRuGbC8ml3ZQyRJM7GQQ+fNp1bjsb0OknMpPw5uTBqrUGhrad7gXDuO4TlfxBhL57krNMti0NW75Vuib3YvpGr5drQlSmaBMnWbUfRvOaPsQfKElh4c2kXVBe45nPCIfU6HRyOFN7cI/xmuTgF23NgHa5Luu4qRRo13BgCC28HqEyb1HXw5FE044iQWuhRBXiJ1XwA7I7hxRYYKj4qr/6QdUW4J2Xjz7lxUaYlk9atDh5iSOGJu/E8DnOlTpkMeAc/MSIVhnH1NWmOmB0gLWhnDu+Kj/pvjgFzoFVsoHqeDAOyK2iwGYwuG1nzXpNmYSU3RwDDsqEucyIYqY6dFdfktpptFOurK3PC2mT3kfOvRymxU8wPXARiSgv2L487RSlDawQFq0K70sqputVb6Ps7NKvdeqHwBpVfWhKUphYtVwX1SmuOCxpO4gk+Z9XIsi9Iatwi6pe9BO8YCH2iuB+nIQiIYxYFBltK/cA6lyHcRxQ/AMnA2k9w8rhPI1sDJvvcm6M2wB8wdTmXacEJ0ZdifOk/vVZPFYbAo13qlf+XMC5dqKaCxfugXurSZ0MISIre0eYgsZV6L62UXyuzl5AODK+UWBDkN/ncmp7kPpS6k9lcEE5EXuQBgb3P1tH4CIHjhpx2cGYPWDzMjjIFXy5OiKt8GK8OAo9+3lBCaES4ulSre2qYgzEyUuUUmXZO0mz9vY3R9gatviJVA== 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:(13230028)(4636009)(396003)(346002)(136003)(39860400002)(376002)(451199021)(40470700004)(46966006)(36840700001)(16526019)(70206006)(70586007)(4326008)(110136005)(54906003)(82740400003)(8676002)(8936002)(40480700001)(478600001)(316002)(6666004)(41300700001)(7696005)(40460700003)(2906002)(86362001)(81166007)(356005)(26005)(44832011)(47076005)(2616005)(83380400001)(1076003)(36860700001)(186003)(426003)(336012)(36756003)(5660300002)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:06.5752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02f8b4e9-db03-4f7b-905e-08db588e8c5c 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5607 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org As part of the authentication flow for Dynamic Boost Control, the calling software will need to send a uid used in all of its future communications. Add support for another IOCTL call to let userspace software set this up. Signed-off-by: Mario Limonciello --- v1->v2: * Update commit message --- drivers/crypto/ccp/dbc.c | 18 ++++++++++++++++++ drivers/crypto/ccp/dbc.h | 6 ++++++ include/linux/psp-platform-access.h | 1 + include/uapi/linux/psp-dbc.h | 20 ++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/drivers/crypto/ccp/dbc.c b/drivers/crypto/ccp/dbc.c index 7afeca903136..ca7ec528536b 100644 --- a/drivers/crypto/ccp/dbc.c +++ b/drivers/crypto/ccp/dbc.c @@ -117,6 +117,24 @@ static long dbc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto unlock; } break; + case DBCIOCUID: + dbc_dev->mbox->req.header.payload_size = sizeof(dbc_dev->mbox->dbc_set_uid); + if (copy_from_user(&dbc_dev->mbox->dbc_set_uid.user, argp, + sizeof(struct dbc_user_setuid))) { + ret = -EFAULT; + goto unlock; + } + + ret = send_dbc_cmd(dbc_dev, PSP_DYNAMIC_BOOST_SET_UID); + if (ret) + goto unlock; + + if (copy_to_user(argp, &dbc_dev->mbox->dbc_set_uid.user, + sizeof(struct dbc_user_setuid))) { + ret = -EFAULT; + goto unlock; + } + break; default: ret = -EINVAL; diff --git a/drivers/crypto/ccp/dbc.h b/drivers/crypto/ccp/dbc.h index 1c3a0a078d15..156435100076 100644 --- a/drivers/crypto/ccp/dbc.h +++ b/drivers/crypto/ccp/dbc.h @@ -33,9 +33,15 @@ struct dbc_nonce { struct dbc_user_nonce user; } __packed; +struct dbc_set_uid { + struct psp_req_buffer_hdr header; + struct dbc_user_setuid user; +} __packed; + union dbc_buffer { struct psp_request req; struct dbc_nonce dbc_nonce; + struct dbc_set_uid dbc_set_uid; }; void dbc_dev_destroy(struct psp_device *psp); diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h index 53b4a1df5180..18b9e0f0cb03 100644 --- a/include/linux/psp-platform-access.h +++ b/include/linux/psp-platform-access.h @@ -9,6 +9,7 @@ enum psp_platform_access_msg { PSP_CMD_NONE = 0x0, PSP_I2C_REQ_BUS_CMD = 0x64, PSP_DYNAMIC_BOOST_GET_NONCE, + PSP_DYNAMIC_BOOST_SET_UID, }; struct psp_req_buffer_hdr { diff --git a/include/uapi/linux/psp-dbc.h b/include/uapi/linux/psp-dbc.h index d032f78934e2..7443c78ede19 100644 --- a/include/uapi/linux/psp-dbc.h +++ b/include/uapi/linux/psp-dbc.h @@ -18,6 +18,7 @@ #define DBC_NONCE_SIZE 16 #define DBC_SIG_SIZE 32 +#define DBC_UID_SIZE 16 /** * struct dbc_user_nonce - Nonce exchange structure (input/output). @@ -34,6 +35,16 @@ struct dbc_user_nonce { __u8 signature[DBC_SIG_SIZE]; } __packed; +/** + * struct dbc_user_setuid - UID exchange structure (input). + * @uid: 16 byte value representing software identity + * @signature: 32 byte signature created by software using a previous nonce + */ +struct dbc_user_setuid { + __u8 uid[DBC_UID_SIZE]; + __u8 signature[DBC_SIG_SIZE]; +} __packed; + /** * Dynamic Boost Control (DBC) IOC * @@ -64,4 +75,13 @@ struct dbc_user_nonce { */ #define DBCIOCNONCE _IOWR(DBC_IOC_TYPE, 0x1, struct dbc_user_nonce) +/** + * DBCIOCUID - Set the user ID (UID) of a calling process. + * The user ID is 8 bytes long. It must be programmed using a + * 32 byte signature built using the nonce fetched from + * DBCIOCNONCE. + * The UID can only be set once until the system is rebooted. + */ +#define DBCIOCUID _IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid) + #endif /* __PSP_DBC_USER_H__ */ From patchwork Fri May 19 03:24:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684775 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 567E2C77B75 for ; Fri, 19 May 2023 17:30:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbjESRaR (ORCPT ); Fri, 19 May 2023 13:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231702AbjESR3x (ORCPT ); Fri, 19 May 2023 13:29:53 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2C610F0; Fri, 19 May 2023 10:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bjz2RJ4Q28cksrrJankz+O/I2b0n8f/jB6i20wkZENDESsKByX01o5PsdEHQmMM1Som0ldMGVOaN+6/kRYSpIr/CjhBMzgEFHNr5ZeTmInk0pyMG5DkGH3tUlESkMwixQL/GjnONRcEnrOYgULxpDR/S/NEfwmOx6x7/hwVe3EZVH7pqXBh8tOlWOWRAPBgq+0EwWCu8VJoXfvEYjwEyLclvDYtUgx6Z2lJF4i/jv9z61Ei5VKEIp4uteMXGU3D4N7UItTIsW1EDimfO7hx/AOw6rCj93HHyCgwnKCmx0xZJyy51usUnOna0fEGAMiLnvvAvaLX04N8l1s3IyIXBpg== 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=aS8JSioac+K5cQTdnoc+oQ3hySJkWDuNq/W398kLq/w=; b=nWn/NYlcEpvZEP4uWZ/U/wbG5iMdV7RSgS0aki81Y3bkluoDkSIR/wYKI4KcZKkTl3lyYWPBQcIeM/9TQimi/NU4Gl8yex90AhV1+8SXM0nvWCGfTBID9TDOPK5MCeGFTdh6ichmcKSeyB6dt2VWzdYLj4jZ/EVaY73SsZlNGVWH7xiQh54M03/CVn/Jz3cZy33yT1BoXAYpUmGo7V2kLYHaNWxwNPqqEbDegAL7prDBaO1MIdCcrUHr+7Sa/Rc8wV4FIz5N5xXYdz/cs8twB9D4uk0L2wy2XkOb1PA2sgiHN+nnG8Gvfn0Qeq7rQy5PyNFY5JWQeHhx9VtxSdHyzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=aS8JSioac+K5cQTdnoc+oQ3hySJkWDuNq/W398kLq/w=; b=5iYi602Jovqe9+n+uhA7mvYkrQu8XvsF0puaDikTHa+Dn5JBN770vcpG329hSDs5jPdaA/hjIq8LKDXAREsuQSvtSqjtQ7ickc2DtPHbz8frpGjomK1SKArCi5PUwZ9i4iuweOaqYUDso9LQ1PZm4XHlMjF2amLVDVzPGwAYegs= Received: from DS7PR05CA0085.namprd05.prod.outlook.com (2603:10b6:8:56::15) by BL3PR12MB9051.namprd12.prod.outlook.com (2603:10b6:208:3ba::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:07 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::6f) by DS7PR05CA0085.outlook.office365.com (2603:10b6:8:56::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29:07 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:07 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:05 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 07/10] crypto: ccp: Add support for getting and setting DBC parameters Date: Thu, 18 May 2023 22:24:45 -0500 Message-ID: <20230519032448.94279-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|BL3PR12MB9051:EE_ X-MS-Office365-Filtering-Correlation-Id: aeadc324-9aa3-45f3-0126-08db588e8cb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o5Mar65pjOwErDzPxMMu8IrUpKRBPG55GDgslCwLxPfJNh/ATdW1x5fsrtXaxqLX5pv8UrIQLxHuKNQm+nBWpiQxWfY2l/ErOHqp//XPgLcLTxs0bnaWKnMrN/SYb9PyYNRRtXFTLmnoe1S541+ykVibO+061jw2x64n/L98PfWU9Pk7UmoALezJEu+RUQzMbuIiDpAYFWmf5xp+OsPILOPbHeyjmHtdweqFZ2piqB2dG6MSt+YriMachZXkSDmLwcVaKELLYFipf15jc8BZ76QMPhByyQ0MqxwDKh3ZfXke21jfXtmjubODg0ddm2r3JeCeTd9U5QiPTJHA5Id+ISNtZYn6fohFw8gW0LY4ceXfQ3T8cUOq/Ig0T9XlhKuRBGGi9awp0wrOiJTmmkMvF2ahZJtIuYPtzteUeaZXsUky0XPq1gQ2egoY5jzSKYaw4NgnswpD8AShb4o1hDMtx237INpKvf+7fw8eJ5JhuHiQMJ/YD4UfO/u6T44jrx1+fvvClSrrj6sAtHTU7bYWNTfKn2dFUiV92hmJ6cB86e7BNCBVkyrrLneyu6//Mc2IWJUSIJOb8ZwF48XrtHpSmHjuDnmLddHVp5YeQOj9PANZX8087PcTdXo3ejvVGh2m9w6G5UrH2RMz+jCRoOGx3DqTEW3vx/uQQaSfynNzqsrvKEEXwPcq7kRq2+enp5KDY9x7+ydVfqf4EZsLH7uMsdDj/Sc3/qMC47uI9/RPjJeWfSugA7iilR9bj4G6sZ/SALnQfJdjuw2wBaA3ArQcZA== 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:(13230028)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199021)(46966006)(40470700004)(36840700001)(70206006)(70586007)(4326008)(82740400003)(8676002)(8936002)(40480700001)(316002)(110136005)(54906003)(478600001)(41300700001)(7696005)(6666004)(40460700003)(86362001)(2906002)(81166007)(356005)(26005)(36756003)(1076003)(44832011)(36860700001)(186003)(336012)(82310400005)(16526019)(426003)(47076005)(5660300002)(2616005)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:07.1221 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aeadc324-9aa3-45f3-0126-08db588e8cb0 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB9051 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org After software has authenticated a dynamic boost control request, it can fetch and set supported parameters using a selection of messages. Add support for these messages and export the ability to do this to userspace. Signed-off-by: Mario Limonciello --- drivers/crypto/ccp/dbc.c | 41 ++++++++++++++++++++ drivers/crypto/ccp/dbc.h | 6 +++ include/linux/psp-platform-access.h | 2 + include/uapi/linux/psp-dbc.h | 60 +++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) diff --git a/drivers/crypto/ccp/dbc.c b/drivers/crypto/ccp/dbc.c index ca7ec528536b..89976d6b9109 100644 --- a/drivers/crypto/ccp/dbc.c +++ b/drivers/crypto/ccp/dbc.c @@ -74,6 +74,30 @@ static int send_dbc_nonce(struct psp_dbc_device *dbc_dev) return ret; } +static int send_dbc_parameter(struct psp_dbc_device *dbc_dev) +{ + dbc_dev->mbox->req.header.payload_size = sizeof(dbc_dev->mbox->dbc_param); + + switch (dbc_dev->mbox->dbc_param.user.msg_index) { + case PARAM_SET_FMAX_CAP: + case PARAM_SET_PWR_CAP: + case PARAM_SET_GFX_MODE: + return send_dbc_cmd(dbc_dev, PSP_DYNAMIC_BOOST_SET_PARAMETER); + case PARAM_GET_FMAX_CAP: + case PARAM_GET_PWR_CAP: + case PARAM_GET_CURR_TEMP: + case PARAM_GET_FMAX_MAX: + case PARAM_GET_FMAX_MIN: + case PARAM_GET_SOC_PWR_MAX: + case PARAM_GET_SOC_PWR_MIN: + case PARAM_GET_SOC_PWR_CUR: + case PARAM_GET_GFX_MODE: + return send_dbc_cmd(dbc_dev, PSP_DYNAMIC_BOOST_GET_PARAMETER); + } + + return -EINVAL; +} + void dbc_dev_destroy(struct psp_device *psp) { struct psp_dbc_device *dbc_dev = psp->dbc_data; @@ -135,6 +159,23 @@ static long dbc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto unlock; } break; + case DBCIOCPARAM: + if (copy_from_user(&dbc_dev->mbox->dbc_param.user, argp, + sizeof(struct dbc_user_param))) { + ret = -EFAULT; + goto unlock; + } + + ret = send_dbc_parameter(dbc_dev); + if (ret) + goto unlock; + + if (copy_to_user(argp, &dbc_dev->mbox->dbc_param.user, + sizeof(struct dbc_user_param))) { + ret = -EFAULT; + goto unlock; + } + break; default: ret = -EINVAL; diff --git a/drivers/crypto/ccp/dbc.h b/drivers/crypto/ccp/dbc.h index 156435100076..e963099ca38e 100644 --- a/drivers/crypto/ccp/dbc.h +++ b/drivers/crypto/ccp/dbc.h @@ -38,10 +38,16 @@ struct dbc_set_uid { struct dbc_user_setuid user; } __packed; +struct dbc_param { + struct psp_req_buffer_hdr header; + struct dbc_user_param user; +} __packed; + union dbc_buffer { struct psp_request req; struct dbc_nonce dbc_nonce; struct dbc_set_uid dbc_set_uid; + struct dbc_param dbc_param; }; void dbc_dev_destroy(struct psp_device *psp); diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h index 18b9e0f0cb03..c1dc87fc536b 100644 --- a/include/linux/psp-platform-access.h +++ b/include/linux/psp-platform-access.h @@ -10,6 +10,8 @@ enum psp_platform_access_msg { PSP_I2C_REQ_BUS_CMD = 0x64, PSP_DYNAMIC_BOOST_GET_NONCE, PSP_DYNAMIC_BOOST_SET_UID, + PSP_DYNAMIC_BOOST_GET_PARAMETER, + PSP_DYNAMIC_BOOST_SET_PARAMETER, }; struct psp_req_buffer_hdr { diff --git a/include/uapi/linux/psp-dbc.h b/include/uapi/linux/psp-dbc.h index 7443c78ede19..b3845a9ff5fd 100644 --- a/include/uapi/linux/psp-dbc.h +++ b/include/uapi/linux/psp-dbc.h @@ -45,6 +45,23 @@ struct dbc_user_setuid { __u8 signature[DBC_SIG_SIZE]; } __packed; +/** + * struct dbc_user_param - Parameter exchange structure (input/output). + * @msg_index: Message indicating what parameter to set or get (input) + * @param: 4 byte parameter, units are message specific. (input/output) + * @signature: 32 byte signature. + * - When sending a message this is to be created by software + * using a previous nonce (input) + * - For interpreting results, this signature is updated by the + * PSP to allow software to validate the authenticity of the + * results. + */ +struct dbc_user_param { + __u32 msg_index; + __u32 param; + __u8 signature[DBC_SIG_SIZE]; +} __packed; + /** * Dynamic Boost Control (DBC) IOC * @@ -84,4 +101,47 @@ struct dbc_user_setuid { */ #define DBCIOCUID _IOW(DBC_IOC_TYPE, 0x2, struct dbc_user_setuid) +/** + * DBCIOCPARAM - Set or get a parameter from the PSP. + * This request will only work after DBCIOCUID has successfully + * set the UID of the calling process. + * Whether the parameter is set or get is controlled by the + * message ID in the request. + * This command must be sent using a 32 byte signature built + * using the nonce fetched from DBCIOCNONCE. + * When the command succeeds, the 32 byte signature will be + * updated by the PSP for software to authenticate the results. + */ +#define DBCIOCPARAM _IOWR(DBC_IOC_TYPE, 0x3, struct dbc_user_param) + +/** + * enum dbc_cmd_msg - Messages utilized by DBCIOCPARAM + * @PARAM_GET_FMAX_CAP: Get frequency cap (MHz) + * @PARAM_SET_FMAX_CAP: Set frequency cap (MHz) + * @PARAM_GET_PWR_CAP: Get socket power cap (mW) + * @PARAM_SET_PWR_CAP: Set socket power cap (mW) + * @PARAM_GET_GFX_MODE: Get graphics mode (0/1) + * @PARAM_SET_GFX_MODE: Set graphics mode (0/1) + * @PARAM_GET_CURR_TEMP: Get current temperature (degrees C) + * @PARAM_GET_FMAX_MAX: Get maximum allowed value for frequency (MHz) + * @PARAM_GET_FMAX_MIN: Get minimum allowed value for frequency (MHz) + * @PARAM_GET_SOC_PWR_MAX: Get maximum allowed value for SoC power (mw) + * @PARAM_GET_SOC_PWR_MIN: Get minimum allowed value for SoC power (mw) + * @PARAM_GET_SOC_PWR_CUR: Get current value for SoC Power (mW) + */ +enum dbc_cmd_msg { + PARAM_GET_FMAX_CAP = 0x3, + PARAM_SET_FMAX_CAP = 0x4, + PARAM_GET_PWR_CAP = 0x5, + PARAM_SET_PWR_CAP = 0x6, + PARAM_GET_GFX_MODE = 0x7, + PARAM_SET_GFX_MODE = 0x8, + PARAM_GET_CURR_TEMP = 0x9, + PARAM_GET_FMAX_MAX = 0xA, + PARAM_GET_FMAX_MIN = 0xB, + PARAM_GET_SOC_PWR_MAX = 0xC, + PARAM_GET_SOC_PWR_MIN = 0xD, + PARAM_GET_SOC_PWR_CUR = 0xE, +}; + #endif /* __PSP_DBC_USER_H__ */ From patchwork Fri May 19 03:24:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684039 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 40488C77B7A for ; Fri, 19 May 2023 17:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbjESRaS (ORCPT ); Fri, 19 May 2023 13:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjESR3x (ORCPT ); Fri, 19 May 2023 13:29:53 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2056.outbound.protection.outlook.com [40.107.96.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F7010F5; Fri, 19 May 2023 10:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n+VuWDSdQLhBh53ge00NzEXfKz+5YxR5AuAKoTXQxkXkPyv4t5gvHPjeshzaXuerwVfnLKjgHUvL4MSmKweqUGIsOtnF9oeuGZDj9sGIj3qJBDSXwjCz4iEWmProehYr8pTyxPEzUK1ENRIzcRpjHA6X87ieyowoGOmCqX9KEaHU4BCLXsVZwZKpU7yGqwEUBTa0Nm/2pvjqbFfJb/WJGIZY27t6qTS91V4daY3uKBYazdhXKBwW1TEaBz6533xafI5VWpjiNdixbDRfw2RqM71rE2tr5mqQJ1Ajge9i+GtnS++m5dQM3ZXaGo4vPwAcIlglcbdli0wPlN2s+8diBw== 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=lJ2R7p1+EheZHnyiiVN2R3UsfUXuzN8/4nby8MGswZg=; b=ZmILaaoN1oSIFfqHMNiLhiGJFNS2T69O/cpDIdpAw4PTIJVwMD+B8wlJtGGlsuSTKZSDU3sgsyPaxRhG0L+d61UhVUKitwVaRxq7i3ARA/Qe/+apJhiQ9yc7lKyKbODmsFFSW4rCFMQI2SWEZ+RR6lVRO9iqiEr7cQvIY7yNVgMhHkh0UB0NHnGfomPMCaBUpOQQpwXMszvPslJISpEfhBoL3+rt8dSgRq+RCd+e4SYYFNUKlcR+CNUG/b1L+mVkUUGli5JVGLNuBr536/g5tlgz6jEHCOaIPNaBgyJsZR7aWA2E9xbd0kS4fFSfHboxwb4tmj0s2e5p8gTSaerGEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=lJ2R7p1+EheZHnyiiVN2R3UsfUXuzN8/4nby8MGswZg=; b=glxFIvHwQqLoqDYDg9iTHVLz6NIHLSy5NjJe1uM19gPgKpi6+7trE04ml1xnCCLZr5hU/Au9aUO6om0yGJ8gJkAuIX1f8zI9oe7pEWEXvGcCqnjzLs65k8YAVI3J0ssZ/0hsTaAXtieNuiKl+TfD/HE77Xd+5wbECmKONDBgd1g= Received: from DS7PR05CA0103.namprd05.prod.outlook.com (2603:10b6:8:56::18) by MN2PR12MB4176.namprd12.prod.outlook.com (2603:10b6:208:1d5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:08 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::a7) by DS7PR05CA0103.outlook.office365.com (2603:10b6:8:56::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29:08 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:08 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:06 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 08/10] crypto: ccp: Add a sample script for Dynamic Boost Control Date: Thu, 18 May 2023 22:24:46 -0500 Message-ID: <20230519032448.94279-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|MN2PR12MB4176:EE_ X-MS-Office365-Filtering-Correlation-Id: aff85af8-8230-4d5a-a965-08db588e8d3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FVc98Np0Dt3Agp2ph3WPy1MPP+RXbi1gas5OyErY6SEY8S5du0CzSXedhLm5w8ilrHhj8oHXJbGi5c3xY+cBA94AwT+shLKOrdc9bPhY67czt00lrxa83Ew4/0s6fma70/AqgqqgYr5WeBU4vaG8iByNg7EsSLahGz3XeqZ1BLXDgdFi50gcYvFu898exGioyvsGIEM2OCFrFuxIseHWovmrUyzbABTus2HiT7+Y7bCCWrJUVHLFFaa+Lq6+aIkJMbLZMDbrWnPV7evVxXFTkfbZSHq2rgd+uvxX69LRMAr6xOApaHlEf3ykPF/EOeULqXQjaWGxXA8x69uZ25117fNXz8Du5QCVBRSHRPgX5UmDAk+jwCn5KQmy6NU1OffcijR9zCKBOeC1/WjAfPl7/Ahy5dAJhsM01AgL65J+5vu3fUHbugzPs7pMNjxHcIRMQbX9PatYdWmDAG7ZzvTEsxFM6CJoGSqZ2AJWejmxYmp8vKAYJU2LCBXIYpCn7XKe276T+sZhLldwNrpf+s+Wd6+Zu7BgmBeoEprxCXmLAzixI4617TISKIF/zAYUoedRD3DszOiCbu9XYx3acwA9ouVR6qaVeoigbWPeV1pvxllKLMcVWYJE7RHqmB3ix3+wVU0YVxY9wP5chINOgknHkOSrqce7f8G4gES02zowwwXW5qrt/GnsJRyu19/1tgb6kKE/Eou3zv5viwxDGNfy5YWVWypgo0Ai4b/qUZE4zdPIkXt7B29B+bL8PIepW88OGGPIOorh/K1x8lbRFEOWXQ== 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:(13230028)(4636009)(376002)(346002)(39860400002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(86362001)(2906002)(16526019)(70586007)(70206006)(186003)(26005)(1076003)(54906003)(478600001)(36756003)(110136005)(40480700001)(40460700003)(6666004)(7696005)(356005)(81166007)(82310400005)(2616005)(47076005)(426003)(336012)(41300700001)(44832011)(36860700001)(83380400001)(8676002)(5660300002)(8936002)(82740400003)(4326008)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:08.0439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aff85af8-8230-4d5a-a965-08db588e8d3c 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4176 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Dynamic Boost Control is utilized by userspace with a collection of 2 R/W IOCTLs and 1 W IOCTL. Userspace needs to prepare buffers with the appropriate signature data and details of the request. To allow rapid prototyping and testing this interface, add a python3 command line script that can validate the functionality of these IOCTLs. NOTE: This script does *not* generate signatures. They will need to be prepared separately and passed as arguments. Signed-off-by: Mario Limonciello --- tools/crypto/ccp/.gitignore | 1 + tools/crypto/ccp/dbc.py | 98 ++++++++++++++++++++++++++++ tools/crypto/ccp/dbc_cli.py | 123 ++++++++++++++++++++++++++++++++++++ 3 files changed, 222 insertions(+) create mode 100644 tools/crypto/ccp/.gitignore create mode 100644 tools/crypto/ccp/dbc.py create mode 100755 tools/crypto/ccp/dbc_cli.py diff --git a/tools/crypto/ccp/.gitignore b/tools/crypto/ccp/.gitignore new file mode 100644 index 000000000000..bee8a64b79a9 --- /dev/null +++ b/tools/crypto/ccp/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/tools/crypto/ccp/dbc.py b/tools/crypto/ccp/dbc.py new file mode 100644 index 000000000000..f1b7342060b1 --- /dev/null +++ b/tools/crypto/ccp/dbc.py @@ -0,0 +1,98 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0 + +from ioctl_opt import IOWR, IOW +import ctypes +import fcntl + +DBC_UID_SIZE = 16 +DBC_NONCE_SIZE = 16 +DBC_SIG_SIZE = 32 + +PARAM_GET_FMAX_CAP = (0x3,) +PARAM_SET_FMAX_CAP = (0x4,) +PARAM_GET_PWR_CAP = (0x5,) +PARAM_SET_PWR_CAP = (0x6,) +PARAM_GET_GFX_MODE = (0x7,) +PARAM_SET_GFX_MODE = (0x8,) +PARAM_GET_CURR_TEMP = (0x9,) +PARAM_GET_FMAX_MAX = (0xA,) +PARAM_GET_FMAX_MIN = (0xB,) +PARAM_GET_SOC_PWR_MAX = (0xC,) +PARAM_GET_SOC_PWR_MIN = (0xD,) +PARAM_GET_SOC_PWR_CUR = (0xE,) + +DEVICE_NODE = "/dev/dbc" + + +class _dbc_get_nonce(ctypes.Structure): + _fields_ = [ + ("auth_needed", ctypes.c_uint32), + ("nonce", ctypes.c_uint8 * DBC_NONCE_SIZE), + ("signature", ctypes.c_uint8 * DBC_SIG_SIZE), + ] + + +class _dbc_set_uid(ctypes.Structure): + _fields_ = [ + ("uid", ctypes.c_uint8 * DBC_UID_SIZE), + ("signature", ctypes.c_uint8 * DBC_SIG_SIZE), + ] + + +class _dbc_param(ctypes.Structure): + _fields_ = [ + ("msg_index", ctypes.c_uint32), + ("parameter", ctypes.c_uint32), + ("signature", ctypes.c_uint8 * DBC_SIG_SIZE), + ] + + +DBCIOCNONCE = IOWR(ord("D"), 0x01, _dbc_get_nonce) +DBCIOCUID = IOW(ord("D"), 0x02, _dbc_set_uid) +DBCIOCPARAM = IOWR(ord("D"), 0x03, _dbc_param) + + +def get_nonce(device, signature): + nonce = _dbc_get_nonce() + if signature: + nonce.auth_needed = 1 + tmp = ctypes.c_ubyte * len(signature) + nonce.signature = tmp.from_buffer_copy(bytes(signature, "ascii")) + result = fcntl.ioctl(device, DBCIOCNONCE, nonce, True) + if result < 0: + raise IOError(result) + return nonce + + +def set_uid(device, new_uid, signature): + uid = _dbc_set_uid() + if not signature: + raise ValueError("Signature required") + if not new_uid: + raise ValueError("UID required") + tmp = ctypes.c_ubyte * len(signature) + tmp2 = ctypes.c_ubyte * len(new_uid) + uid.signature = tmp.from_buffer_copy(bytes(signature, "ascii")) + uid.uid = tmp2.from_buffer_copy(bytes(new_uid, "ascii")) + result = fcntl.ioctl(device, DBCIOCUID, uid, True) + if result < 0: + raise IOError(result) + return True + + +def process_param(device, message, signature, data=None): + param = _dbc_param() + if not signature: + raise ValueError("Signature required") + if type(message) != tuple: + raise ValueError("Expected message tuple") + tmp = ctypes.c_ubyte * len(signature) + param.signature = tmp.from_buffer_copy(bytes(signature, "ascii")) + param.msg_index = message[0] + if data: + param.parameter = data + result = fcntl.ioctl(device, DBCIOCPARAM, param, True) + if result < 0: + raise IOError(result) + return param diff --git a/tools/crypto/ccp/dbc_cli.py b/tools/crypto/ccp/dbc_cli.py new file mode 100755 index 000000000000..2dbefc2b7ed3 --- /dev/null +++ b/tools/crypto/ccp/dbc_cli.py @@ -0,0 +1,123 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0 +import argparse +import binascii +import os +import errno +from dbc import * + +ERRORS = { + errno.EACCES: "Access is denied", + errno.E2BIG: "Excess data provided", + errno.EINVAL: "Bad parameters", + errno.EAGAIN: "Bad state", + errno.ENOENT: "Not implemented or message failure", + errno.EBUSY: "Busy", + errno.ENFILE: "Overflow", + errno.EPERM: "Signature invalid", +} + +messages = { + "get-fmax-cap": PARAM_GET_FMAX_CAP, + "set-fmax-cap": PARAM_SET_FMAX_CAP, + "get-power-cap": PARAM_GET_PWR_CAP, + "set-power-cap": PARAM_SET_PWR_CAP, + "get-graphics-mode": PARAM_GET_GFX_MODE, + "set-graphics-mode": PARAM_SET_GFX_MODE, + "get-current-temp": PARAM_GET_CURR_TEMP, + "get-fmax-max": PARAM_GET_FMAX_MAX, + "get-fmax-min": PARAM_GET_FMAX_MAX, + "get-soc-power-max": PARAM_GET_SOC_PWR_MAX, + "get-soc-power-min": PARAM_GET_SOC_PWR_MIN, + "get-soc-power-cur": PARAM_GET_SOC_PWR_CUR, +} + + +def _pretty_buffer(ba): + return str(binascii.hexlify(ba, " ")) + + +def parse_args(): + parser = argparse.ArgumentParser( + description="Dynamic Boost control command line interface" + ) + parser.add_argument( + "command", + choices=["get-nonce", "get-param", "set-param", "set-uid"], + help="Command to send", + ) + parser.add_argument("--device", default="/dev/dbc", help="Device to operate") + parser.add_argument("--signature", help="Signature for command") + parser.add_argument("--message", choices=messages.keys(), help="Message index") + parser.add_argument("--data", help="Argument to pass to message") + parser.add_argument("--uid", help="UID to pass") + return parser.parse_args() + + +def pretty_error(code): + if code in ERRORS: + print(ERRORS[code]) + else: + print("failed with return code %d" % code) + + +if __name__ == "__main__": + args = parse_args() + data = 0 + if not os.path.exists(args.device): + raise IOError("Missing device {device}".format(device=args.device)) + if args.signature and len(args.signature) != DBC_SIG_SIZE: + raise ValueError( + "Invalid signature length %d (expected %d)" + % (len(args.signature), DBC_SIG_SIZE) + ) + if args.uid and len(args.uid) != DBC_UID_SIZE: + raise ValueError( + "Invalid UID length %d (expected %d)" % (len(args.uid), DBC_UID_SIZE) + ) + if args.data: + try: + data = int(args.data, 10) + except ValueError: + data = int(args.data, 16) + + with open(args.device) as d: + if args.command == "get-nonce": + try: + nonce = get_nonce(d, args.signature) + print("Nonce: %s" % _pretty_buffer(bytes(nonce.nonce))) + except OSError as e: + pretty_error(e.errno) + elif args.command == "set-uid": + try: + result = set_uid(d, args.uid, args.signature) + if result: + print("Set UID") + except OSError as e: + pretty_error(e.errno) + elif args.command == "get-param": + if not args.message or args.message.startswith("set"): + raise ValueError("Invalid message %s" % args.message) + try: + param = process_param(d, messages[args.message], args.signature) + print( + "Parameter: {par}, response signature {sig}".format( + par=param.parameter, + sig=_pretty_buffer(bytes(param.signature)), + ) + ) + except OSError as e: + pretty_error(e.errno) + elif args.command == "set-param": + if not args.message or args.message.startswith("get"): + raise ValueError("Invalid message %s" % args.message) + try: + param = process_param(d, messages[args.message], args.signature, data) + print( + "Parameter: {par}, response signature {sig}".format( + par=param.parameter, + sig=_pretty_buffer(bytes(param.signature)), + ) + ) + except OSError as e: + pretty_error(e.errno) From patchwork Fri May 19 03:24:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684778 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 E77ADC77B7A for ; Fri, 19 May 2023 17:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbjESRaM (ORCPT ); Fri, 19 May 2023 13:30:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231816AbjESR3y (ORCPT ); Fri, 19 May 2023 13:29:54 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B2D10FC; Fri, 19 May 2023 10:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BwFW9TS7rGNUePGy9IZy6jZOxVeu+TDsDv5cvFyshPyw4ftIZl0BSNYIV62wSS+ufQSCbVaFsBTpzN3n/gYO2JIrtS2cfjtZKf/45fG8BqHxdLarXZ5EmhoCckwxPQdLfz4jqh1IUbiGKMrjQA1UAVGy3Sy0umVDNW22FFlJW5zWUuzNYn0Jl0/iup+IX1GDob1s8wpLcgorgWBVen5uUre2BPaevzf9jXNa5K/Lp0I1lDoKCDoclZi3gAeZ16fEa29pUG4GRzsF8lkecc7/ugF+BE5r/UFM6/lS0LlSsjLV4GqNTfcDhYbK5I/Eexvv2H3nA8j6NjjeDyjjn4R4Eg== 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=3vRp3oQ5mI3lG5LA7CKfO8Bfupy1g/R2DxOVyVWTqMs=; b=gBc6Qix/IBamjl/B2oM5Dwp7A0saf0zsirNmzqttG10B8mlZvN+6iYZduQlwSgIBVR4dnFJvq1Ph8NzA7kvkPgddtNG2YC2B1qyDqFrnUhIpGsjQXwcAN42o55NNqYgfVQrZxGs/h1FnCmmpeKfTk5vSROSsXDtTBE80H9lr5UKLLvwHguMl+bAQGpmaPKt0QdVvLCt8OGEZS1t3vJi7Kh2F44i0QECBcC1vlURSgHCJ58YVPPrr0FBT0WJZgRq5ndEEpJOHKB1QshVgLSHWWsJPiXjECJykDrVmsCZslJzpWi/k4Neqxe8uG5vrCDMKKd87Fc1b4twWVGOX+cR/7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=3vRp3oQ5mI3lG5LA7CKfO8Bfupy1g/R2DxOVyVWTqMs=; b=j4XwNOc2K648TxtL2mOb1K2BSvoe8X50mHsnOq01MQYZytuHzL15qTQ2QGhjDNK/NBkljzBurqGJXLvhAGP4JOQJoVuj4uUVDcZCGHcasdx7IVDAh/Myue7rKr+Blv0/4xq06TSybUmWAcMkhnr21ut9ju8tan896Enlhujkzfo= Received: from DS7PR05CA0085.namprd05.prod.outlook.com (2603:10b6:8:56::15) by SA1PR12MB6773.namprd12.prod.outlook.com (2603:10b6:806:258::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21; Fri, 19 May 2023 17:29:08 +0000 Received: from DM6NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:8:56:cafe::bb) by DS7PR05CA0085.outlook.office365.com (2603:10b6:8:56::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.7 via Frontend Transport; Fri, 19 May 2023 17:29:08 +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 DM6NAM11FT082.mail.protection.outlook.com (10.13.173.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:08 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:07 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 09/10] crypto: ccp: Add unit tests for dynamic boost control Date: Thu, 18 May 2023 22:24:47 -0500 Message-ID: <20230519032448.94279-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT082:EE_|SA1PR12MB6773:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ea52ae3-3806-4ff4-7e82-08db588e8d73 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t4A9A+sJXkXWjko/GPoIJZW+BAdSNFqOvf/n+QXVNpN7ascIv0ph0QJpp6co8VUViUGhv2UA9RCpZz2GGOLmBQoO6A+5zwcU8iQfox6PNCMNYiHiLzRgQO6JEmXhH6PJmS40Bh7ERc+tko1XxYQnI4eO4gOsO5AgTsEduo6yJxPNrnvMfURmH6+mVNUCgcNypa6JSkrjVLa0QNkI4qQeIYKR+vqyoUiJcNUUpAKyRtE1T6PUQ8mICBhKLQryr4tYqFxnZsnOiBNvKwcWQEUOGe4H4OzW2V05TpojfEjNuB6nOJRKdLRoXSc4j6+5nfHWRXVNlpmypWFJFqIAtT8Mdl6RJ5gxWhX+GT+A/SARqv5Kr0V14Hhbk3ZQmomr7JTJ/us11G/zPE0TuFcKua+ypYPQGv7hyF+RivRDF2KJo+bWFX6AVxg28tvYpa1CumtypX1MOMeoTwekzbB3SIPdUJraDJ6vMFyACvCh4YlJeriZKScrmJiCycqgYTbmRvrP5vmr4+raFfVL09ku1RgDjQCCEDvBCvZEAPOZkZwkZXAjVDphnh0nfBmnBc13CXfT0WgObiqwi0NTEvptJutcDxAjGpbVkSHoqiMt4NRdICPIprsmpwO8K531k+5phsZK9L/YM5oWoU7EcfnqXP/hkdHhdvt5IF/ROVuKwp8DfVZnocuSyCO8zeYPqxrUZTKI7+oVbV0xuf/3/QE/+yGI3XZRWPY7XZjKoSspdTKINTj4bkbmXNaedvR/w0ewUxMgZe7yElrGrBS68iBcSeiq2A== 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:(13230028)(4636009)(136003)(346002)(396003)(376002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(54906003)(5660300002)(26005)(1076003)(44832011)(478600001)(186003)(110136005)(316002)(41300700001)(70586007)(70206006)(4326008)(16526019)(8936002)(6666004)(7696005)(82310400005)(86362001)(2906002)(8676002)(82740400003)(426003)(47076005)(336012)(2616005)(40460700003)(36756003)(356005)(81166007)(36860700001)(40480700001)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:08.4188 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea52ae3-3806-4ff4-7e82-08db588e8d73 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: DM6NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6773 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Interacting with dynamic boost control messages requires the caller to supply a signature. To allow validation of individual dynamic boost control components, introduce a set of tests that can be run. The tests can be run in 3 distinct different environments, and so certain tests will be skipped depending on the environment. 1. Systems that do not support DBC. 2. Production systems that support DBC but are secured silicon. 3. Pre-production systems that support DBC but are unsecured silicon. Unsecured silicon does not validate the signature, and so this allows testing more of the state machine and functionality. Signed-off-by: Mario Limonciello --- v1->v2: * Update commit message --- tools/crypto/ccp/test_dbc.py | 266 +++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100755 tools/crypto/ccp/test_dbc.py diff --git a/tools/crypto/ccp/test_dbc.py b/tools/crypto/ccp/test_dbc.py new file mode 100755 index 000000000000..a58c153d52e6 --- /dev/null +++ b/tools/crypto/ccp/test_dbc.py @@ -0,0 +1,266 @@ +#!/usr/bin/python3 +# SPDX-License-Identifier: GPL-2.0 +import unittest +import os +import time +import glob +from dbc import * + +# Artificial delay between set commands +SET_DELAY = 0.5 + + +class invalid_param(ctypes.Structure): + _fields_ = [ + ("data", ctypes.c_uint8), + ] + + +def system_is_secured() -> bool: + fused_part = glob.glob("/sys/bus/pci/drivers/ccp/**/fused_part")[0] + if os.path.exists(fused_part): + with open(fused_part, "r") as r: + return int(r.read()) == 1 + return True + + +class DynamicBoostControlTest(unittest.TestCase): + def __init__(self, data) -> None: + self.d = None + self.signature = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + self.uid = "1111111111111111" + super().__init__(data) + + def setUp(self) -> None: + self.d = open(DEVICE_NODE) + return super().setUp() + + def tearDown(self) -> None: + if self.d: + self.d.close() + return super().tearDown() + + +class TestUnsupportedSystem(DynamicBoostControlTest): + def setUp(self) -> None: + if os.path.exists(DEVICE_NODE): + self.skipTest("system is supported") + with self.assertRaises(FileNotFoundError) as error: + super().setUp() + self.assertEqual(error.exception.errno, 2) + + def test_unauthenticated_nonce(self) -> None: + """fetch unauthenticated nonce""" + with self.assertRaises(TypeError) as error: + get_nonce(self.d, None) + + +class TestInvalidIoctls(DynamicBoostControlTest): + def __init__(self, data) -> None: + self.data = invalid_param() + self.data.data = 1 + super().__init__(data) + + def setUp(self) -> None: + if not os.path.exists(DEVICE_NODE): + self.skipTest("system is unsupported") + return super().setUp() + + def test_invalid_nonce_ioctl(self) -> None: + """tries to call get_nonce ioctl with invalid data structures""" + + # 0x1 (get nonce), and invalid data + INVALID1 = IOWR(ord("D"), 0x01, invalid_param) + with self.assertRaises(OSError) as error: + fcntl.ioctl(self.d, INVALID1, self.data, True) + self.assertEqual(error.exception.errno, 22) + + def test_invalid_setuid_ioctl(self) -> None: + """tries to call set_uid ioctl with invalid data structures""" + + # 0x2 (set uid), and invalid data + INVALID2 = IOW(ord("D"), 0x02, invalid_param) + with self.assertRaises(OSError) as error: + fcntl.ioctl(self.d, INVALID2, self.data, True) + self.assertEqual(error.exception.errno, 22) + + def test_invalid_setuid_rw_ioctl(self) -> None: + """tries to call set_uid ioctl with invalid data structures""" + + # 0x2 as RW (set uid), and invalid data + INVALID3 = IOWR(ord("D"), 0x02, invalid_param) + with self.assertRaises(OSError) as error: + fcntl.ioctl(self.d, INVALID3, self.data, True) + self.assertEqual(error.exception.errno, 22) + + def test_invalid_param_ioctl(self) -> None: + """tries to call param ioctl with invalid data structures""" + # 0x3 (param), and invalid data + INVALID4 = IOWR(ord("D"), 0x03, invalid_param) + with self.assertRaises(OSError) as error: + fcntl.ioctl(self.d, INVALID4, self.data, True) + self.assertEqual(error.exception.errno, 22) + + def test_invalid_call_ioctl(self) -> None: + """tries to call the DBC ioctl with invalid data structures""" + # 0x4, and invalid data + INVALID5 = IOWR(ord("D"), 0x04, invalid_param) + with self.assertRaises(OSError) as error: + fcntl.ioctl(self.d, INVALID5, self.data, True) + self.assertEqual(error.exception.errno, 22) + + +class TestInvalidSignature(DynamicBoostControlTest): + def setUp(self) -> None: + if not os.path.exists(DEVICE_NODE): + self.skipTest("system is unsupported") + if not system_is_secured(): + self.skipTest("system is unfused") + return super().setUp() + + def test_unauthenticated_nonce(self) -> None: + """fetch unauthenticated nonce""" + get_nonce(self.d, None) + + def test_multiple_unauthenticated_nonce(self) -> None: + """ensure state machine always returns nonce""" + for count in range(0, 2): + get_nonce(self.d, None) + + def test_authenticated_nonce(self) -> None: + """fetch authenticated nonce""" + with self.assertRaises(OSError) as error: + get_nonce(self.d, self.signature) + self.assertEqual(error.exception.errno, 22) + + def test_set_uid(self) -> None: + """set uid""" + with self.assertRaises(OSError) as error: + set_uid(self.d, self.uid, self.signature) + self.assertEqual(error.exception.errno, 11) + + def test_get_param(self) -> None: + """fetch a parameter""" + with self.assertRaises(OSError) as error: + process_param(self.d, PARAM_GET_SOC_PWR_CUR, self.signature) + self.assertEqual(error.exception.errno, 11) + + def test_set_param(self) -> None: + """set a parameter""" + with self.assertRaises(OSError) as error: + process_param(self.d, PARAM_SET_PWR_CAP, self.signature, 1000) + self.assertEqual(error.exception.errno, 11) + + +class TestUnFusedSystem(DynamicBoostControlTest): + def setup_identity(self) -> None: + """sets up the identity of the caller""" + # if already authenticated these may fail + try: + get_nonce(self.d, None) + except PermissionError: + pass + try: + set_uid(self.d, self.uid, self.signature) + except BlockingIOError: + pass + try: + get_nonce(self.d, self.signature) + except PermissionError: + pass + + def setUp(self) -> None: + if not os.path.exists(DEVICE_NODE): + self.skipTest("system is unsupported") + if system_is_secured(): + self.skipTest("system is fused") + super().setUp() + self.setup_identity() + time.sleep(SET_DELAY) + + def test_get_valid_param(self) -> None: + """fetch all possible parameters""" + # SOC power + soc_power_max = process_param(self.d, PARAM_GET_SOC_PWR_MAX, self.signature) + soc_power_min = process_param(self.d, PARAM_GET_SOC_PWR_MIN, self.signature) + self.assertGreater(soc_power_max.parameter, soc_power_min.parameter) + + # fmax + fmax_max = process_param(self.d, PARAM_GET_FMAX_MAX, self.signature) + fmax_min = process_param(self.d, PARAM_GET_FMAX_MIN, self.signature) + self.assertGreater(fmax_max.parameter, fmax_min.parameter) + + # cap values + keys = { + "fmax-cap": PARAM_GET_FMAX_CAP, + "power-cap": PARAM_GET_PWR_CAP, + "current-temp": PARAM_GET_CURR_TEMP, + "soc-power-cur": PARAM_GET_SOC_PWR_CUR, + } + for k in keys: + result = process_param(self.d, keys[k], self.signature) + self.assertGreater(result.parameter, 0) + + def test_get_invalid_param(self) -> None: + """fetch an invalid parameter""" + try: + set_uid(self.d, self.uid, self.signature) + except OSError: + pass + with self.assertRaises(OSError) as error: + process_param(self.d, (0xF,), self.signature) + self.assertEqual(error.exception.errno, 22) + + def test_set_fmax(self) -> None: + """get/set fmax limit""" + # fetch current + original = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) + + # set the fmax + target = original.parameter - 100 + process_param(self.d, PARAM_SET_FMAX_CAP, self.signature, target) + time.sleep(SET_DELAY) + new = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) + self.assertEqual(new.parameter, target) + + # revert back to current + process_param(self.d, PARAM_SET_FMAX_CAP, self.signature, original.parameter) + time.sleep(SET_DELAY) + cur = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) + self.assertEqual(cur.parameter, original.parameter) + + def test_set_power_cap(self) -> None: + """get/set power cap limit""" + # fetch current + original = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) + + # set the fmax + target = original.parameter - 10 + process_param(self.d, PARAM_SET_PWR_CAP, self.signature, target) + time.sleep(SET_DELAY) + new = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) + self.assertEqual(new.parameter, target) + + # revert back to current + process_param(self.d, PARAM_SET_PWR_CAP, self.signature, original.parameter) + time.sleep(SET_DELAY) + cur = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) + self.assertEqual(cur.parameter, original.parameter) + + def test_set_3d_graphics_mode(self) -> None: + """set/get 3d graphics mode""" + # these aren't currently implemented but may be some day + # they are *expected* to fail + with self.assertRaises(OSError) as error: + process_param(self.d, PARAM_GET_GFX_MODE, self.signature) + self.assertEqual(error.exception.errno, 2) + + time.sleep(SET_DELAY) + + with self.assertRaises(OSError) as error: + process_param(self.d, PARAM_SET_GFX_MODE, self.signature, 1) + self.assertEqual(error.exception.errno, 2) + + +if __name__ == "__main__": + unittest.main() From patchwork Fri May 19 03:24:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 684774 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 167A2C77B75 for ; Fri, 19 May 2023 17:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbjESRaT (ORCPT ); Fri, 19 May 2023 13:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231792AbjESR3y (ORCPT ); Fri, 19 May 2023 13:29:54 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D7810FF; Fri, 19 May 2023 10:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bl1BtrsvjIPdr9Rx7IKXR3S1hHrJ6sHam/vmrd4jXDUdfSF0cMRpwoMBbvMrAjf6iiRhwiK3MBeNjIB0Eomvu97zIYlH1qKdRUgw7IY5Ymiuqg7qeO0fBU8fye8rffBtReTrzsdqJKGKz+T3FH8ZndyjjW1KGXrNHravidAftdsi5bkDaUJvUa97wlAZHe9+0NGE2FitjOiIu/xFEEsvgO5OdJG2AV+ZMF/EAEsqbcaHW6FjGHWDrHrZETyiBkxhgV83aM5qChISUrTXGc1i7K1ceFrWAvYzPGqj8bRQjjJE93oB4+FrH1DYlD3kfIUmYrPTjJ8BStfIckKJBdK+ZA== 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=J5UoFraxHPBUsLmDGAbHt7a9vEfgZB82Dtkjge2Jds4=; b=D8Ab2dx0HOdBmy2hPaIyUrxbYrNLwcFDPb74VH2qfDdtAc5nWAJKiFdIVeyCwZmVTQgZQmt6jVek8qrNnGkeGL86a3SybcZ7cYeRGvPgQV6q6VWgSWR7hmr2coGjFfb0bSxY7TW5bASVBZvlzfM8bsVfws+8K6XqhpS/6rkPjRDFA8eZ5tfTMQ0rwpTPW2DPZvx4JIfg2PoDB+evObsd7d4dssG1jWMQRr/Dy2xwj8AWgd1NAIfdhmpQhilRqN0MkBJEgwZjAdWzpaa8G1fNKenww3lP4GpC2eE31pyR+n8+f8uwEEifgkyMkQsU3kl0t29ATfBTqfZ0lNbkKjcT6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=gondor.apana.org.au 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=J5UoFraxHPBUsLmDGAbHt7a9vEfgZB82Dtkjge2Jds4=; b=g9Vm6EcMOZafNW/K2EnN/3vvtwSH69sSf6z1zeg0Q8dbJ0LgeyjiAOJYDVm+49Vykp00x4PFg8MxgKZo+pIVJRKST839gYZgHJGZYKcKHy+0ygF9H4MKcGfZcmDhFUnYdij5EY4/nO8E88HX6+/h18Y1Q2whdWfq0ySXdHCZePE= Received: from DM6PR08CA0027.namprd08.prod.outlook.com (2603:10b6:5:80::40) by MN0PR12MB6224.namprd12.prod.outlook.com (2603:10b6:208:3c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.17; Fri, 19 May 2023 17:29:10 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::fd) by DM6PR08CA0027.outlook.office365.com (2603:10b6:5:80::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:10 +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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.21 via Frontend Transport; Fri, 19 May 2023 17:29:09 +0000 Received: from SITE-L-T34-2.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; Fri, 19 May 2023 12:29:08 -0500 From: Mario Limonciello To: Tom Lendacky , Herbert Xu , "David S . Miller" CC: John Allen , , , Mario Limonciello Subject: [PATCH v3 10/10] crypto: ccp: Add Mario to MAINTAINERS Date: Thu, 18 May 2023 22:24:48 -0500 Message-ID: <20230519032448.94279-11-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032448.94279-1-mario.limonciello@amd.com> References: <20230519032448.94279-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: DM6NAM11FT013:EE_|MN0PR12MB6224:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a3f264c-db08-42d6-ab5a-08db588e8e34 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kTYXWZR7JIoCJWj8alrCIy/zMiV5QN1B9x9Xm1ExWKxZ8kNlGXnpmfdSTs7UcR4o7QLCxtVeCYjiNkrZtWb01gYmd2sOfclx3HSPGwwdjgL6s8eHuJckvknBR7b8DImgCp6ODoIHO4AzU85CFlX2BaLU+mhCmjY+LZYGcMB2wOzZJq9RVFbmZP98VwoQuGn9DziLDWXpJ4B4Gn6lJtDecPw25Fe0D3oVlawdbtTXt9tU567C3iQTIsSFGbZytDrZd5VRJK9rPz0jYtVFuVhHuLEc4fsrG2GItfCGTbNeVP3iquUEaEp5YiadByFhj1jG/Esb00Gq6E4G2gVmUo59zeUuVaOHrfRluDBBPydBPhTUfly9+U4cvlvloyRjFjVtTCWZ5uXyNyO7Cfd/YJipFSjQmjk3w/c10Okl86iIwUJWNth6C26ahHgVTTdwBm/FPqjP9f+wPtyAAyvX2ocvY95jeVGlbR8DXCeO70U5A1DaP4SqF9zJadp7diDsWhK/ekRrlrVyU1asZ1igdfmpozUum1EomZYwhJLc6Y6YKKceLI6YbqprvmYbD1O2FIl+3vPlDiJ/zL9y17cV96T7G3qm36JFojn+p+VP4hEMddxlh3DYiY/X1Y8PVsg6nuzSF+FrsFJR+U1Fwk1jRzRjICh+pb8fVMPQRdOb8Z58h699F75Swe78p52eZDHUhMPuZNgvAB7WBXokwVgZWDZwFsmaaycLNP2Axt5foQJA2gG8fWOKiioaauhXQfLHmeVywTgUCqPdAss5wtNHJzH6PQ== 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:(13230028)(4636009)(376002)(346002)(396003)(136003)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(478600001)(36756003)(86362001)(6666004)(316002)(110136005)(54906003)(4326008)(70586007)(70206006)(82310400005)(44832011)(5660300002)(4744005)(2906002)(40480700001)(8676002)(41300700001)(82740400003)(81166007)(8936002)(356005)(16526019)(36860700001)(7696005)(2616005)(83380400001)(186003)(1076003)(26005)(426003)(336012)(47076005)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 17:29:09.6692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a3f264c-db08-42d6-ab5a-08db588e8e34 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6224 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org I will maintain the platform access interface and dynamic boost control support. Signed-off-by: Mario Limonciello --- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f2e19f576fec..fdc923bff7f8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -988,6 +988,17 @@ S: Supported F: drivers/crypto/ccp/sev* F: include/uapi/linux/psp-sev.h +AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - DBC SUPPORT +M: Mario Limonciello +L: linux-crypto@vger.kernel.org +S: Supported +F: drivers/crypto/ccp/dbc.c +F: drivers/crypto/ccp/dbc.h +F: drivers/crypto/ccp/platform-access.c +F: drivers/crypto/ccp/platform-access.h +F: include/uapi/linux/psp-dbc.h +F: tools/crypto/ccp/*.py + AMD DISPLAY CORE M: Harry Wentland M: Leo Li