From patchwork Thu Mar 31 21:12:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555327 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 3954EC433F5 for ; Thu, 31 Mar 2022 21:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241653AbiCaVN5 (ORCPT ); Thu, 31 Mar 2022 17:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241645AbiCaVN4 (ORCPT ); Thu, 31 Mar 2022 17:13:56 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2055.outbound.protection.outlook.com [40.107.94.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D504422B6EF; Thu, 31 Mar 2022 14:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gqx5mQpXRydIcFTGKNxhZehMG9+6n/iioUQ2JJFlDOWUP5LJp7HKKNSDCiSNGDvSoWfUsJqR+X2quUYae/r3Q39hGLGqMPJ4fPDUqkMJyQG03+3qxUDzTWYMzV8BP58h96V+5Beiye4dGgYoWLqAAWEMlgBmknePBcCywnEEGMriQkhQBOHUPcAghXTt+ziSyNM4cia1dhcC11wNwTQESgppQGIyqZPe3mtaldWifpfp4QP7SC9yqMddFwhZFovIKpGWoLFufOr7vFZvQ+TzX2Nvl3CKiBw15kqjkl/9LnowNzSrgmmfACgsxni7btqY1XIzB2EzWMh3Axy704F/TQ== 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=2co5/rOsE00fTAmw0G6l6ePxmNfTTKvFhHjEQWydebY=; b=RByb9MzrQWixMVpJhYlpi0+DzFalG4Q8sms4983lEML1KJOdw8ZBHbx0MkkBDFEzB9MDHz66W68/nLjqvh+qCKyp5JothlpQFj39F72lKYp1Pm5xFhpCHD6J3JYRf1yFv1fDyXj7XTHM3ahopwwOZPsN8rAFd5xXC9QudHObr47CWPrLIcyuJef9E12uChVgfM36fmoVosQIu6StPkydnpS7Dq5ar9bJN8QlSmEHcPhyskYQGotawagMCRuTl7rOFeIhYwDn4Hnnau7tzbl/mObU8C197+nzBUC/BMh6bbsoyBS80QsjKomaebE1LcOJvFUL51//rPHj36mFuLfjRg== 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=2co5/rOsE00fTAmw0G6l6ePxmNfTTKvFhHjEQWydebY=; b=YK+qYwWyWZB6O8vd577+jbZNakD595pXSYL67mHw5cwBx3dhOb27Zj6aWrdhpjUZBDkPW8n6cptsg9ZTNryFUfwst/665SviZe/LJmG9wT93cVEwLojHRGmvVW0btr4pe4OmwrE7TQaq6PPYfrYyQ8fS0jHBgjCHZAsvlqKGG3s= Received: from MW4PR03CA0135.namprd03.prod.outlook.com (2603:10b6:303:8c::20) by CY4PR12MB1494.namprd12.prod.outlook.com (2603:10b6:910:f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Thu, 31 Mar 2022 21:12:06 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::e9) by MW4PR03CA0135.outlook.office365.com (2603:10b6:303:8c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Thu, 31 Mar 2022 21:12: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 21:12:05 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 31 Mar 2022 16:12:02 -0500 From: Mario Limonciello To: Tom Lendacky , John Allen , Herbert Xu , "David S . Miller" CC: open list , "open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER" , Kerneis Gabriel , Richard Hughes , "Mario Limonciello" Subject: [PATCH v3 1/4] crypto: ccp: cache capability into psp device Date: Thu, 31 Mar 2022 16:12:10 -0500 Message-ID: <20220331211213.2844-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331211213.2844-1-mario.limonciello@amd.com> References: <20220331211213.2844-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b5297ea-cde4-4f28-055b-08da135b1bd0 X-MS-TrafficTypeDiagnostic: CY4PR12MB1494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fGZ0mW5RzgSXTosNQhLSxW8IMIT/MOpL3q1LrDTTAEYqjSFi/UtRB2pKgkpMzBWU58Y+9spZvbh+INqDh0Lkcl5GD5YLRbEhzXuPjW85JQqxqd2/SQ2bTHmpRkaD0MlMrzbHwzIof7fNJ4lm1ByL9sPbwkZd5HnvVbkUBPq7vmSQRz3lFIyf8eLCSDwNL+EdYLw/UteSkFyruRBuC6iX76WX3Mc6f9/ovPVXET3L9VzOvTQTFW2UjbSRyME1M2WQL0TeOz0R81snIesYwrX0sKH8n9ySQq3hKIQkKzPGbYe/V+Fdqe/dNp/at64xYCdSNpfMqEJqerTegFzVlOzu1jPQgN7gvHdsz62vELR5DaBbLhhKnFxTsMGTi03zg8zZfgIVk3mjvN+q+PtPL/9fLthLfwpSagWrn+18tQsClSVrHzr+RtY/8KKX3vo/iCDo1J+zvSYlTi//j1ceXH39hqQOXoqa7f1jtpS8fVOrfWlesPRUlv4kIKdp9HmPgmzyUigGvVlY3qkhF0XQIPWO3CLrn5LHtibztmh3ilMU/Rovjw7kHJcdPbOx3exU7bt66296lb+zOipuWs2QC8d3CbwRPh2ycUk/hD8xzMabPjPMRHy34ea7FaB21p6eXP6z93vtDky4XsafYqWfcQPVca/vpWsH7eldjQdjWSMrEMG+EJR1pUNGcXG9KR7viPMm1Xxl0gHNcwqhZGrT1ko5Jg== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(82310400004)(110136005)(316002)(54906003)(36756003)(7696005)(2616005)(16526019)(1076003)(186003)(86362001)(26005)(336012)(426003)(6666004)(36860700001)(70586007)(8936002)(5660300002)(83380400001)(44832011)(8676002)(356005)(70206006)(2906002)(508600001)(81166007)(4326008)(40460700003)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 21:12:05.4040 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b5297ea-cde4-4f28-055b-08da135b1bd0 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: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1494 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The results of the capability register will be used by future code at runtime rather than just initialization. Acked-by: Tom Lendacky Signed-off-by: Mario Limonciello --- v2->v3: * Add Tom's tag --- drivers/crypto/ccp/psp-dev.c | 37 +++++++++++++++++------------------- drivers/crypto/ccp/psp-dev.h | 5 +++++ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index ae7b44599914..8cd404121cd5 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -70,17 +70,17 @@ static unsigned int psp_get_capability(struct psp_device *psp) */ if (val == 0xffffffff) { dev_notice(psp->dev, "psp: unable to access the device: you might be running a broken BIOS.\n"); - return 0; + return -ENODEV; } + psp->capability = val; - return val; + return 0; } -static int psp_check_sev_support(struct psp_device *psp, - unsigned int capability) +static int psp_check_sev_support(struct psp_device *psp) { /* Check if device supports SEV feature */ - if (!(capability & 1)) { + if (!(psp->capability & PSP_CAPABILITY_SEV)) { dev_dbg(psp->dev, "psp does not support SEV\n"); return -ENODEV; } @@ -88,11 +88,10 @@ static int psp_check_sev_support(struct psp_device *psp, return 0; } -static int psp_check_tee_support(struct psp_device *psp, - unsigned int capability) +static int psp_check_tee_support(struct psp_device *psp) { /* Check if device supports TEE feature */ - if (!(capability & 2)) { + if (!(psp->capability & PSP_CAPABILITY_TEE)) { dev_dbg(psp->dev, "psp does not support TEE\n"); return -ENODEV; } @@ -100,11 +99,10 @@ static int psp_check_tee_support(struct psp_device *psp, return 0; } -static int psp_check_support(struct psp_device *psp, - unsigned int capability) +static int psp_check_support(struct psp_device *psp) { - int sev_support = psp_check_sev_support(psp, capability); - int tee_support = psp_check_tee_support(psp, capability); + int sev_support = psp_check_sev_support(psp); + int tee_support = psp_check_tee_support(psp); /* Return error if device neither supports SEV nor TEE */ if (sev_support && tee_support) @@ -113,17 +111,17 @@ static int psp_check_support(struct psp_device *psp, return 0; } -static int psp_init(struct psp_device *psp, unsigned int capability) +static int psp_init(struct psp_device *psp) { int ret; - if (!psp_check_sev_support(psp, capability)) { + if (!psp_check_sev_support(psp)) { ret = sev_dev_init(psp); if (ret) return ret; } - if (!psp_check_tee_support(psp, capability)) { + if (!psp_check_tee_support(psp)) { ret = tee_dev_init(psp); if (ret) return ret; @@ -136,7 +134,6 @@ int psp_dev_init(struct sp_device *sp) { struct device *dev = sp->dev; struct psp_device *psp; - unsigned int capability; int ret; ret = -ENOMEM; @@ -155,11 +152,11 @@ int psp_dev_init(struct sp_device *sp) psp->io_regs = sp->io_map; - capability = psp_get_capability(psp); - if (!capability) + ret = psp_get_capability(psp); + if (ret) goto e_disable; - ret = psp_check_support(psp, capability); + ret = psp_check_support(psp); if (ret) goto e_disable; @@ -174,7 +171,7 @@ int psp_dev_init(struct sp_device *sp) goto e_err; } - ret = psp_init(psp, capability); + ret = psp_init(psp); if (ret) goto e_irq; diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index ef38e4135d81..d811da28cce6 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -45,6 +45,8 @@ struct psp_device { void *sev_data; void *tee_data; + + unsigned int capability; }; void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler, @@ -57,4 +59,7 @@ void psp_clear_tee_irq_handler(struct psp_device *psp); struct psp_device *psp_get_master_device(void); +#define PSP_CAPABILITY_SEV BIT(0) +#define PSP_CAPABILITY_TEE BIT(1) + #endif /* __PSP_DEV_H */ From patchwork Thu Mar 31 21:12:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555665 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 22E8EC433FE for ; Thu, 31 Mar 2022 21:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241664AbiCaVN6 (ORCPT ); Thu, 31 Mar 2022 17:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241652AbiCaVN5 (ORCPT ); Thu, 31 Mar 2022 17:13:57 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50F21223872; Thu, 31 Mar 2022 14:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZUMZ8CoEbnKnjLT6zBOnK11NgQqJtbaW2jngLpuNVeymuJFuP4WS/qw/8awxbzMYhqz+LmuMqYzfBXt+SPJ3uz2wD/VAw6oJN18wBX9ImER29DwvWKT//xtxGbADGSkHs8UIuDAvmyRxxKgSf6lJ/B49z9dnarZUGqj6pPw6i4t81AMOibexI2mXxdPg2HYCL87RBUHCl0VYSysQ8M4VuHu3WwUOJFJ3csj4LzgMy9Gm/Gv4I7E2gaANkbjb1pTOjHEAdgmVeQu2ewhxAPfaF/s18iik2pYgr3OR4meef4ymMDHtxxZNPykkB9wgcJWsssh3H8X6fPEU3Mv+ny7lew== 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=rUm/R3J7CVYyM9Z3lyG7h0i6ngl+76S2QWnp5/dooEk=; b=KHDd9BC6bxvkoE2VpURCZN/TSBI/bCmUeqeS7UoDGkTSC7FRC8nBKCBFFF8cq5r3jT61ZbCUJOMjf3TdmNWaNMmIGEW5DgJg2orjKFhhvnMKmCDuLhg39dUjSGgDobprJgCkdOHYmOGMK7M+OdgkkbYljHFGiScBdurUrZzFZxYtlbYNQa5u0e0et7lrNcTIt5aXfl3OCbqBzIWdAY6E4LYS2Qz1rKCk2jDLKIKtwOWweSqchammluHgOI8DU+cxarXI77H0Wgti0ePuu0dJ8JvzEqn7FFgwuVFxsPEKyaTX6ZCTRNoq0QJ82kRxFHrMdi4UIQ2ntSED0wErIunqlQ== 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=rUm/R3J7CVYyM9Z3lyG7h0i6ngl+76S2QWnp5/dooEk=; b=iuUqslDQsMm/+hOub6ZgMfIIjJOjczcOWdeMn0nKkfgKp3aZjjly9bNuY9rDmJnYroiQwrD5BZlseMOfk9vo7ywOpUfhF5YMFOSdcH6w1SLSVjf2SmzUkdacpgVGZLxexY7EfVYLKW0O60w3Q2DIpRhPHHpVg8CAw8ei1lfjz9c= Received: from MW4PR03CA0127.namprd03.prod.outlook.com (2603:10b6:303:8c::12) by DM6PR12MB3001.namprd12.prod.outlook.com (2603:10b6:5:116::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Thu, 31 Mar 2022 21:12:06 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::a7) by MW4PR03CA0127.outlook.office365.com (2603:10b6:303:8c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.23 via Frontend Transport; Thu, 31 Mar 2022 21:12: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 21:12:06 +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.24; Thu, 31 Mar 2022 16:12:03 -0500 From: Mario Limonciello To: Tom Lendacky , John Allen , Herbert Xu , "David S . Miller" CC: open list , "open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER" , Kerneis Gabriel , Richard Hughes , "Mario Limonciello" Subject: [PATCH v3 2/4] crypto: ccp: Export PSP security bits to userspace Date: Thu, 31 Mar 2022 16:12:11 -0500 Message-ID: <20220331211213.2844-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331211213.2844-1-mario.limonciello@amd.com> References: <20220331211213.2844-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 98212183-b95c-4391-e904-08da135b1c57 X-MS-TrafficTypeDiagnostic: DM6PR12MB3001:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7zocdKVex/WXO/rhW0DNC33QXWL6O0QKG4sayW+Be07LePfvgHeujf/fPhn56K456ed3zJCzCJVJISy2OXc+h20LspF8FH2ejeQHjb8HY/ix+VZcRfZ3FWSaY7XJgHviLaScfGZ2Pi3+3cZzZPVu9g3djuLjmxbfth4Hc9RPS7+nlcD6ostL994w10i3FUZPuXLAj2blRrJEIXXZ/nN/xNXnWu6WssBmz46hdlwFB8s9v786D1rHKimXOO6tCwIiNfh0LVg7QS3i+9j3bTgY9MQss+8gL6Fi4RcHmt4/JXmgcjUntFDuWfLCzO07pQBFBqStwjUb3IW4dYuabD0nd2uxenLE8nN0HPxeUlrXNLkc4XEy5AjkRG1XtutS9h8+raI5p3bs56pmyanUqcBgobRX5v/prZrrO0CBb3DPkABYnnTkwiBs3PEqF1/OpQSH5PtOA1XdDF4mN5TZlSm5RgUX7rlqI4l1iEQvIZaZrwjAbliIVtGEsMbprEA7+jNCvJFyeoY6Z1+0ReM6Io+DRrWFtMkX2f/XWQ0lZD2yGiecNTv9Z9S/RQTOMsnFUBasgIT4EuD9CgtBu9nPut+FawvcxEGCJcjW9ZZ+UKu+/GnAhbv9XJ+AJ1jW0LPwKf0ZRBbEZGUAYqUz/cZlH2BRq00Fu9s14xQoA3w8NyqIycHRioq5KjATvGYpVwKkQ2sV9rBfUr8K2XLGISUZm0vAQ== 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:(13230001)(4636009)(36840700001)(40470700004)(46966006)(356005)(8936002)(1076003)(508600001)(47076005)(186003)(86362001)(426003)(5660300002)(83380400001)(81166007)(36860700001)(16526019)(15650500001)(36756003)(336012)(2906002)(26005)(110136005)(40460700003)(6666004)(70206006)(2616005)(54906003)(7696005)(70586007)(8676002)(82310400004)(4326008)(44832011)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 21:12:06.3102 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98212183-b95c-4391-e904-08da135b1c57 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: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3001 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The PSP sets several pre-defined bits in the capabilities register to indicate that security attributes of the platform. Export these attributes into userspace for administrators to confirm platform is properly locked down. Acked-by: Tom Lendacky Signed-off-by: Mario Limonciello --- v2->v3: * Add Tom's tag --- Documentation/ABI/testing/sysfs-driver-ccp | 87 ++++++++++++++++++++++ drivers/crypto/ccp/psp-dev.h | 17 +++++ drivers/crypto/ccp/sp-pci.c | 62 +++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-ccp diff --git a/Documentation/ABI/testing/sysfs-driver-ccp b/Documentation/ABI/testing/sysfs-driver-ccp new file mode 100644 index 000000000000..7aded9b75553 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-ccp @@ -0,0 +1,87 @@ +What: /sys/bus/pci/devices//fused_part +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//fused_part file reports + whether the CPU or APU has been fused to prevent tampering. + 0: Not fused + 1: Fused + +What: /sys/bus/pci/devices//debug_lock_on +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//debug_lock_on reports + whether the AMD CPU or APU has been unlocked for debugging. + Possible values: + 0: Not locked + 1: Locked + +What: /sys/bus/pci/devices//tsme_status +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//tsme_status file reports + the status of transparent secure memory encryption on AMD systems. + Possible values: + 0: Not active + 1: Active + +What: /sys/bus/pci/devices//anti_rollback_status +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//anti_rollback_status file reports + whether the PSP is enforcing rollback protection. + Possible values: + 0: Not enforcing + 1: Enforcing + +What: /sys/bus/pci/devices//rpmc_production_enabled +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//rpmc_production_enabled file reports + whether Replay Protected Monotonic Counter support has been enabled. + Possible values: + 0: Not enabled + 1: Enabled + +What: /sys/bus/pci/devices//rpmc_spirom_available +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//rpmc_spirom_available file reports + whether an Replay Protected Monotonic Counter supported SPI is installed + on the system. + Possible values: + 0: Not present + 1: Present + +What: /sys/bus/pci/devices//hsp_tpm_available +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//hsp_tpm_available file reports + whether the HSP TPM has been activated. + Possible values: + 0: Not activated or present + 1: Activated + +What: /sys/bus/pci/devices//rom_armor_enforced +Date: June 2022 +KernelVersion: 5.19 +Contact: mario.limonciello@amd.com +Description: + The /sys/bus/pci/devices//rom_armor_enforced file reports + whether RomArmor SPI protection is enforced. + Possible values: + 0: Not enforced + 1: Enforced diff --git a/drivers/crypto/ccp/psp-dev.h b/drivers/crypto/ccp/psp-dev.h index d811da28cce6..d528eb04c3ef 100644 --- a/drivers/crypto/ccp/psp-dev.h +++ b/drivers/crypto/ccp/psp-dev.h @@ -61,5 +61,22 @@ struct psp_device *psp_get_master_device(void); #define PSP_CAPABILITY_SEV BIT(0) #define PSP_CAPABILITY_TEE BIT(1) +#define PSP_CAPABILITY_PSP_SECURITY_REPORTING BIT(7) + +#define PSP_CAPABILITY_PSP_SECURITY_OFFSET 8 +/* + * The PSP doesn't directly store these bits in the capability register + * but instead copies them from the results of query command. + * + * The offsets from the query command are below, and shifted when used. + */ +#define PSP_SECURITY_FUSED_PART BIT(0) +#define PSP_SECURITY_DEBUG_LOCK_ON BIT(2) +#define PSP_SECURITY_TSME_STATUS BIT(5) +#define PSP_SECURITY_ANTI_ROLLBACK_STATUS BIT(7) +#define PSP_SECURITY_RPMC_PRODUCTION_ENABLED BIT(8) +#define PSP_SECURITY_RPMC_SPIROM_AVAILABLE BIT(9) +#define PSP_SECURITY_HSP_TPM_AVAILABLE BIT(10) +#define PSP_SECURITY_ROM_ARMOR_ENFORCED BIT(11) #endif /* __PSP_DEV_H */ diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 88c672ad27e4..b5970ae54d0e 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/drivers/crypto/ccp/sp-pci.c @@ -32,6 +32,67 @@ struct sp_pci { }; static struct sp_device *sp_dev_master; +#define attribute_show(name, def) \ +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; \ + int bit = PSP_SECURITY_##def << PSP_CAPABILITY_PSP_SECURITY_OFFSET; \ + return sysfs_emit(buf, "%d\n", (psp->capability & bit) > 0); \ +} + +attribute_show(fused_part, FUSED_PART) +static DEVICE_ATTR_RO(fused_part); +attribute_show(debug_lock_on, DEBUG_LOCK_ON) +static DEVICE_ATTR_RO(debug_lock_on); +attribute_show(tsme_status, TSME_STATUS) +static DEVICE_ATTR_RO(tsme_status); +attribute_show(anti_rollback_status, ANTI_ROLLBACK_STATUS) +static DEVICE_ATTR_RO(anti_rollback_status); +attribute_show(rpmc_production_enabled, RPMC_PRODUCTION_ENABLED) +static DEVICE_ATTR_RO(rpmc_production_enabled); +attribute_show(rpmc_spirom_available, RPMC_SPIROM_AVAILABLE) +static DEVICE_ATTR_RO(rpmc_spirom_available); +attribute_show(hsp_tpm_available, HSP_TPM_AVAILABLE) +static DEVICE_ATTR_RO(hsp_tpm_available); +attribute_show(rom_armor_enforced, ROM_ARMOR_ENFORCED) +static DEVICE_ATTR_RO(rom_armor_enforced); + +static struct attribute *psp_attrs[] = { + &dev_attr_fused_part.attr, + &dev_attr_debug_lock_on.attr, + &dev_attr_tsme_status.attr, + &dev_attr_anti_rollback_status.attr, + &dev_attr_rpmc_production_enabled.attr, + &dev_attr_rpmc_spirom_available.attr, + &dev_attr_hsp_tpm_available.attr, + &dev_attr_rom_armor_enforced.attr, + NULL +}; + +static umode_t psp_security_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; + + if (psp && (psp->capability & PSP_CAPABILITY_PSP_SECURITY_REPORTING)) + return 0444; + + return 0; +} + +static struct attribute_group psp_attr_group = { + .attrs = psp_attrs, + .is_visible = psp_security_is_visible, +}; + +static const struct attribute_group *psp_groups[] = { + &psp_attr_group, + NULL, +}; + static int sp_get_msix_irqs(struct sp_device *sp) { struct sp_pci *sp_pci = sp->dev_specific; @@ -391,6 +452,7 @@ static struct pci_driver sp_pci_driver = { .remove = sp_pci_remove, .shutdown = sp_pci_shutdown, .driver.pm = &sp_pci_pm_ops, + .dev_groups = psp_groups, }; int sp_pci_init(void) From patchwork Thu Mar 31 21:12:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555326 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 C6DB3C433EF for ; Thu, 31 Mar 2022 21:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241669AbiCaVOB (ORCPT ); Thu, 31 Mar 2022 17:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241646AbiCaVN7 (ORCPT ); Thu, 31 Mar 2022 17:13:59 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2051.outbound.protection.outlook.com [40.107.223.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B672335CF; Thu, 31 Mar 2022 14:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KEcuogOJykEwmVgjLC64wtEefSUcdTUB0qFhxzsiKeQ7cJBt6cG+NBI6Xjy/z432XROh3vl0E/bqAYQZ0/DvsHrx3ogQYFIyIfuCqbTXNFr8axrdb4ikRhjoBOp8Edm6baYRMCyn8UDthAVfaQ8ffhnzHSvG41gIvvJZhYgga1qMTS8jJBy14VBnByGtVrag4MIDGBn+MPvzPoMukV8wwswHto1u+fuCPEVB+NtiRByZX0XvQiJnoTMzP0tQOspp8JT8Sthv/tJ9p7kqkG4TGdcUi2R0W8WfTBNUTzSmBqoM6s51ZBjbR+pXrG/GvNUa+RPA5Jd54Onp31YLPDwixQ== 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=4Ntjp/aedIsu6xGNCH6gycu57Z5n6dEx01U734rW34Y=; b=LzLmVA7RTBa1sXWpfwlkPXQbu1UMwSntuzb/jQIzesRZuGArsB/8xQInRj3rmjqAjbwQEzNVxi26IwhKMJN6gpLXNdJvVoaKxZq1hb6+ShBKEwgt/zL4ZI7728z4BSt6SIheuKNS+ZKaMqtjxGqQt9MfjgkbQOzKONTPZbn5vjXMcpE7FNpFVK79TygcQGIeMXgeSrkvkxKlQjwfORcpy13rUc5IKDf6NMlZzp6cqMxOhtwbdusMbhrOjC9JP0NcDYns95L2FX84IZwcEslaPUBZDEBYktUYJgT2ZIiNErUt6aZBp5hrRygXNrj0HI3/HDThUSMxrQux7ND7eX7J2A== 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=4Ntjp/aedIsu6xGNCH6gycu57Z5n6dEx01U734rW34Y=; b=nE2iv/LskJ8I9WiunAoOxXdfN+uJHcF/YoyTRfWBd0qiqpkRmUp9SYu/b+QcWci3nJOC39Pz1tXlLcym3RNTx9/wpr8+bhJ/b8yXBWkXIJLc4nizp3TAA5CSzKiBfyRIN3k+SV4uAUMRwE5DNCwp0UkShpNZF6shgNgJWkmxxNI= Received: from MW4PR03CA0147.namprd03.prod.outlook.com (2603:10b6:303:8c::32) by BY5PR12MB3794.namprd12.prod.outlook.com (2603:10b6:a03:1aa::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.23; Thu, 31 Mar 2022 21:12:08 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::be) by MW4PR03CA0147.outlook.office365.com (2603:10b6:303:8c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.22 via Frontend Transport; Thu, 31 Mar 2022 21:12: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 21:12: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.24; Thu, 31 Mar 2022 16:12:04 -0500 From: Mario Limonciello To: Tom Lendacky , John Allen , Herbert Xu , "David S . Miller" CC: open list , "open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER" , Kerneis Gabriel , Richard Hughes , "Mario Limonciello" Subject: [PATCH v3 3/4] crypto: ccp: Allow PSP driver to load without SEV/TEE support Date: Thu, 31 Mar 2022 16:12:12 -0500 Message-ID: <20220331211213.2844-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331211213.2844-1-mario.limonciello@amd.com> References: <20220331211213.2844-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e9f94d4-b6b1-4c0d-b846-08da135b1ceb X-MS-TrafficTypeDiagnostic: BY5PR12MB3794:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hs/8Tr3FZzTVt1WtS19gk5CoAcJ+16fQby7DbyuzQLJizKFvO9fzvNnSOigFuW1QdL9I5/DGTKmvdOBQDXvSA/2UvSrFIUp64ePgtCHTn76dIWRu0yOR46ziuaym2WoBrC0t9fGD5OWisxPPBph69/DUHy2YCYnKp32APrvbC9f2iZdBEHJEtgRluTvsAdytyeCOMiDlLqrNiBLPCjfXRHU+uXFWHlfJLUi28Bl0XdG1/3NdCNy+sShmcdzjgvvuh7W/zNotLHZdlB4rD+1ISJCiBDhbTqAlTLISTg2FnxqamDstwUOELNc4Og9ToT8AGtCLQuwEcS3epR8bGnR+45RSHkUWUqp7NdsOhmhIlNbUhRiOQa6JSjvkphRCZg09jnKPu3JU+MOCY4z6swqJkKE6m7aiPr1U8LaVMXV3o9ppMKa7qlzLPSQdLbH+/okdtfS3v+612tEcGbSlksTrLF91Dc6hRT+HCGGNnUZKWnan0QqVc4RjxglTWCY0unY2stT/Jh70RXTBinYmW0QBJ5lO0W9Jm0pELlc6C6wEJEAO6ZWIO8xcatlh3A/w7mfMME0jHwjvoChwcVfkJtpdwDBX6+4ShUUiuBx84/uzNRr11N52Up5nwzS4suUAH12F1zbZpKkNDOFAxqRWj5IZXMoCHJn8jkXKr4uP4qAH+eLt/Vth+xd8jns6cM242wZPQMQlO60rkYNCIC1UCaXRQQ== 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:(13230001)(4636009)(46966006)(40470700004)(36840700001)(8936002)(36756003)(44832011)(4326008)(508600001)(6666004)(70586007)(7696005)(2906002)(40460700003)(81166007)(70206006)(8676002)(5660300002)(47076005)(316002)(110136005)(54906003)(82310400004)(356005)(36860700001)(83380400001)(86362001)(426003)(336012)(186003)(1076003)(2616005)(16526019)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 21:12:07.2789 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e9f94d4-b6b1-4c0d-b846-08da135b1ceb 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: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3794 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Previously the PSP probe routine would fail if both SEV and TEE were missing. This is possibly the case for some client parts. As capabilities can now be accessed from userspace, it may still be useful to have the PSP driver finish loading so that those capabilities can be read. Signed-off-by: Mario Limonciello Acked-by: Tom Lendacky --- v2->v3: * Remove helper function, and still set up IRQs even in this case to keep cleanup process the same v1->v2: * Whitespace fixes --- drivers/crypto/ccp/psp-dev.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 8cd404121cd5..a3b7b5130be4 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -99,18 +99,6 @@ static int psp_check_tee_support(struct psp_device *psp) return 0; } -static int psp_check_support(struct psp_device *psp) -{ - int sev_support = psp_check_sev_support(psp); - int tee_support = psp_check_tee_support(psp); - - /* Return error if device neither supports SEV nor TEE */ - if (sev_support && tee_support) - return -ENODEV; - - return 0; -} - static int psp_init(struct psp_device *psp) { int ret; @@ -156,10 +144,6 @@ int psp_dev_init(struct sp_device *sp) if (ret) goto e_disable; - ret = psp_check_support(psp); - if (ret) - goto e_disable; - /* Disable and clear interrupts until ready */ iowrite32(0, psp->io_regs + psp->vdata->inten_reg); iowrite32(-1, psp->io_regs + psp->vdata->intsts_reg); From patchwork Thu Mar 31 21:12:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 555664 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 4C178C433EF for ; Thu, 31 Mar 2022 21:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241724AbiCaVOY (ORCPT ); Thu, 31 Mar 2022 17:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241676AbiCaVOA (ORCPT ); Thu, 31 Mar 2022 17:14:00 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB7F223872; Thu, 31 Mar 2022 14:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OsT+PxDuIdvH/YSAkJIQ4mcEorYFFN2hAh6yJ4LV0L1p5GuoQ8+8JAnhoBN9864aprxhrLHdHt0rdxI1vFKizw8/6svoTgFWv67TAf4cB8QB2OyM7+04VbYd6GqwHOp1ltk4awpvex5CheiM34S0Yzo2rWKlGlsrjx5YZJYDmElVb5ze1Kwh0BiNHw4XR1fTV4erqIw8OcQ0ggnmOncA2r9knuHOjnMWMlbRTztkge4Tlhybxp+3+aFSGTNbprZlheJ08k19ucGDs21VUx0M0bWm1+BoRo5SueOVx84oz45aJWXK35VgF6kG1w63/gVcBnxE+I7fKmUu0Jw1Ua8FkQ== 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=qYPIHBx2LmPULSamdRNsWiXpJcuExp/yHCz09gERJV4=; b=R/CqF9RlWL1cXfkYUYGBj7+o7dw+omKgqmSrUklZRHVCiBmZDDbOQ24PRKDMCleQGbxzeYB4Qp0VNw/09gSTeT9jJ1phlh/n2SfB3q1b9kHxVnkjNpsCong4oADJsIMvxwzQw1JZX8WxxbkxZhRJDQFXvrnVWWhsddN/lT2YClwU5S8gU2US1QVrmbgCurQfPejSyKI2vVGkC0Y+rZNEHuOepKBt8ySSUAtEyVor69QLblquBDr/a6nVkELfEOssbCX4JzX2BrFDNmktCUL3cYnmlbWxDwVSMsLa7QdX7ItApUWUHzV4pT9yVveCKCK+aFn9VIFql2UlUMM9gnqInA== 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=qYPIHBx2LmPULSamdRNsWiXpJcuExp/yHCz09gERJV4=; b=b3riI43I74YRLU49N2AizMy96gxbbab9CDadLQunKAa/L5mp/Lzrtr/3UUiwIVrunGAZGjd0CYCsn2Ywt3CFScqrR7D0nkhQMEcNDiXW1ERjmI5JQzb91/GPhgYP9Mx/0w1jbYUQhthEneGYQezOpxMJsbC/4gZrtnbHxh6Ki7Y= Received: from MW4PR03CA0146.namprd03.prod.outlook.com (2603:10b6:303:8c::31) by MW4PR12MB5667.namprd12.prod.outlook.com (2603:10b6:303:18a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.19; Thu, 31 Mar 2022 21:12:08 +0000 Received: from CO1NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::e2) by MW4PR03CA0146.outlook.office365.com (2603:10b6:303:8c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.23 via Frontend Transport; Thu, 31 Mar 2022 21:12: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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT005.mail.protection.outlook.com (10.13.174.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 21:12:08 +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.24; Thu, 31 Mar 2022 16:12:05 -0500 From: Mario Limonciello To: Tom Lendacky , John Allen , Herbert Xu , "David S . Miller" CC: open list , "open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER" , Kerneis Gabriel , Richard Hughes , "Mario Limonciello" Subject: [PATCH v3 4/4] crypto: ccp: When TSME and SME both detected notify user Date: Thu, 31 Mar 2022 16:12:13 -0500 Message-ID: <20220331211213.2844-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331211213.2844-1-mario.limonciello@amd.com> References: <20220331211213.2844-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ec53764-f551-483d-5ea0-08da135b1d97 X-MS-TrafficTypeDiagnostic: MW4PR12MB5667:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ugyLLP5KjQD2hpraRkwsM9Mh1O7zajardXrtiuvQTQoDZBcGojI0yzths49PhTp4QTVKcGjfJavZHuX09UYdh2p1Ih04aGaXcNUY4r9+DiWv9DVvuuKxzSsxLUHAT2B0Iyv1q07OOvl7DCBZKTOJNotyrqHY9SV7xOTgOV2tqtiigAJSVXswjoJjyeoB7nSpRd43u5K0LFcMECzO0kgN06SQRGtj4uPJSAgH18EMvMiPat1ygb5ewPg3bgwjTH0iI3okhHDYiC7Be9PPVCdYxMzxfkgOpIW3NRqlExjakmyjZfxSZmpihESwtKO6/sc7N3rmoV2RNBH7Oh63vxjUddFMAhmrVkn72jTqdwU+vQkOUZhfbjXUZQ0xqa1EpfbyErdrBaYCmqcQ8u5ogU3BH/vBS2Sl+2jtICysSJo+KWdfpda9fF8RsVqnz457IXuQe8UAaVQSiUMtS1JzMUyAz1Hx3LphtQ+dsp9G2v8pyRJuCEvEcnEk8AaaYUMqtWjNO7JigehycyU1Yu4NGEYPv9cj39+dY5cpWa4uJKwBPaiQ8VGBX2cBACIuub8KTbo+dxxuv9QaS+HbA2F7C5nRJSGkbgJlkvI1dZqg6PbTfJ6uYO/eFn88UqKNfjpEBO1gv3vHIBKyJvDag9hx40HeBQfra5ay7dvlo9o2R7zpX9ODeZcwK9WRJtiO/EtTa7iw43vHCcgYqaW/U6GAvcr2Rg== 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:(13230001)(4636009)(46966006)(40470700004)(36840700001)(81166007)(2906002)(426003)(40460700003)(86362001)(8676002)(356005)(47076005)(82310400004)(54906003)(508600001)(110136005)(6666004)(316002)(70586007)(44832011)(83380400001)(70206006)(5660300002)(8936002)(7696005)(186003)(26005)(16526019)(336012)(36860700001)(36756003)(2616005)(4326008)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 21:12:08.4038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ec53764-f551-483d-5ea0-08da135b1d97 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: CO1NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB5667 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org CC_ATTR_HOST_MEM_ENCRYPT is used to relay that memory encryption has been activated by the kernel. As it's technically possible to enable both SME and TSME at the same time, detect this scenario and notify the user that enabling TSME and SME at the same time is unnecessary. Signed-off-by: Mario Limonciello Acked-by: Tom Lendacky --- v2->v3: * Remove extra whitespace * Reword comment v1->v2: * Reword notice about TSME/SME * Use cc_platform_has instead --- drivers/crypto/ccp/psp-dev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index a3b7b5130be4..c9c741ac8442 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -74,6 +74,12 @@ static unsigned int psp_get_capability(struct psp_device *psp) } psp->capability = val; + /* Detect if TSME and SME are both enabled */ + if (psp->capability & PSP_CAPABILITY_PSP_SECURITY_REPORTING && + psp->capability & (PSP_SECURITY_TSME_STATUS << PSP_CAPABILITY_PSP_SECURITY_OFFSET) && + cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) + dev_notice(psp->dev, "psp: Both TSME and SME are active, SME is unnecessary when TSME is active.\n"); + return 0; }