From patchwork Tue Aug 29 15:07:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13369418 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5C13C83F1D for ; Tue, 29 Aug 2023 17:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237896AbjH2ReT (ORCPT ); Tue, 29 Aug 2023 13:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237667AbjH2Rdo (ORCPT ); Tue, 29 Aug 2023 13:33:44 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2086.outbound.protection.outlook.com [40.107.243.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE6AEC2; Tue, 29 Aug 2023 10:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NgWxGvfNS1h63T+7ce1aXMXqLnaotm275S3LAx684c8mom+4Z72Zc4RxKxuJ7t5ZB3ICNcpC2zAvO9oHwwrkm3TtfhYo5MntrnE4cGIUNTHxNIq8KCB1qH2oNBPBW+/28Zva0bNLkK5VoB6Tf4BNna6xHYQyDrhVk8BOsG3STVFydGgrwucvbMAhnlfR8in/cikG+e9BPRdZJBciK8kVdRY81vQf1Fr5SxmrLIzpco6erFQ7lvgr4msWYEdNGnChQpk0z7cFRdMuVGxYDYnrxVP5eitzqNU5LDgNkoaAyO4XM3kYixZhqcUBYYZ9g6GeGeMKNHzi07v/OvosHuJboQ== 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=aYa2Qn6XP3jIT7igpRKKR4n7GoSXQMkt9N/o+t0Slbg=; b=JRm00Bn2iXcns6mDWJwfhIZ007UjNV6i78z6kQdnGmxWTlW7SKjKjrq4r0gGDjNME9/5EY7Va17YH1YZEvFGq87AcZ4UOyyeOqhryMWrNYcSz9ApqYsZzRrcvfQpymc2KDVIkcz5DppAtuIonRhO65DHC7My1uX3XXL03llfwPFX2KapW8SlXb46UpOahZfsBO+UHNuwjqHd6edMzc3nUB2QmVJy61NONyrUi6QOYagwtltAJICqUpoArn3/Iobf12aFOqH+AyxtvYFJgDYgsHE0uIpee1qrv10lEGWA7+ckKjMjOAA75N/bXCuvUu5lcCDlzdRY7A8Gpfy0fUeXWA== 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=aYa2Qn6XP3jIT7igpRKKR4n7GoSXQMkt9N/o+t0Slbg=; b=PU7uRtNYDinz0mQZmXegF9LbLhGCtG/fVpTekgWclF6SbGox19m0QzMORT3U6WJyXsZI9tl+2ikxVJ9RPaIzq887q9ADlEPtV4SX9S4qLvx2gXE5TyhCDGsUoesPdNUjpJv21UUcBYgxTTEUP4zz5eUmOyt9OWEHegrMN/xyIW0= Received: from CY5PR22CA0040.namprd22.prod.outlook.com (2603:10b6:930:1d::16) by CH0PR12MB5372.namprd12.prod.outlook.com (2603:10b6:610:d7::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18; Tue, 29 Aug 2023 17:33:38 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:930:1d:cafe::c7) by CY5PR22CA0040.outlook.office365.com (2603:10b6:930:1d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Tue, 29 Aug 2023 17:33:38 +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 CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Tue, 29 Aug 2023 17:33:37 +0000 Received: from AUS-P9-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.2507.27; Tue, 29 Aug 2023 12:33:34 -0500 From: Mario Limonciello To: , CC: , , "Mario Limonciello" Subject: [PATCH v3 1/5] crypto: ccp: Get a free page to use while fetching initial nonce Date: Tue, 29 Aug 2023 10:07:55 -0500 Message-ID: <20230829150759.156126-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829150759.156126-1-mario.limonciello@amd.com> References: <20230829150759.156126-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: CY4PEPF0000EE33:EE_|CH0PR12MB5372:EE_ X-MS-Office365-Filtering-Correlation-Id: 3629f795-4427-43d6-008a-08dba8b6143e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YpjoCgsCHbj1+l4DMc4FdZV99KoMYXPSzQJhUxtjQvRr/HC9C69vejw/JbwEpERzCpB5Dqa14uQ6743KwG99YHJNpamH10J73KrRZHbaB7+92c0MGO60fgcYF1qhIXu5Bzp8mUFD74v/p2xq3w5hc8NWsr+NKRgpNnVhMI8ZRTvzFdDPqzZP+nLvX+aPGmp7D2ytmu52kyG9LnjG9cOSlU9gghnGAAipz2Y78mGgGT5QJNmiX+QlfiEzHh//wl0zCUNBoGgVXoCgLTL1X+4+N5baTWFh/ynd0Zn4Uh6fwz7LYkV2UkFyEJ7TH3pUtg01tGrrxQpdyYilej59iYniGYlvUz3TILAkiUuxWNI0p5dWueckH/FVBwLCW8puw+ARmqaI8YhK635ANf4lc+tpM5EPQx5ffQDd8XV1LQ27YNFuwAsHIadK/FTT0aZ3IaW3QJLW691W0oBzZqmxBslAIq9OLbnxb6URAi1S3iemG4f/XQamhZCkOVg+J3v8ZW3Fja9lBoi3aQb5yrgwfgjBrfQ+RJggS44g97vmVKSy4qlPmeuW5kgvbkS7OI0J2KyDCZODuO9QexU0QotPFp5BPxwbgLMw6bgXhdr/Iul8B7Oq68Rc4N3cmQh8tSjYxbPX6xCCOr4lRxV8DImSP/mtx4b9qYCj53aC4kd67mYLm8niZ1UJtcL3GTvFmyP7mxbEW9495EXr1nBa31SbisjVsy2GVWhUyKvrKqrvGgKp3FFIDSmB6I+Bg0vzKO6qP7SOzPafJgImo4x76+UC2+DUMw== 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:(13230031)(4636009)(136003)(376002)(396003)(346002)(39860400002)(1800799009)(186009)(82310400011)(451199024)(46966006)(36840700001)(40470700004)(356005)(81166007)(82740400003)(8936002)(6666004)(478600001)(110136005)(70206006)(70586007)(7696005)(54906003)(316002)(41300700001)(40460700003)(36756003)(16526019)(26005)(44832011)(5660300002)(8676002)(1076003)(83380400001)(2906002)(2616005)(86362001)(47076005)(40480700001)(36860700001)(426003)(336012)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 17:33:37.9085 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3629f795-4427-43d6-008a-08dba8b6143e 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: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5372 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org dbc_dev_init() gets a free page from `GFP_KERNEL`, but if that page has any data in it the first nonce request will fail. This prevents dynamic boost control from probing. To fix this, explicitly request a zeroed page with `__GFP_ZERO` to ensure first nonce fetch works. Fixes: c04cf9e14f10 ("crypto: ccp - Add support for fetching a nonce for dynamic boost control") Signed-off-by: Mario Limonciello --- drivers/crypto/ccp/dbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/dbc.c b/drivers/crypto/ccp/dbc.c index 839ea14b9a85..6f33149ef80d 100644 --- a/drivers/crypto/ccp/dbc.c +++ b/drivers/crypto/ccp/dbc.c @@ -205,7 +205,7 @@ int dbc_dev_init(struct psp_device *psp) return -ENOMEM; BUILD_BUG_ON(sizeof(union dbc_buffer) > PAGE_SIZE); - dbc_dev->mbox = (void *)devm_get_free_pages(dev, GFP_KERNEL, 0); + dbc_dev->mbox = (void *)devm_get_free_pages(dev, GFP_KERNEL | __GFP_ZERO, 0); if (!dbc_dev->mbox) { ret = -ENOMEM; goto cleanup_dev; From patchwork Tue Aug 29 15:07:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13369414 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7211AC6FA8F for ; Tue, 29 Aug 2023 17:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237613AbjH2ReR (ORCPT ); Tue, 29 Aug 2023 13:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237821AbjH2Rdp (ORCPT ); Tue, 29 Aug 2023 13:33:45 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2056.outbound.protection.outlook.com [40.107.223.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F12AEC9; Tue, 29 Aug 2023 10:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJJDejlcpBkKTj4LzOLMgrKMyCUaD8vL7RkPInTwnabH3UMODiXZRWn4YdVtLMOM0jAfL9i5aGnPA395J5XWpixXWO2QJqr5Ct3EceklqoRepAPYQAWKsvj7gQ3Vf9+FKqngz4WKwFE68XueX9G6LTWrHsJqPryfWYHho67lVT78HRIrCXkCLcTsMANmi2WeHzIV1OEu8Gid3DQ4IB9WYmtXFmnDV3a5GBkC4jF0I6Yu1/H+Hq8Zzh4CKp1/NMiUVZ2ZRRKkcP6jSNDOz7BRzDY3mNV3pNkrytoSCFJpGVibCjGtUtTA1mPnOB6BR/R5lLOaPwoRYhlOizCWkkTBvA== 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=U/udfMVaiLkdoezvhE/wsL8Gx9l3vvOCa2PztxMIapI=; b=VSn0nMl5j/77bGUhp5NBxRgXT1RWAtVthcE3XI1nEgozhmrjicsAnBlEBrwubF1AmZ0rhCbVBDGWh6Uo9QDZyTqlDWx8uVUOiXvhGidd6ZCwq9xZ504pS+8mbT+zQeLTa6Ihj6lDWyqmjqOByCbNSPkkDETuPD3fuYeEdtfL02ethWEkWDLhTZfdnorPnW2IDZTgppneQw8F/Z9+iz1d2fPEcccw2jEyCjOH2oFsMil0Qf+hysEchPzipF6KOejEAZlkYoSDYNS0E06qWd4os+3Bs8Q35z1W503dnJQt02iRUX/prIR4aPvsVOy0PgwVqwtmTojz53IC2tRtl4/Fag== 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=U/udfMVaiLkdoezvhE/wsL8Gx9l3vvOCa2PztxMIapI=; b=xH04YKIkRCggEKNGXLo+fHYK0qCMOcv0Z/q/Jwoo3CqdwPluF/c4acTJQa9gABajM3uNmrcUxcMw4m3DXQXWpd7p4jdAwu+ix534x6guF9380y8/1lMRL5Gv/NRBMk6FTNYf7t0qByo7cEE8I8T0Tr1TEZGi6Lj0YqBH6kQH+ro= Received: from DS7PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:3b5::30) by DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 17:33:39 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:5:3b5:cafe::38) by DS7PR03CA0055.outlook.office365.com (2603:10b6:5:3b5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 17:33:39 +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 CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Tue, 29 Aug 2023 17:33:38 +0000 Received: from AUS-P9-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.2507.27; Tue, 29 Aug 2023 12:33:34 -0500 From: Mario Limonciello To: , CC: , , "Mario Limonciello" Subject: [PATCH v3 2/5] crypto: ccp: Fix ioctl unit tests Date: Tue, 29 Aug 2023 10:07:56 -0500 Message-ID: <20230829150759.156126-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829150759.156126-1-mario.limonciello@amd.com> References: <20230829150759.156126-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: CY4PEPF0000EE31:EE_|DM6PR12MB4337:EE_ X-MS-Office365-Filtering-Correlation-Id: 8af0acf9-95cc-4201-f411-08dba8b614d9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E36LGOVOww/K0FPw9bnhzK0yl4UcKES3aQWLyJcfEayMA8kplQVRIRYilkqJD+BdBoEdyXvBINWOIPCZEtA0RLVWubadnoGfqgk8YGJye9Sw3cWG3bcXLOgieTAbKo3igwaBnloUIhKCNap3HBrnRcK+6kldP8JScD83cd+H44POnGBtmbReR0Hvu0nBeHN/YJPZ9U67XkNFP2xdFCXydNxqBJueZLzgItonAWAW8UMDxs6xMUdRYbxwLlMEYE3rOGjsMycsLbZyrn4U0TVg0RcCYugYeKfB5piDP3hnhOK79mNdFgHQILUbAVuuabjA82nkq9HsQRaOl1iZDdIPUrGHXa2tRjMDfVv6LcBdelmPvlf6QD3YQVoHTrEjw7wne0ULgZ8W2Fmn8LlBzjTR26X9/HxP+ksTYRFonnb4u0X/XbGO/7vASsk3VEzUYyfAidG7j5grk/BDEv80KeGFx0dMU8TFhVPR7r1TqIB6AZRMT/zMV2oolAqMssWJb7rJcawjjpyW8iiWw3sqrUSbSDuLYpBJWJf4IWNKw76+Lqdpjb2sa7chT1+1ukBD48zO5mjwmDhT3S88RXAVgiShzLfc/ih4/+6Kor6s5jZQ+EaB57c5CFEHKaGoERpoNBHBkrW5E7KpXn/eOM8VzyWBZtBnNYnlK9wZj+nT+9o4Y5+okkLFEp3AzRELXoeJ1ST7cZ3lQ12B4HpZlUP/vaIiDBGvnXIn+YmoFJnGm89gXfcFIxHTG1wrUo+B7hctFLbL7qgMYT1w3hbame55JV2nJg== 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:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199024)(82310400011)(186009)(1800799009)(36840700001)(46966006)(40470700004)(82740400003)(6666004)(7696005)(81166007)(36756003)(86362001)(356005)(40480700001)(47076005)(36860700001)(1076003)(478600001)(426003)(110136005)(26005)(16526019)(2906002)(336012)(83380400001)(40460700003)(70586007)(8676002)(4326008)(44832011)(41300700001)(316002)(8936002)(5660300002)(70206006)(2616005)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 17:33:38.9462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8af0acf9-95cc-4201-f411-08dba8b614d9 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: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4337 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org A local environment change was importing ioctl_opt which is required for ioctl tests to pass. Add the missing import for it. Fixes: 15f8aa7bb3e5 ("crypto: ccp - Add unit tests for dynamic boost control") Signed-off-by: Mario Limonciello --- tools/crypto/ccp/test_dbc.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/crypto/ccp/test_dbc.py b/tools/crypto/ccp/test_dbc.py index 998bb3e3cd04..a28a1f94c1d2 100755 --- a/tools/crypto/ccp/test_dbc.py +++ b/tools/crypto/ccp/test_dbc.py @@ -4,6 +4,12 @@ import unittest import os import time import glob +import fcntl +try: + import ioctl_opt as ioctl +except ImportError: + ioctl = None + pass from dbc import * # Artificial delay between set commands @@ -64,13 +70,16 @@ class TestInvalidIoctls(DynamicBoostControlTest): def setUp(self) -> None: if not os.path.exists(DEVICE_NODE): self.skipTest("system is unsupported") + if not ioctl: + self.skipTest("unable to test IOCTLs without ioctl_opt") + return super().setUp() def test_invalid_nonce_ioctl(self) -> None: """tries to call get_nonce ioctl with invalid data structures""" # 0x1 (get nonce), and invalid data - INVALID1 = IOWR(ord("D"), 0x01, invalid_param) + INVALID1 = ioctl.IOWR(ord("D"), 0x01, invalid_param) with self.assertRaises(OSError) as error: fcntl.ioctl(self.d, INVALID1, self.data, True) self.assertEqual(error.exception.errno, 22) @@ -79,7 +88,7 @@ class TestInvalidIoctls(DynamicBoostControlTest): """tries to call set_uid ioctl with invalid data structures""" # 0x2 (set uid), and invalid data - INVALID2 = IOW(ord("D"), 0x02, invalid_param) + INVALID2 = ioctl.IOW(ord("D"), 0x02, invalid_param) with self.assertRaises(OSError) as error: fcntl.ioctl(self.d, INVALID2, self.data, True) self.assertEqual(error.exception.errno, 22) @@ -88,7 +97,7 @@ class TestInvalidIoctls(DynamicBoostControlTest): """tries to call set_uid ioctl with invalid data structures""" # 0x2 as RW (set uid), and invalid data - INVALID3 = IOWR(ord("D"), 0x02, invalid_param) + INVALID3 = ioctl.IOWR(ord("D"), 0x02, invalid_param) with self.assertRaises(OSError) as error: fcntl.ioctl(self.d, INVALID3, self.data, True) self.assertEqual(error.exception.errno, 22) @@ -96,7 +105,7 @@ class TestInvalidIoctls(DynamicBoostControlTest): def test_invalid_param_ioctl(self) -> None: """tries to call param ioctl with invalid data structures""" # 0x3 (param), and invalid data - INVALID4 = IOWR(ord("D"), 0x03, invalid_param) + INVALID4 = ioctl.IOWR(ord("D"), 0x03, invalid_param) with self.assertRaises(OSError) as error: fcntl.ioctl(self.d, INVALID4, self.data, True) self.assertEqual(error.exception.errno, 22) @@ -104,7 +113,7 @@ class TestInvalidIoctls(DynamicBoostControlTest): def test_invalid_call_ioctl(self) -> None: """tries to call the DBC ioctl with invalid data structures""" # 0x4, and invalid data - INVALID5 = IOWR(ord("D"), 0x04, invalid_param) + INVALID5 = ioctl.IOWR(ord("D"), 0x04, invalid_param) with self.assertRaises(OSError) as error: fcntl.ioctl(self.d, INVALID5, self.data, True) self.assertEqual(error.exception.errno, 22) From patchwork Tue Aug 29 15:07:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13369417 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5B08C83F1A for ; Tue, 29 Aug 2023 17:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237816AbjH2ReT (ORCPT ); Tue, 29 Aug 2023 13:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237826AbjH2Rdq (ORCPT ); Tue, 29 Aug 2023 13:33:46 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2054.outbound.protection.outlook.com [40.107.96.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1A91FD; Tue, 29 Aug 2023 10:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOqxKVLLm9/WJ89D66rMIQOFBlRW+b9uOrXGU0ESAkh0Pb09rpKyWmtZVjzNbD3utZcKdya7JDwZRZhZgzni9frfrKjGp3J/W5ez5pHT4yvMx92Wmj5HoLsBxByRQdeHAokxnOf9g+kPALvPU1YJ+ETkKvJp4qSkcX9LlBZ3LfAeMBGSgQnF8SAsZoDWZSve9g5H38Hzv2C/CLQe436wP6kATER4Ez4FSvQ+lzzdNsOEcIbt7JCjKH/cXFrcM7sbmCqXhow0fxRe6nTOssmZ3YuCmKiT3fdfBX3G4gzOKymaBdR3vGpLfaqgyLQ51QfpitwnGeAheclESwB7XtH0iA== 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=YI8lHO+7BvVObYlNycuuR5Y81uIHEpIvq8tgjj5vwLo=; b=gaLOCqf4EepmM5HcxkF/b73fIh4YcXv0DyQE57tCC443DdreedoH4SjFw/0DRF3qcvyBXZ2DzQ8Dvf95iQPQVeUEZIkTS67d080Z4TJRwwJ/jf8eDYI8h3M3srj9MMJzha0bB04CL6YXVvTNMmMRsTrFqWsix1yTpBbArt98/G8XVYA02nUbImPZ0sa8r6L5PLwm3hEcMiamQdG5bsW58vbR3Nn1t++LW0sKs1Zpm8yTVXnrXeurvVk22EVFD80V0aS8yd8kmS+ToJxPTqZLVjnE75oRrGL8m9nLaEInyCEK1EZsLugTaAqpJ/Hb1zUfXQWc5tftS8yoR+dQPwQM9g== 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=YI8lHO+7BvVObYlNycuuR5Y81uIHEpIvq8tgjj5vwLo=; b=FXlfwCcw2+kc+l9/sttm8KRGM4La1CWuDRwstA6GxfHExK19BcXAMIO+zI54uXbJrcVIDKZgWIYJRGoQGAvjxMQ1uZZNVqEJ7T3bhOsF4RBU5n0G404Ach2zGjakLhMPUWJZQsgTW9eqga3F1iEeFdqssaOcvsOhiCkqUSHpYbA= Received: from CY5PR22CA0040.namprd22.prod.outlook.com (2603:10b6:930:1d::16) by CH0PR12MB8508.namprd12.prod.outlook.com (2603:10b6:610:18c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Tue, 29 Aug 2023 17:33:40 +0000 Received: from CY4PEPF0000EE33.namprd05.prod.outlook.com (2603:10b6:930:1d:cafe::c7) by CY5PR22CA0040.outlook.office365.com (2603:10b6:930:1d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34 via Frontend Transport; Tue, 29 Aug 2023 17:33:40 +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 CY4PEPF0000EE33.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Tue, 29 Aug 2023 17:33:39 +0000 Received: from AUS-P9-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.2507.27; Tue, 29 Aug 2023 12:33:35 -0500 From: Mario Limonciello To: , CC: , , "Mario Limonciello" Subject: [PATCH v3 3/5] crypto: ccp: Fix DBC sample application error handling Date: Tue, 29 Aug 2023 10:07:57 -0500 Message-ID: <20230829150759.156126-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829150759.156126-1-mario.limonciello@amd.com> References: <20230829150759.156126-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: CY4PEPF0000EE33:EE_|CH0PR12MB8508:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a763936-a0fe-417a-a8ec-08dba8b61508 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RlGAX3whTr0ip1EwcBAJhNXqFE8Ddrqkbc8U6O1UEXCxzX0MkEXdUiDPqtsjeUviFvbpzkDKIl/Xxmh17GAVH0LDyl9LYrEskKp2awTWa2lFII6Vsu2rZIqmt3U67NfYYYvjvAQK4Ko+OkjD0cFr2Bx6N1fM2ZwCETfZdTdfYkGpG5aBJzY3QOTqP5E70URHR5Lvpa0YtLTGHPHwTjxHxwHvO2oT1o88cAkynudip6EhmE76I7SzzoyB2XFcD3asTvjfdjT90rph+jZFnMu19ghKtETcNS22mSlgp9O9lEQDqXCaNfn1l+YbT3mtR9PDRh5NNqth0nagr9H/3BV97qpLGSnupalTWpu7c+PT1ewFF4eH2os4wU6OIAgqwMic94JxDHrZs9AoI+VAEUKOjMrq0Zd0f1gdivr/sdvtvTDTO07ueFQ57AKURU5H/sNgIsItLllJDNEikLjrsVcdxuYekb8m5hgo9z3TdQZKKslqfV4CxlZl5HPg+FC9AtQJaoPsDRZ/49cKL2xSZ0xBg5dhujuVd/9o9lxCm+eJT/srpTliv8mIuvb5QPSASHM+JrdF9H6mDC0VK1Njdcx7MgKmPZOtJ94wyzrEnpQNXUQrwcbLE4ONGkUFjhJ/Lq0osPH6mxQn4Cqj/Vm5oOCbe5fz6GoPrdWfiDMtQqYBB6Dj+sT83hx2tpRol74do07XeXUTzUcNWBB7NUe4Zpxvyv0n4ya+lpy1nyIkGorzx9XsuJR30IqA8iIoL9q6IPcvIl+XAsDLVD+oRNsLFo7IpFNToBvzuqCfr8kPfN9ttLg= 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:(13230031)(4636009)(136003)(396003)(376002)(346002)(39860400002)(186009)(451199024)(1800799009)(82310400011)(46966006)(36840700001)(40470700004)(40460700003)(41300700001)(336012)(2616005)(82740400003)(81166007)(6666004)(86362001)(47076005)(83380400001)(478600001)(356005)(16526019)(1076003)(26005)(36860700001)(7696005)(426003)(40480700001)(70586007)(70206006)(54906003)(36756003)(110136005)(316002)(2906002)(5660300002)(4326008)(8676002)(8936002)(44832011)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 17:33:39.2366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a763936-a0fe-417a-a8ec-08dba8b61508 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: CY4PEPF0000EE33.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8508 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The sample application was taking values from ioctl() and treating those as the error codes to present to a user. This is incorrect when ret is non-zero, the error is stored to `errno`. Use this value instead. Fixes: f40d42f116cf ("crypto: ccp - Add a sample python script for Dynamic Boost Control") Fixes: febe3ed3222f ("crypto: ccp - Add a sample library for ioctl use") Signed-off-by: Mario Limonciello --- tools/crypto/ccp/dbc.c | 16 ++++++++-------- tools/crypto/ccp/dbc.py | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/crypto/ccp/dbc.c b/tools/crypto/ccp/dbc.c index 37e813175642..7774e981849f 100644 --- a/tools/crypto/ccp/dbc.c +++ b/tools/crypto/ccp/dbc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -22,16 +23,14 @@ int get_nonce(int fd, void *nonce_out, void *signature) struct dbc_user_nonce tmp = { .auth_needed = !!signature, }; - int ret; assert(nonce_out); if (signature) memcpy(tmp.signature, signature, sizeof(tmp.signature)); - ret = ioctl(fd, DBCIOCNONCE, &tmp); - if (ret) - return ret; + if (ioctl(fd, DBCIOCNONCE, &tmp)) + return errno; memcpy(nonce_out, tmp.nonce, sizeof(tmp.nonce)); return 0; @@ -47,7 +46,9 @@ int set_uid(int fd, __u8 *uid, __u8 *signature) memcpy(tmp.uid, uid, sizeof(tmp.uid)); memcpy(tmp.signature, signature, sizeof(tmp.signature)); - return ioctl(fd, DBCIOCUID, &tmp); + if (ioctl(fd, DBCIOCUID, &tmp)) + return errno; + return 0; } int process_param(int fd, int msg_index, __u8 *signature, int *data) @@ -63,9 +64,8 @@ int process_param(int fd, int msg_index, __u8 *signature, int *data) memcpy(tmp.signature, signature, sizeof(tmp.signature)); - ret = ioctl(fd, DBCIOCPARAM, &tmp); - if (ret) - return ret; + if (ioctl(fd, DBCIOCPARAM, &tmp)) + return errno; *data = tmp.param; return 0; diff --git a/tools/crypto/ccp/dbc.py b/tools/crypto/ccp/dbc.py index 3f6a825ffc9e..3956efe7537a 100644 --- a/tools/crypto/ccp/dbc.py +++ b/tools/crypto/ccp/dbc.py @@ -27,8 +27,7 @@ lib = ctypes.CDLL("./dbc_library.so", mode=ctypes.RTLD_GLOBAL) def handle_error(code): - val = code * -1 - raise OSError(val, os.strerror(val)) + raise OSError(code, os.strerror(code)) def get_nonce(device, signature): From patchwork Tue Aug 29 15:07:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13369413 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD2B9C71153 for ; Tue, 29 Aug 2023 17:34:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237823AbjH2ReS (ORCPT ); Tue, 29 Aug 2023 13:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237816AbjH2Rdp (ORCPT ); Tue, 29 Aug 2023 13:33:45 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EFFF91; Tue, 29 Aug 2023 10:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dpokTQaNDAiRRyIUTf6Bm3V8IobYb+6/4PAFUcYVTme95lCEH+kqyjVP9i3OHusfJ5jGcPKe2+2JEME2vVziwqADrrZDN1fraoxZyW4H8d673Z9kAXrEZTZU0fzMocGkwRGZRJbZEzF+LPu7sFvJgEXJ6mc6FNXehYK9NZg8yKJl4zpxlHu5c0wUvPJJCvzcEUkhWp9Lmsg2qI2ez4tMRkv0Mr9mDe0pLaZUdhCodKyupZHUBD4b9KQXJ1pZuZHLw+tP36QikDHSR8zxoRawqZLbkCHJ+vhwakaimnMjEkjzr+J5kThZ9oJ4vMjZ0tfq0Y7XseyYNT3wRJTKYrCmtg== 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=0xQllGKglFv1LKUOFury9p1WWhzqcRJqzuC6eBDtfvw=; b=COt/DCvMkCx+IjJgD1JPU/cUHQcS+c3+C1szf2gi+i2OV9N4Hlo4GUtVNpaSkBKFNjX1zuX9BElXWjBtyeswms3qEl0KClFEPxBpSoI/wocoMT8/8JcdI+psPKkMG6pz00H7Ndo7dl3nsmI0S8TwxO5QH3JmEKAyznMibgsV8RG7M6Dp4ECgnahtksJnf5egF2S0fKDxbXLvHzXX0GkNZwjLTUl227Fi1Mlch/KVaz7tFPHfJDrvsoIp6YfKicWN9sCcre2pzQiQBX4Htq4YpI1JKnY8WThiOKJC8MJYNwvFvFRYKo9EkjU02n3SwxZZmkYLjGzFplw6ntQrMOiLgQ== 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=0xQllGKglFv1LKUOFury9p1WWhzqcRJqzuC6eBDtfvw=; b=WQgp5LnxuW9of9njgxdi4akxVy6r3DSnDAXCz1iZr0QFU8+90U79v30l6A+H0Lsanx8f9ohQVOLIIdXsjgeZPTrCQ6dcEKjRiBqUdAbQSps0ipL49DiyTzlT83g7pP8JY79ayXqfsxJczSPDbHCtJZKtiMNwL5oZ32PL0BPZjBc= Received: from DS7PR03CA0044.namprd03.prod.outlook.com (2603:10b6:5:3b5::19) by DS7PR12MB6117.namprd12.prod.outlook.com (2603:10b6:8:9b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Tue, 29 Aug 2023 17:33:39 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:5:3b5:cafe::3f) by DS7PR03CA0044.outlook.office365.com (2603:10b6:5:3b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35 via Frontend Transport; Tue, 29 Aug 2023 17:33:39 +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 CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Tue, 29 Aug 2023 17:33:39 +0000 Received: from AUS-P9-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.2507.27; Tue, 29 Aug 2023 12:33:35 -0500 From: Mario Limonciello To: , CC: , , "Mario Limonciello" Subject: [PATCH v3 4/5] crypto: ccp: Fix sample application signature passing Date: Tue, 29 Aug 2023 10:07:58 -0500 Message-ID: <20230829150759.156126-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829150759.156126-1-mario.limonciello@amd.com> References: <20230829150759.156126-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: CY4PEPF0000EE31:EE_|DS7PR12MB6117:EE_ X-MS-Office365-Filtering-Correlation-Id: 02a9f915-0a1c-4582-c73e-08dba8b6154e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xD053orUs0y8jiUFe7ZRnfsgnJTXqRJ2oxQ+o6guPol7WLWaAMKLXB6Gf0Z9b3l5Xeovmld0OFCERxkWOnnjK7w61ob57ESzDMiOE7diiI2loeMFsVWrWYea/mxgIL3lI43HwdiwTHUMFrh8jIU/dnbD0HKkzAjOvNLz205V0qrjaYDrCziCXGiyYZtpdcHPtbcW/1N8kWNeFs65QNYjh+D0234KAZza1mqwlqeI42Jp8g1PEHrbm7hR74KREVMSPOZ0OduwmeZagJdA2j9VzF+Y1iKIshZBV9GF1aZlwT2IG80ryQFjFgBPGWImc4zkmcqsbG2rQcGv6xJYGDU6EmeU5tL+r6aIy2+kMAV4bR8AH33Bv0POIC8pkDoa6KkjutDGwULljaQiuNuIqCaSZwTeEI+ZByvaxYsYoj/kLWcjMAUmQxO+tL2QQoOY07af0JUtFofVX6kdOURNEv6TdqVZ8fkmr3sHyUpmKov6emTVtX4BP1PWytoYY5FC+8k4oNXk/O98PUQM9wA/+MRHLbmFj+nd4ZcmxSqmLhIrDcerQUEROkTyKrhxThlQTy7VDkpI/2fBYd2ejQwSgj96HYK7rhpxxLs382tAq98xzRgacg3AYLZU/Bp2LM8jyQz1K2n87kkf3hqwfJkZDN0VbD0KbY+czDlJTfct4Gw3K1buliQ19a398HJiO5tN3EWS69PhZzUlOAomt1ONN23cRT8ZRYO7wO/o9afihJdifNvEdPNJaGHcRrV/Q2UCLKIMtBBotXC1Pi+ZDr8MOkP2Gw== 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:(13230031)(4636009)(376002)(346002)(136003)(39860400002)(396003)(186009)(1800799009)(451199024)(82310400011)(46966006)(40470700004)(36840700001)(7696005)(1076003)(2616005)(86362001)(110136005)(6666004)(81166007)(478600001)(83380400001)(47076005)(426003)(336012)(36860700001)(26005)(16526019)(82740400003)(356005)(40460700003)(36756003)(4326008)(8936002)(8676002)(44832011)(5660300002)(316002)(70206006)(54906003)(70586007)(41300700001)(40480700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 17:33:39.6961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02a9f915-0a1c-4582-c73e-08dba8b6154e 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: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6117 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org When parameters are sent the PSP returns back it's own signature for the application to verify the authenticity of the result. Display this signature to the caller instead of the one the caller sent. Fixes: f40d42f116cf ("crypto: ccp - Add a sample python script for Dynamic Boost Control") Fixes: febe3ed3222f ("crypto: ccp - Add a sample library for ioctl use") Signed-off-by: Mario Limonciello --- tools/crypto/ccp/dbc.c | 1 + tools/crypto/ccp/dbc.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/crypto/ccp/dbc.c b/tools/crypto/ccp/dbc.c index 7774e981849f..a807df0f0597 100644 --- a/tools/crypto/ccp/dbc.c +++ b/tools/crypto/ccp/dbc.c @@ -68,5 +68,6 @@ int process_param(int fd, int msg_index, __u8 *signature, int *data) return errno; *data = tmp.param; + memcpy(signature, tmp.signature, sizeof(tmp.signature)); return 0; } diff --git a/tools/crypto/ccp/dbc.py b/tools/crypto/ccp/dbc.py index 3956efe7537a..2b91415b1940 100644 --- a/tools/crypto/ccp/dbc.py +++ b/tools/crypto/ccp/dbc.py @@ -57,7 +57,8 @@ def process_param(device, message, signature, data=None): if type(message) != tuple: raise ValueError("Expected message tuple") arg = ctypes.c_int(data if data else 0) - ret = lib.process_param(device.fileno(), message[0], signature, ctypes.pointer(arg)) + sig = ctypes.create_string_buffer(signature, len(signature)) + ret = lib.process_param(device.fileno(), message[0], ctypes.pointer(sig), ctypes.pointer(arg)) if ret: handle_error(ret) - return arg, signature + return arg.value, sig.value From patchwork Tue Aug 29 15:07:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13369416 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C45E8C83F1B for ; Tue, 29 Aug 2023 17:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237911AbjH2ReT (ORCPT ); Tue, 29 Aug 2023 13:34:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237834AbjH2Rdq (ORCPT ); Tue, 29 Aug 2023 13:33:46 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C1E6113; Tue, 29 Aug 2023 10:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xq04zIIPY8ognuYg/Ha7KrHcwJ1jU7Ani6IHNwlW2u2eWrkJDxcds2ZeNk+edEU7oPixwY85Yh+kNOg3NvcJVJm8ADkJGMVl+QdCorOR/H5D3lr1LTlqXjYAC7kdGYRY7xLJuTGeA3cQQo6u9RYbb8DbcBFhPGw5S7qUZViRvLUBihbPkXNxsnV0/dZ6sANA52bc/LBQZW7rAhrHoS7MUUZKKeic+rt7LnjkXKJOzrHaN6Bb8vKFXr1VeXfoSvizAgQfqhSIY8wVIIfhL/5odBixNqB+HaRGYDdRnFIHBytywv9DvkzjwmpgMzn5+AQR7Yahkop/0ALqLjJXSYQwaw== 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=swMK4AS+xNOzeidT5UnOauIodF3UBtnQjuO95XkmML4=; b=O2/oaw6RF1o/g31GgOBJCti6b30DFN9Ouzxh4XhKnnDziNZuu0O1Cbd3Rb6IfQn28UzVzi+lAY5gCgo0bt2+ZN8z3S0Q6zyr74TOHgXXskjRAgHefEh58Q9SWgcDSGZk7iuDJkxQcdqpERrcqsFYxztvOTh9PyiN+ytVFv2etgnUYXbe4Tp+NE2mGV70aHW2iF03Ai5r8Ea90CtuoNnOglk2LcraaM2Uw3EuaL6LfSx0tLP5ZdwPmoEWwgt2JNPRA/1NVUNlsc00VF3QjaojD27uBIzpe+BSJ2ICgRvERXrsuI6vi88mLSRqfOjChTyMvWJjo4/uIhb/gN2tcPdI6Q== 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=swMK4AS+xNOzeidT5UnOauIodF3UBtnQjuO95XkmML4=; b=nUf05RF0JcQcN5iZjYZOiOK9zfwIZ7w9ahhil9xx9yxMPLrICm68ccPbp2IhbNHEOv3b2PcP+Pk81hutIrVpjpHNdXt1WDYWMzFukyi+5xBE2p0VkvF4WmFyAsVNyVx+Q0Yp7vBj2BiOVL02Ny4EEOzDmuM2USET4jnWrUt4Bww= Received: from DS7PR03CA0057.namprd03.prod.outlook.com (2603:10b6:5:3b5::32) by BY5PR12MB4887.namprd12.prod.outlook.com (2603:10b6:a03:1c6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Tue, 29 Aug 2023 17:33:41 +0000 Received: from CY4PEPF0000EE31.namprd05.prod.outlook.com (2603:10b6:5:3b5:cafe::cb) by DS7PR03CA0057.outlook.office365.com (2603:10b6:5:3b5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Tue, 29 Aug 2023 17:33:40 +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 CY4PEPF0000EE31.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Tue, 29 Aug 2023 17:33:40 +0000 Received: from AUS-P9-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.2507.27; Tue, 29 Aug 2023 12:33:35 -0500 From: Mario Limonciello To: , CC: , , "Mario Limonciello" Subject: [PATCH v3 5/5] crypto: ccp: Fix some unfused tests Date: Tue, 29 Aug 2023 10:07:59 -0500 Message-ID: <20230829150759.156126-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829150759.156126-1-mario.limonciello@amd.com> References: <20230829150759.156126-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: CY4PEPF0000EE31:EE_|BY5PR12MB4887:EE_ X-MS-Office365-Filtering-Correlation-Id: 08bf8b95-dd42-406e-7057-08dba8b615fa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R9vDmygP/u8buQ+cNU+m1L5TifdcoT1i2fgniYJ1smA3bDYC1JoGKrpAPH7xWUqQBatOgtOMpMJCMm3RH6T1G0eEG+652wjrHLy8eqKXodWCOqFasR8tW8xf+wS9Ryl9AefBEQl3AJt0EicANTjBcrDRlhW4OHLCD8qWw+zT8EXxqnmSapau2YoWdeYFsxVDjTzyA4dlMUdcigdlhcFyTOeDNyetRfr9JUdsmyGpm5L2lViF3FC+0N7GTYevAOxrI7FHfolKblabsog0wnodJFWgXKtqKJMyQqUp/Z9+J/kI9Uziw0jjsm2BwGs9ktbp3Ey2blYrdF33ioiR2BJ50k15TAD3hvvfL+SBuqyM+OpcMlyxmzosR3Tjyahpt8ixYDom9h1K9h/DRwVwe0LUaui9GBDjagG948Agxw9ZG9mx9E1i72sm2EF5sZ8KWMh5Tl1B7aPior6XJfOyNsPM00CEMD1tc9+uG2F0Y5TiNRB7uijpTaTlDc7GOKvfmy8OWpM9v4vWE+e/Ogy21i9Sjfnl8heAGHssRbRakvQb/k7wC/+2xdBu8LPHmrlxq1sw3aeLoqglxnOcfQaNexB0FpsBLjDjJAUwYxHuK37cvoUSWBPKgsjksXCATb6LffHlaHPaAfqmin5jh9Vjfg2KH1OP3yAzkOTCK7QY8tdGt4Pg1XNswv35cs7YIE2anvWIEWcYLPwAdsMkTTsrSO7pRkRvx2dqGIwZ3Buhc1E+hB2PAnT9SoNrgxhROhP/i+Xz9qvp1pI2rFu/L/yEJ3b3Uw== 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:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(1800799009)(186009)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(356005)(81166007)(82740400003)(8936002)(6666004)(70206006)(110136005)(70586007)(478600001)(7696005)(54906003)(316002)(41300700001)(40460700003)(16526019)(36756003)(26005)(44832011)(8676002)(1076003)(5660300002)(83380400001)(2906002)(2616005)(47076005)(86362001)(40480700001)(36860700001)(336012)(426003)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2023 17:33:40.8211 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 08bf8b95-dd42-406e-7057-08dba8b615fa 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: CY4PEPF0000EE31.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4887 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Some of the tests for unfused parts referenced a named member parameter, but when the test suite was switched to call a python ctypes library they weren't updated. Adjust them to refer to the first argument of the process_param() call and set the data type of the signature appropriately. Fixes: 15f8aa7bb3e5 ("crypto: ccp - Add unit tests for dynamic boost control") Signed-off-by: Mario Limonciello --- tools/crypto/ccp/test_dbc.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/crypto/ccp/test_dbc.py b/tools/crypto/ccp/test_dbc.py index a28a1f94c1d2..79de3638a01a 100755 --- a/tools/crypto/ccp/test_dbc.py +++ b/tools/crypto/ccp/test_dbc.py @@ -33,8 +33,8 @@ def system_is_secured() -> bool: class DynamicBoostControlTest(unittest.TestCase): def __init__(self, data) -> None: self.d = None - self.signature = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - self.uid = "1111111111111111" + self.signature = b"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + self.uid = b"1111111111111111" super().__init__(data) def setUp(self) -> None: @@ -192,12 +192,12 @@ class TestUnFusedSystem(DynamicBoostControlTest): # SOC power soc_power_max = process_param(self.d, PARAM_GET_SOC_PWR_MAX, self.signature) soc_power_min = process_param(self.d, PARAM_GET_SOC_PWR_MIN, self.signature) - self.assertGreater(soc_power_max.parameter, soc_power_min.parameter) + self.assertGreater(soc_power_max[0], soc_power_min[0]) # fmax fmax_max = process_param(self.d, PARAM_GET_FMAX_MAX, self.signature) fmax_min = process_param(self.d, PARAM_GET_FMAX_MIN, self.signature) - self.assertGreater(fmax_max.parameter, fmax_min.parameter) + self.assertGreater(fmax_max[0], fmax_min[0]) # cap values keys = { @@ -208,7 +208,7 @@ class TestUnFusedSystem(DynamicBoostControlTest): } for k in keys: result = process_param(self.d, keys[k], self.signature) - self.assertGreater(result.parameter, 0) + self.assertGreater(result[0], 0) def test_get_invalid_param(self) -> None: """fetch an invalid parameter""" @@ -226,17 +226,17 @@ class TestUnFusedSystem(DynamicBoostControlTest): original = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) # set the fmax - target = original.parameter - 100 + target = original[0] - 100 process_param(self.d, PARAM_SET_FMAX_CAP, self.signature, target) time.sleep(SET_DELAY) new = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) - self.assertEqual(new.parameter, target) + self.assertEqual(new[0], target) # revert back to current - process_param(self.d, PARAM_SET_FMAX_CAP, self.signature, original.parameter) + process_param(self.d, PARAM_SET_FMAX_CAP, self.signature, original[0]) time.sleep(SET_DELAY) cur = process_param(self.d, PARAM_GET_FMAX_CAP, self.signature) - self.assertEqual(cur.parameter, original.parameter) + self.assertEqual(cur[0], original[0]) def test_set_power_cap(self) -> None: """get/set power cap limit""" @@ -244,17 +244,17 @@ class TestUnFusedSystem(DynamicBoostControlTest): original = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) # set the fmax - target = original.parameter - 10 + target = original[0] - 10 process_param(self.d, PARAM_SET_PWR_CAP, self.signature, target) time.sleep(SET_DELAY) new = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) - self.assertEqual(new.parameter, target) + self.assertEqual(new[0], target) # revert back to current - process_param(self.d, PARAM_SET_PWR_CAP, self.signature, original.parameter) + process_param(self.d, PARAM_SET_PWR_CAP, self.signature, original[0]) time.sleep(SET_DELAY) cur = process_param(self.d, PARAM_GET_PWR_CAP, self.signature) - self.assertEqual(cur.parameter, original.parameter) + self.assertEqual(cur[0], original[0]) def test_set_3d_graphics_mode(self) -> None: """set/get 3d graphics mode"""