From patchwork Fri Apr 28 18:55:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677768 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 13EE1C77B60 for ; Fri, 28 Apr 2023 18:56:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344155AbjD1S4F (ORCPT ); Fri, 28 Apr 2023 14:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjD1S4E (ORCPT ); Fri, 28 Apr 2023 14:56:04 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2044.outbound.protection.outlook.com [40.107.94.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 600C930D6; Fri, 28 Apr 2023 11:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5a5tCTKlA58DlsZY8aPWoKCU2FYfL4c7iqUauaI8f9hIUM/iFiRtRN4p+Ad+uWbdzL2+leG5VSaOA0RUkC2sNC4f4swB+W2tnql1S+SSMZLYx4OUI2lYGAXzD6OQJviPdEDoVhTfEVHBFgYBI4ev2SpgjO4Q6pczgoxQJ8ppQNcsugEixbsPKCgX3jFucueJqB0XGvu9t6FYnuVvKk1FXmiUNTGmNfoHPmM5WR5AUr+pOYlbADcWnC/1I4rPff/McRb2eE/gmxqtrndZgJQP3WMjuecYNGCYF0PK2NEBABWKeODcA1E9zemuZv1mXCMQjNItesmuyiQKJxu+nbvCg== 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=tT9pMXjLl6E+ougnM0VBeecJpTqYTp3ifuOyQ+Nqe0I=; b=LmYnFa34qnGcQSV5pUGA/vd4IYhXWEgnsBX4/xEPKNtdLLS0qYQGu/sKbVsWbQI1ke+odHgCF9FwrPzS73/BZ5w/CpmZfETK+y4g4z/XuQbWSOueH2BsidnPt6RMcHunDEFkX02BzlN0jRbiQOoSnL43jvVbQ63Jouzr81oFf2iqxbBxFqmubWPw+ChPUnUCUPx1+wELYMO0bVwtCTm039FWQoWwF/+Mz4cC01aiDl8znhGKKOL3r1HEkqYXfAd5eUqGyI96iiTTaMKcPwxHEoqEw0zfDixJbn0YJhYYY2/u5RtKmLk+WehMqc0MZhTjhdtenMJWyjqwY34knsxlmA== 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=tT9pMXjLl6E+ougnM0VBeecJpTqYTp3ifuOyQ+Nqe0I=; b=tfqb0Svrtv8kDaXVpNnRS5krd1Pyz9W1RxCkzR0tRu+RwwPXh4Iwf9y4xGfu17RrP/USDmq1TRob68gyYjLDXjGXbSN1U6IogYsgCo2brfIF2OArWVDg18j6didlJbx7jwIeRYcjMvRiXGq3Wm/apgrFucQ3B4ZrRt20g1IUvsI= Received: from DM6PR02CA0120.namprd02.prod.outlook.com (2603:10b6:5:1b4::22) by PH0PR12MB8797.namprd12.prod.outlook.com (2603:10b6:510:28d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21; Fri, 28 Apr 2023 18:56:01 +0000 Received: from DM6NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::20) by DM6PR02CA0120.outlook.office365.com (2603:10b6:5:1b4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56: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 DM6NAM11FT042.mail.protection.outlook.com (10.13.173.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56:00 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:55:58 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 01/10] crypto: ccp: Rename macro for security attributes Date: Fri, 28 Apr 2023 13:55:31 -0500 Message-ID: <20230428185543.8381-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT042:EE_|PH0PR12MB8797:EE_ X-MS-Office365-Filtering-Correlation-Id: 87a1398b-7fe0-4a4d-f878-08db481a35ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 57UjEe45Qm4W2sI/ljlgc5+ATqtq0EsQJUCUT58m/vKX9j9nj7gV+drDlOQ2VDr80DBfJyjWfCvXCAg49pN03ErZ+3bsCHeuFEqwV9zMAc2c7T2WP9okugDnolNX9a7XZ5UGJm9jglKFzhZYczxYJJdsYT2sFGzgwXcIrjwXz6Oqv1cH3lr4hj7QBmyA27pgiWHQ6Jp71eyU+aOn7U7Ta8GvDqZtI9FTlqrUd3QqjrjfSSlBwehH2C1YpVEHd4B907PSGdB/vlB/cGuhl78d6jb6YhLA0LzPwZQiBF0AcBI+YCtLGDVtN7cyKGejUmIK3NM5tR4USWZNaqz85RQP1aUDk9YchUhMAT9KzxyAlTGIK+Y3aVB+4nF5kZb12Iz2dLwDZvgPe5VtwUKRVJUvA1H3d/gy4Uv647IAOPy3ALqXCirV/o4VDRZYGZ7/oG6yzNh3w22o5USW1pO6iO/4n7N+vew+jiQ/rlJ7AUQFzxltVxgVRzEcg+DKxf3ggBskSklwV3ljiETiZ6wXdUOVpkuwGmFJua2VWnEGSdartjkIIsOytcB18rRc/01lm2bvW0/z2/LLADSE1kF2zXriAbGdDaMgku2Uqvh+Vl/9n9VPWcQFDKJnMh8kdea/ZgnvRs2o1oR4LL9TK5t4cQQO06/IRXWMYC8guWuOe9h2a7Gdfb1HREfC84bGD3flX8+Idb35hq/3xGCoMYkO3ooR8ZlyCRZw0E6IE/2YDPtsrBE= 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)(376002)(396003)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(40480700001)(110136005)(4326008)(54906003)(6636002)(478600001)(70586007)(70206006)(316002)(41300700001)(81166007)(82740400003)(8676002)(8936002)(356005)(5660300002)(336012)(16526019)(83380400001)(2616005)(426003)(186003)(6666004)(7696005)(36860700001)(15650500001)(26005)(1076003)(40460700003)(36756003)(2906002)(44832011)(82310400005)(47076005)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:00.9284 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87a1398b-7fe0-4a4d-f878-08db481a35ae 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: DM6NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8797 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. Signed-off-by: Mario Limonciello Acked-by: Tom Lendacky --- 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 aa15bc4cac2b..85e3dc8853e2 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 Apr 28 18:55:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677766 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 903A7C77B7E for ; Fri, 28 Apr 2023 18:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346531AbjD1S4M (ORCPT ); Fri, 28 Apr 2023 14:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346468AbjD1S4I (ORCPT ); Fri, 28 Apr 2023 14:56:08 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2047.outbound.protection.outlook.com [40.107.95.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A4D64EFE; Fri, 28 Apr 2023 11:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EGInx/Jn6V599fH7MxVZeLu6BjNL8iXLN1wXyxJ/Dx/qVoLbrvL9lgCPoFBugR8HytE49xmkBoifC4St3+zgEberJ4VKDX7ezMtGgwl2ZttO6PJxxitOG7PiHh3j45adaPAPQYn2ljmUv18s4KIdbzXsmrm8CyQ25QczYnoy8BJQ2YEMlo+iA5vUJv0qgQ6+Ujwot4OmLAJ2m39pEUs2vfuSUlYSUBiDx1jHZJP/boW4BI4h4FsXldCLU7oHiSm4HIvVWVjmDKxWZPxpzyGtPrsyWD+Ph8rtScBdwtlT9JMqPus3L68lYkbmJFDhWJyIV13X+she+8FWC8AZZDXKXw== 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=P8pXCP4cZAIIewrP9UkvRDq/kcEppWjyHw+UNk2bTMk=; b=QmtTVVE4oNxr52I58W7NkIHcfji2gGyOjVoNGX+Lui3whKiPew0SC5WU5BrmA1wMnqjIaKlRUQtHnNk8EPIv1te2ptcN+3gAqcq8Ov+75+n0noGuHyibq+PnDyI4Mb9DW+GyPtt7dBNXG4RA6l72IyUgMwkcIwBq1BD8qAE+KPPcFRlAOby/3LYrkN+QlWYS4R9jGXTdnISw/qe0xrSKxIsrw6v5grbc0pShSZJWLLZH2tJhIKkszq9Q3RSh/Px9xE2fvxmvq2aPikDO419JOkizFK7WOTW/hUY9Q2ISoa85Wn45p2IPiTtDBDRHbmRdvYZmupZ8BoQRI38n/RItjQ== 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=P8pXCP4cZAIIewrP9UkvRDq/kcEppWjyHw+UNk2bTMk=; b=4oihphtGh1XFUqMIRBfPVQkR1glHiOcEnohDDodNj2iCO0ISDTpK4LQWIK5PRW9JmxALSHY2YNwX1dzVADoqelWYk+TCPDWXsrcG57FaO9FMQ8ndum4nYIsSqA/vzPJyS8D3L7jvf7TKFzOYhAFQSlZKhyauSoxnfRMwA9niLKg= Received: from DS7PR07CA0024.namprd07.prod.outlook.com (2603:10b6:5:3af::6) by BL1PR12MB5206.namprd12.prod.outlook.com (2603:10b6:208:31c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.23; Fri, 28 Apr 2023 18:56:03 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::76) by DS7PR07CA0024.outlook.office365.com (2603:10b6:5:3af::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56: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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.25 via Frontend Transport; Fri, 28 Apr 2023 18:56:01 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:00 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 02/10] crypto: ccp: Add support for displaying PSP firmware versions Date: Fri, 28 Apr 2023 13:55:32 -0500 Message-ID: <20230428185543.8381-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT050:EE_|BL1PR12MB5206:EE_ X-MS-Office365-Filtering-Correlation-Id: 1206370c-59b9-4f27-4274-08db481a363c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xl0xSvkO7B403rdB4fY9ykvhLqrKF6ugCuD2ohZYEywWMyUqb2t2AtRrZ2DklFEjIxj1YruOO+miXl7FPPnfcUd+ITarvfTOiSCM42d3rHGk82TeGmw8nKgnqkgFqY8Rn3Tss58bfOFK0NRjJq7Hp+SxyZpzN/IieeOnOoo3gofkVbLuNzJwIp88KMyyV7gKef5Z+Q/NJ8kJjZZI3aUKTm285FFNOPR2ohKVWVXu+U0uLed96prB02K+kXUbDPeC6LI4Mc63lf6cdGvhft7iixUS3cPJOxC70Yphlxv7gaYBMF04+rx4pZpVx29ezBvMSHipEcjmksirrcm3aOcmvA9F9yk3rFZuSAVX5aWLg0bGVVnRfxdAUdaW7W0/i2YbqFn5By8H+jj9OR09lzc3JfQx6DgkAMUB2HiiVuHZI40rB3u1+ucmQf3qF/oYxXogm1Y+8OgnoqKcS7Unp92ONowCDhzUO1lcMYscJfUC+ljltZ3LK1jgmirKd5zLikSgz6da/M3v7UmOIyrBJQBmv/DyhgfR0Z8WOgGswwAJnBPX/haBK4Anl283iIuUMdC8cKN24NZKIQdxvsbIa7qWP/67jAzs08L5ifyXaYRUfTED04Tgb8xFYrFD/831pskK5G7DfSqytWJ7Aki0EG1O5tQPGRed8SXmZn+Yf6UgThA8ZbfJWTha7qg7foGwfnj6cLEHB2J7Qvih9HJmAqWmd7BKx27FiwXX2z3ayBAB29SaFSl1RVAg2FSRV0DBUj8oaVwe/kt36t76BZgM8v88Q9fGim+mqEKkQCQ5C8WigR4= 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)(346002)(396003)(376002)(136003)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(54906003)(6636002)(110136005)(478600001)(7696005)(6666004)(40460700003)(41300700001)(83380400001)(2906002)(36860700001)(82740400003)(86362001)(5660300002)(44832011)(82310400005)(81166007)(356005)(8676002)(8936002)(16526019)(40480700001)(1076003)(186003)(26005)(70586007)(336012)(316002)(4326008)(47076005)(2616005)(426003)(70206006)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:01.8544 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1206370c-59b9-4f27-4274-08db481a363c 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5206 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. Signed-off-by: Mario Limonciello Acked-by: Tom Lendacky --- 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 85e3dc8853e2..7ef7c09b4a2f 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 Apr 28 18:55:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677767 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 8DBCAC7EE21 for ; Fri, 28 Apr 2023 18:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346534AbjD1S4K (ORCPT ); Fri, 28 Apr 2023 14:56:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346449AbjD1S4H (ORCPT ); Fri, 28 Apr 2023 14:56:07 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2083.outbound.protection.outlook.com [40.107.237.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F13571704; Fri, 28 Apr 2023 11:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TKNb2EbQUbqQgBhO9V8miHvlYz57UvIA+rmTb5B43ZatPQpX/PkSbXGfAuPb9MXKmKUvgoef4WpD5rxiMK7KWHv/6pjtVE+c22OK2Y2wAXnfcN2etfSKWzwQI3QgEt2Ydp0MPdWSLs+jPC6jTtXMvf6bXjy1ZQpbIta2779SbvOJ0P/J5FmkCXRcuzlpZRGkOqiBopUbj06tsREZMvQGsOlhKHhhTPSFZpMWwaCIXN5tEn9Y6glRdwOb7FW1PIRMfjQzy5MjKoSBdb3q1jC60EO+/7fWC5QtFWWihtV3Gvgk71KHqifbkL+B+pzuw3GEIpZHjWQP+NmC72XsFl8Nug== 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=XnAt8LX0A5dwt3U/7IhmLsAoxaT9jZuB0k+oCYO3hFg=; b=Z6DSlbn8n33+0jpHfAjaqZFkqFMtzNTULdmtO7+aHLZTeJ+wtKwNCWgeBkvZKBPTZzuKWVepwHqgVIBb3hX6++MxyOSv9JjRS221Yl3sVZKVC7Vnasl8mkTrj/gGk9AI+Zspd2MEQ3JmFq8ivfgAgp23BgR46f1lVM5dZcYGnSIJ3CxWABdpfZDmY7gmSKycbFkQImlFWh0CZRyHl2XZ8U4em+2HwhphWGfBxgGntuS8AOEXWi+M76/oBPqxQ5i3CLAjSTf6LwcwkaSW3IR+67fUSZS1WiK/wMSLzVHJ2Ie/kvnXQzYvyAOav0ECGY/3SeyvK9/cKMx0FUsLQeMS7A== 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=XnAt8LX0A5dwt3U/7IhmLsAoxaT9jZuB0k+oCYO3hFg=; b=QlTo7dc2eWpApbFlqDmn5uMafaANLNN20PFHemkEdgtbhOLBALsnREX6ouX0tWVMh3t/x3FP5km+ePnufTBU7IrspzkigdpLdwmm3ATa1WWk2tqTh7oQAtNhtBjPLosiJFZLUfJslvNYofnn/KYcs913a2jhCdTwMUVgkg4sprw= Received: from DS7PR07CA0005.namprd07.prod.outlook.com (2603:10b6:5:3af::15) by MN0PR12MB6152.namprd12.prod.outlook.com (2603:10b6:208:3c4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24; Fri, 28 Apr 2023 18:56:03 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::9a) by DS7PR07CA0005.outlook.office365.com (2603:10b6:5:3af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56:03 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.25 via Frontend Transport; Fri, 28 Apr 2023 18:56:03 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:01 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 03/10] crypto: ccp: Add bootloader and TEE version offsets Date: Fri, 28 Apr 2023 13:55:33 -0500 Message-ID: <20230428185543.8381-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT050:EE_|MN0PR12MB6152:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a767bf6-c1b6-4dbf-f825-08db481a3719 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qpVc9YFA2+0OoD8lIKcsKankisjF3OOl7/yRJN/LOhby/GN/J2paqk5f40zS74d4t/ZQEVhEPuK7Rq0S+lcYB5Jb0l2A33/kihFnSLtm43a7MRwLJMWLhTTD5woBH6lytUnAf6KyqLu8U/uhNwPo7+DSkNhiLdMVGzYFMDdt2ZEkLg8TEZSQ6bLANAvrEFJ3NDKv7V5m7a1prIH0ISSAEcK57DhK32PaCQONXaj4AdZLFnRIyuyq3kHeWRgAd/VqJgbccOTfB+CVDpJFUTMiz6OiaeBNYbRNfVZzf+MXeNq8p2y11j7YYwLuB22ZaQiYWHrTEukzNC2/MO8JZg2TsafFloClfrqUZVgsjq77TPYQ3Fzkkh0onIaMX20FiabApWUPKlFgs7QtwuoFNj3uzctlpGVYgIyNniJNSYQIRObBf6yac17p+Lg0OnQUB1T0EqQinY2INrnGSGCWbb4vmI+s14zXlO62XpTv0u85Lv1YaPlF3kBe7Far2uDkGADS2otg4zB2jC7HMJ5I6qyQpXAu0st7aIPt9FzDMqNz8iMzHhF/KkIRy1rOXtEWla2NpbPK9aNpMS9fJxfWQ4VLvJgeRub+Dm4Xko8c0Ud6a5U2jP16LbmZP5PbmP6DPAydYE93a7p6QqfWxs2dYjIvO2YZpQJlb6aGMa3hJ+v9ceioa5JmA1/VjFIyK98EayhZGEO2RHIFimPcE+EatYjj5PpFEL/KKd47xL9NvzSWFc4= 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)(41300700001)(40480700001)(4326008)(82740400003)(356005)(81166007)(6636002)(2906002)(8676002)(40460700003)(36756003)(44832011)(8936002)(5660300002)(316002)(54906003)(70206006)(86362001)(70586007)(478600001)(110136005)(7696005)(336012)(47076005)(26005)(1076003)(6666004)(83380400001)(2616005)(186003)(16526019)(426003)(36860700001)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:03.3074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a767bf6-c1b6-4dbf-f825-08db481a3719 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6152 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. Signed-off-by: Mario Limonciello Acked-by: Tom Lendacky --- 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 7ef7c09b4a2f..46dd7a2ade18 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 platform_access_vdata pa_v1 = { @@ -435,6 +436,7 @@ static const struct platform_access_vdata pa_v1 = { 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 */ @@ -442,6 +444,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 */ @@ -450,6 +453,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 */ @@ -458,6 +462,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 Apr 28 18:55:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677907 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 1A1E1C7EE22 for ; Fri, 28 Apr 2023 18:56:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346516AbjD1S4L (ORCPT ); Fri, 28 Apr 2023 14:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346461AbjD1S4I (ORCPT ); Fri, 28 Apr 2023 14:56:08 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2055.outbound.protection.outlook.com [40.107.102.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 456B05249; Fri, 28 Apr 2023 11:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZhZtYtTWOSusHKVG1KjPStAx6qW21RBgUThmUtmAXl9HlHodFsZ6xGCPvC0fx1Mk4H0mfapCy3ArBOpHHFpwKNcSVQd05sljiYNdmpCKZrDhcBkNdlDpRRYrUmzzMVfc6+A9JJL/fLxFlLMVjafPqinB5HuJjPl/wTigcIPA7bO+vt86q58j6X30NxAhYbWj4p4alhJZRaGaGQCrWRiBzdcyeeSFgXTrF+8cl3JoutOihoHGCNHq0mrAKW9LjhrkFZ7G3NEWxpIK+Pq/Q1Y5HmS79+X8bgs+njnzsxPq9DSw5YZeS8IV2AkC/WIG+YFJEoKR/128t8cDNqedkJ9PQ== 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=uCK3UFN7kfeIWQFj87Ev9Xsr6tgtpWCv/5cTFSUBohk=; b=nemAPUSg94rtzUqrsKTS2667fC+c78ARA+dMUVLrSHzoI2F8zSDgx9XI5N/TJZ9JK1ChbWOtBXqWl7C/Ut9VcxwJgnsJ/d3Qol8QQ921q3yyzxyGnFljI5yPy1qaEe3rtnttziqWZc9QTKVy0XSUvZoUnVTDgKuUk6fQxMx2oUebD1zL91riNmaalZ6kd/0/iZjXYAr+rUed2kbGtvFUnhjyEK061SIwnb0srA35Yk4MKC2ctlwnGgFWilugZNyZSsUOTLI/R+QQRYUJNmsL3rJJc8CzwiqqBGzR3T5E1M2Hyy04cg5x1Z90EeQQHr2flBv1QUhB2dGlRyfff/urKA== 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=uCK3UFN7kfeIWQFj87Ev9Xsr6tgtpWCv/5cTFSUBohk=; b=YA5R3dQHArK/3S12ygQgPI0YoUrjR1ua4ilgqmF/aazWXU6fjBZKWX/tMpM505GXWURx3U2PYUDZ3jZ4QslXHwDwqRxfpVgQ9+33cpXAjfp+sri6TJhACh8bHLHj4AAGXO3QhXm8W6/lEkc5/BRqcEKPa2col5cuiQ/tTz500mQ= Received: from DS7PR07CA0018.namprd07.prod.outlook.com (2603:10b6:5:3af::27) 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.6340.24; Fri, 28 Apr 2023 18:56:04 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3af:cafe::93) by DS7PR07CA0018.outlook.office365.com (2603:10b6:5:3af::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56:04 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.25 via Frontend Transport; Fri, 28 Apr 2023 18:56:04 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:02 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 04/10] crypto: ccp: move setting PSP master to earlier in the init Date: Fri, 28 Apr 2023 13:55:34 -0500 Message-ID: <20230428185543.8381-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT050:EE_|CH2PR12MB4969:EE_ X-MS-Office365-Filtering-Correlation-Id: 90b9aea5-083c-4bb2-78d1-08db481a379f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6NKDy9yUb3K9t/WX6FE/BvU+sPuUAmlW7jEHlKAdiZJuwZMkbG+eCb9m2GT87OGXBbl/BG1IWLcrp+JLmUHdDl0a3wbeTp4DTRz0KNKBbkWE+Ai7lMaIMwcwxn/I5G6Ha+Q3cyXXUAnpgZ4We4IlJNwQRFhq09lfvuxGQpfYWDB0ZfCjMDRWF4q7ci4tquMAZgzaJSyndh+jezvRYrKfWK+Q9WCZS+ceCzzcjQ3PIWu+SST/H/nXl5Y9cHzUTnAnWLw6KK7PTpCXcJ8DxO1l5eiOP8EQl87pC8edtSQ5FJsNojvrXnAxr/X9wpcpslhOTP4add/Jze7dySIXO84szS4ySao8y1/rEfHWyTYnEG1d4r++vBli88i9cYRV1E3JovF2iNMfEmZA9bfU/czhpcWgtjOwENMaBM28YYi+NOmXJxRJc5Qv4Zyi8s6sNqvdObKx2Rn8nAmRPs8y2dzT1dOl7RYf35iNjAxFYXM0EmAWdguV9a/QLRy+fL2Wd4f4TGq58xuGmrXweZWJY/qDtlpgaIhcIQJjGSfVtIaEhhHtBYFX1lPCjFVDV64Mx0Yi6xwtE4YxrF9PWP10kIwJgamvvKMLxBOeLeGV7s6I6MpX62hJ3tT7SAr7TQY+OxYYpE9WD6AVR7kigOhPPQkxJ7ewN4ScH4evdMJlY+jFZ27RrvACAnpL5M/1SqnVcxgBAl5llYQFIFp0KosVHriiiowJsOqykT2rLUF1xSKtPgA= 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)(396003)(39860400002)(376002)(346002)(451199021)(36840700001)(46966006)(40470700004)(86362001)(2906002)(82310400005)(36756003)(4744005)(40460700003)(40480700001)(6666004)(7696005)(4326008)(83380400001)(2616005)(47076005)(186003)(36860700001)(16526019)(426003)(336012)(1076003)(26005)(44832011)(6636002)(70206006)(70586007)(478600001)(110136005)(82740400003)(356005)(316002)(5660300002)(41300700001)(81166007)(8676002)(54906003)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:04.1667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90b9aea5-083c-4bb2-78d1-08db481a379f 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: DM6NAM11FT050.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 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 --- drivers/crypto/ccp/psp-dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index e3d6955d3265..e9136e398174 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); From patchwork Fri Apr 28 18:55:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677906 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 2DC6DC77B60 for ; Fri, 28 Apr 2023 18:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346586AbjD1S4h (ORCPT ); Fri, 28 Apr 2023 14:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346561AbjD1S4S (ORCPT ); Fri, 28 Apr 2023 14:56:18 -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 18C646192; Fri, 28 Apr 2023 11:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K0ic1l8DflTLjA4XhLbE/Gbrii+kHdmoTuJEPamgvRDRuYHnYPSNj1gR6kjZK0X0HDDl73SG3GXVcUds8jfu1vY9fZC30gHRLWNovuGM+73kfw4BwCwJtr8DEMF0ZMgyY+OL0jjly3K9GykJn2URdI+a62/FkKo7e9ZtkF5dqIqcpBVkf+T099km8wGszkMJ4cT4LQz+VkRLcN0tzi40oq7FL5flJmDcQrM1XZWPX/PVniVvT/OAWE4MsGfjfbo1yS926wDF67lLz+PeGOwRGeRgExz2D+aBWze8SqRf+488bMlFFtfs8ZKr5tCrqHd1kiRzvTZTG2/yeEK02+jpAw== 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=G7Jyn/1umfUbPu2sHytVWKn9fJ1Oj8RFTMdyZE81ii4=; b=hPcrCUi+IOjcaXvuDil5nQD6RhKECw5IDwkASjfTp/wTA8xazFt241n1x/TyQLNC+GxQPtdrNvpMB5kb+o67YAOhFv9LFTXD6RGx27jEUsYTfrnFl/d8b0p+GawOo4WLZd+syUiOFiGY2KKkw8p60NqCsjlHDz30yqYZcSe2/kcNg7JbCH1zIJfI2Aj6VLh4z31In4KOozAgH7uuuk4dWAfDpUqQTK2bfB3aqU2ew1odUDvMMvRA7RTBmLDv0aV/cNtCehMeZJC+Ex3aR8XE3abB0NwGvTbO7cLfeNKhEUopSQ2WiAltKuavT451zVD4AAEY5+g6IInF4/MRTRHs8Q== 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=G7Jyn/1umfUbPu2sHytVWKn9fJ1Oj8RFTMdyZE81ii4=; b=POH+9O2mghIzbWooqZrzbfhlrtMFk2T3Ns8FYJzriiUEvdY+x5ufgXPqI/MUCq5XNd9jSS5leOhHxnH8TcHRkUsr2IUlLzzg8iuJI28mfgUVrgfsLn8BZU4UqUu3hQzrQWHzr0BaSh4XKerYq3yYO4CQ/TjWWChe5z/di9x4Wvo= Received: from DM6PR11CA0045.namprd11.prod.outlook.com (2603:10b6:5:14c::22) by CH3PR12MB8459.namprd12.prod.outlook.com (2603:10b6:610:139::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24; Fri, 28 Apr 2023 18:56:09 +0000 Received: from DM6NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::90) by DM6PR11CA0045.outlook.office365.com (2603:10b6:5:14c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56: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 DM6NAM11FT045.mail.protection.outlook.com (10.13.173.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.23 via Frontend Transport; Fri, 28 Apr 2023 18:56:07 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:05 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 05/10] crypto: ccp: Add support for fetching a nonce for dynamic boost control Date: Fri, 28 Apr 2023 13:55:35 -0500 Message-ID: <20230428185543.8381-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT045:EE_|CH3PR12MB8459:EE_ X-MS-Office365-Filtering-Correlation-Id: d3cef5eb-650a-4e53-51d4-08db481a3978 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WVNod3Qv3wTWUtAYnnkvD6/J7an6WjBuvEHDetlfFxKTfTTW2vgLbLu0fZuOrtXu8r1gVW9qV3w4R2E3VTSarxJeox/C7zMN4gaB/3S/7iwG6kb5Mm6gSBZUNMagU5R2hfYffi5JvJ59M2jky3qR3/gsu8TYr9IbtVjEqqjfGLtqCuTajB9l3I6x1pu5IwPhwBaHQqgKZyX8WK6gPFvNvCEZpbYvNluAo+WEotfTOxbNnu28IO57Zg6l0wn9YzvwUvvrdi9Tf86BxBgukMVvcNzZl6PfuweieToG/n/LWyStLdGYGV+xRM7XkDwnX22hu85x2lHgiIW9zQEOsR10pjKRcvsMHIU9csZ2D758+Cyb+C1/T7cF2bJl6u0i3P2zHb0Vky6dyOwD5HjBlYmHnHmnVEYWXTPTqEi//xTZ3gS8a3Q92Im8Jjz1CdYA8T4PvDDlSPnKFlrA0dGzaDlOwvdXmB4At2MAUWtfUzq94ShYDVl0eYSncIF3FxeD9J6e4scLsvrHFWzLKPOG6AKfThYuNTNp4+J2ZZgEHeSpRNuXXdmWKypAUpeZoulT2W8+uqynO2VHGqMtqx2qbCV5EKkRdlgkKabOBwLE+XZ80AscVfneD9p4ujjkK0jI9S+5zqFhsc0PHQfGPXD9PQ+rg9OgInKIu/pC4z3HqlOMbubDXjlUp6mD+bPuHvRELDuz8Mmb4YpCF/hIJ17NJmvrqbdEWjK1HXst7qaOciruadw= 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)(376002)(346002)(136003)(396003)(451199021)(36840700001)(40470700004)(46966006)(40480700001)(40460700003)(110136005)(6636002)(4326008)(70586007)(70206006)(478600001)(54906003)(8676002)(8936002)(5660300002)(82740400003)(356005)(316002)(41300700001)(81166007)(7696005)(16526019)(186003)(47076005)(426003)(336012)(36860700001)(83380400001)(6666004)(44832011)(1076003)(26005)(2616005)(86362001)(36756003)(82310400005)(30864003)(2906002)(66899021)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:07.2812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3cef5eb-650a-4e53-51d4-08db481a3978 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: DM6NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8459 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 e9136e398174..15cc7bfe663d 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) @@ -214,6 +221,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 46dd7a2ade18..116da677f33b 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -457,6 +457,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 Apr 28 18:55:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677765 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 09791C77B7E for ; Fri, 28 Apr 2023 18:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346570AbjD1S4j (ORCPT ); Fri, 28 Apr 2023 14:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346567AbjD1S4e (ORCPT ); Fri, 28 Apr 2023 14:56:34 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 342DF59DC; Fri, 28 Apr 2023 11:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhtMFMcJedMUdgyy3Vj4cf5y1XldXr7E7Lo3oTJAXCbFm1XjmffkLIez3Y7RPbaAxhsGWkxskH4wHfsilLyWrHdl/tv02uZFwatdgQyemTXplAglgPJYWOtoGOyI80f1ys9/9s/S763PD5HXWm6gxVK6+Sdtp7P7tLwndD+zGGfGpX5CUhptgnYFULoSHoJmMbrx9m17Nje2PZNh3ekU23ODgbrgOu56iAmhyTMtBFPBcAAiJnfhFYtXGZe6QImky4F6yDqqN+3MZHGLQLTbIT79aRts/uCI2jZnh8WQzAg8UEWxiFpgkz9WVYmcucbFDLCYxS/p7Ew2aaTBSByx6w== 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=Uy3LoPQQsmBUT9+F4MTe4rfcGT+R4Md72qoc04kqUjUrs8HTauhwTnq5owgbhG8FP/+o5yBLtf3Ji04PEFL/2yem5YTvIu9ZTngE8z2b3EWryrkpBmKNAAyy3ACDExHOhel3/Fu1cCZnQVbRTDi/SkJLmRqYC4lATUL9U98tTLBtiFLjNenjk76hLrISUVWFGvfntY5j1aUKVhP1GblpfD3RD8pj6Ep8DUW/f0340EXqJvtjcMOh6/U00DhKAyqB8DgU384scfFulOtxmJiICPeH1WMRxt+wdH+mJ17DHDYT6zAwUwe0PGsoiwxHUI/4AWK+JJd15d/mRI/MdSAnQw== 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=Qfqzfn04U7AkBTu3rjApxoYIXkxJ4hHwc6cjqVaBB+dI5WexyklBhfkW9e0rW2huHNRTQi7dTEPoAQXIpBJucf7KbyJv4qTAN4gE8Oe5dn8F3sM1A+5weIrGnaF+IDQLbBh0e0ShycVSbB+hvS48wPGP8Jv5WKoZe3pKIgo23tQ= Received: from DM6PR11CA0069.namprd11.prod.outlook.com (2603:10b6:5:14c::46) by DS0PR12MB8272.namprd12.prod.outlook.com (2603:10b6:8:fc::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.22; Fri, 28 Apr 2023 18:56:11 +0000 Received: from DM6NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::db) by DM6PR11CA0069.outlook.office365.com (2603:10b6:5:14c::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56:11 +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 DM6NAM11FT045.mail.protection.outlook.com (10.13.173.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.23 via Frontend Transport; Fri, 28 Apr 2023 18:56:09 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:06 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 06/10] crypto: ccp: Add support for setting user ID for dynamic boost control Date: Fri, 28 Apr 2023 13:55:36 -0500 Message-ID: <20230428185543.8381-7-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT045:EE_|DS0PR12MB8272:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e1fbfb5-a809-4426-fdbe-08db481a3b0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kdodYmJeeL9bvxKhJBt35CibAV2aqG3obWxG5mPMiZLGz8ZW6FFZHahJ2rb9gHIGSCIOIwZZ4wkVcdS+taa/hCLS/PFt6U7jgHlDGjNmiMZpX+U3yrwXv0Pyb5g0aK9p2Gt8OUwbURZe9lm3nrIw+xX5o/03ZF39LIZpaE+KtkgP692Kco/fp2Od3uoFC9/VqqIEXiMjdNsQTkTJFoSqMDrbAFjLPyxWUyS+ofiJhrmF0n3B8l0XM7YKx93WRNB+wflnq/5GHVwkcDCqtLn6+JdCoIuGJEJwySRgk3gNYpVY6pangsl6ljq85eFDIBgIUC5h7rm2OwAolWkzOEm9f3NLuPxSZUTT+bayxwi4s/H8s8taYIxIJyY6nNJocswsMNbaXLk5/gN2zIgvGdEV82GOidDHDezTBGlnbLYVBLQBBrKXLPx2S4xOhf4OTAMyA756EcpftL4cXDbHvQbp1ZLWeUQfYP+MjBoa//s5CkbTDhXzVrJRtvjGgazlCG+cYxOtK3vRLfUU84ESRm3JqJrwq1qN4wlvx5P0nFdqnmf/RStVmY3NNlkHekyMjtrRdGZktD8KuBvdtKoCXM2BRgJ8YGtgdN0As0mDKQWBV/mL23ZEw5Yh1PUSZTBhgDmGSALqOdRtXZhwzoHllLuefw7sAPsHbKFqcoBVfrJyAWHC+8lvWfoOqaZh1PuWRNwLTBIY/R8RZNqL92PNl1zgJgpEnp2REIBHkTWv0zt7O2M= 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)(39860400002)(376002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(336012)(426003)(83380400001)(36860700001)(41300700001)(1076003)(40460700003)(26005)(82740400003)(36756003)(186003)(16526019)(2906002)(2616005)(7696005)(6666004)(40480700001)(86362001)(5660300002)(8936002)(8676002)(47076005)(4326008)(316002)(44832011)(6636002)(70206006)(81166007)(478600001)(356005)(110136005)(70586007)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:09.9529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9e1fbfb5-a809-4426-fdbe-08db481a3b0f 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: DM6NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8272 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 Apr 28 18:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 677905 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 DD94FC77B60 for ; Fri, 28 Apr 2023 18:56:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346603AbjD1S4k (ORCPT ); Fri, 28 Apr 2023 14:56:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346545AbjD1S4g (ORCPT ); Fri, 28 Apr 2023 14:56:36 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2056.outbound.protection.outlook.com [40.107.244.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFBA0659A; Fri, 28 Apr 2023 11:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VjWruWPzY0sZwFTIWCCHXAaoDvCl4HV3VqD8Q0nzSxtZuL2A+919zKrLWma2BbOvQv5FF1uSzQFCHH9dWqElWkCF2MeHnvwMgTlDcWTFnKDD/jkUf1NFDDRVnaSwRrCeszEghejDb0cuFyNA4BXGS9zwO/AgVttHm3bjkNLGSGErt21WPfbco0fjJnykvkGTP+21oQy7NBOfj2TeajOuh+9KxB1kk5pzbYfe7wJ3Uflq7NNsfQl2ASWpOpcMX3jEfdfhIwSEkuMq+RuMpWHRlLy8l2/rssYzBspXN2mk1ArTWMC9/DcYlyewrBxVE/hHfllaDnw+iFKk47pOfnZSYg== 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=mVDuJioyJcsUD267AuBe5iJ7HvyjifR6ErWswm5GfKmoAiX1vzGu50D7HAQs81Rz+0ISpb1V5m2rKQpQ0BrYtLyOhAbLINEQq0VEO/6WtRuBTMMsLZ0WJIDn9PtiiSbnfOcCIkCb5Vsh7NNFHC3c3GEbyBiGlrE8UDzwkkZRJsg1jT2I0DpmuFiBgUUcxNcv/pspna4S4uDCw8cVYt9j90MyPK8Pymdt2BjiPHnoVjKfn3g/6c5K8gtMn2QEUXy0xraucM+e0dWjYlIrmB0Nox9PEONOUNEHx5nWxbWxitcOVpI7aeFaL8lKJp/0SrlCe2fyJansgsC/aB2UiFeLDg== 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=Heb98Bry/+zMqFffrvTEUtRWOjBbtwDLqdYPZSjhI6HPX2hjWCfe5rPXsgDiaZtM31OBbfEtsWTQ8RzAFdD+Sw0JmphFxaKWha8+FYCDd/wp9Wf1MwA6eum12KRWqO+HkpxZvOcJ9z5V4lBjZw/ulAXoOXsl9xE70eEQKtBPTKY= Received: from DM6PR11CA0069.namprd11.prod.outlook.com (2603:10b6:5:14c::46) by LV2PR12MB5727.namprd12.prod.outlook.com (2603:10b6:408:17d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.21; Fri, 28 Apr 2023 18:56:12 +0000 Received: from DM6NAM11FT045.eop-nam11.prod.protection.outlook.com (2603:10b6:5:14c:cafe::7f) by DM6PR11CA0069.outlook.office365.com (2603:10b6:5:14c::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24 via Frontend Transport; Fri, 28 Apr 2023 18:56:12 +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 DM6NAM11FT045.mail.protection.outlook.com (10.13.173.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6340.23 via Frontend Transport; Fri, 28 Apr 2023 18:56:12 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 28 Apr 2023 13:56:08 -0500 From: Mario Limonciello To: Herbert Xu , Tom Lendacky , John Allen CC: David S Miller , Mario Limonciello , , Subject: [PATCH v2 07/10] crypto: ccp: Add support for getting and setting DBC parameters Date: Fri, 28 Apr 2023 13:55:37 -0500 Message-ID: <20230428185543.8381-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230428185543.8381-1-mario.limonciello@amd.com> References: <20230428185543.8381-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: DM6NAM11FT045:EE_|LV2PR12MB5727:EE_ X-MS-Office365-Filtering-Correlation-Id: 2429067a-ee09-47ea-c1e6-08db481a3c5d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jcCoQPnH0N6a2w/A/robeilUgdZa1UpH2pZnVnz2xBdj+30qV3DrEcddHiScmpOQe7mo3T629CbrhSmyAEHQIMZ9g2vGeI4PrDCIH7RLWwpKGZvfNHebiijR75aEQggCVfU27dWcxN65AVriw5x0HGKhMlC0/Y2eHaOFSybBUO0Zxmje+SLOL7ipQe3G5JCe8S2Hmat8fg2UPrxprGwBpy5lvZmYPWSTpdIUqqhpkggujYG7y4bOUsmpyBO9EghZmMkWlgFmfHpdM1x5cq37AGdsq0G7BktIXQYorti/V6Hwlbj3bOqio5iOQTIW6lMjjrDdfu6KgssYm8oy/8RVOm6rVNl91CQ+PdqArFHuxYP2uNLOOtgniPqQTjAr2OnGzX/Pt0pTeAB/waaaiD37HJZGWPoeBGhSVeaGYyqpKiKBbTVZXnO3A3mVpcjjgOKYWYjxEh3ndUixuwvrDIylmTizegFAjybSpmP9QkZ6q8xvIdfj+h6II4tmd9n6GDYau+rrvgSIYYQ1y184qF2uBJtS5DFuUGJWRplKcz0oZs7gvNhIExMxFlEJDJUplCs6+rCWIS47f6a1lJX5e4ZIVHFyNZfv+71T1K8FKJhHLl0fzclokkCouGP/HFneMU/aI52+beeBXUB3Iukxgcu++4ihwTsLZADyb/v43z61DeGmo76ZWfH9QjOvXmXNm4XqX92oMOuw+GHWcXXvLvt3XDI2yjlHcoPLDy7IdleDbJ4= 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)(39860400002)(396003)(136003)(346002)(451199021)(40470700004)(46966006)(36840700001)(110136005)(54906003)(7696005)(426003)(4326008)(83380400001)(6636002)(36756003)(82310400005)(86362001)(41300700001)(8936002)(6666004)(8676002)(2616005)(478600001)(16526019)(44832011)(186003)(316002)(26005)(70586007)(5660300002)(1076003)(336012)(70206006)(81166007)(47076005)(40460700003)(36860700001)(356005)(2906002)(82740400003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 18:56:12.1402 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2429067a-ee09-47ea-c1e6-08db481a3c5d 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: DM6NAM11FT045.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5727 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__ */