From nobody Sat Feb 7 08:27:25 2026 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2040.outbound.protection.outlook.com [40.107.212.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 661226BFB3; Sun, 18 Feb 2024 14:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708265489; cv=fail; b=G/MfTTlzX2lnheaJXEZSY5K2DMOyVQCHJMop7EIM21440xZzDHTaQeuBKw9+KQqWi8vZbtmTaoI1tXI32UYDHYNFHX9FMYkhDZ+btXcHg5xsCwgal859opYWh8P5PWd4kgc73GwDUD7w6kOOdeI4pU9prShKc0Y00C5p6HSyCHg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708265489; c=relaxed/simple; bh=UPucnQzRSezoUa8wbcD4r/onTXpcVMGq6u9TPaDo9Qo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MdzxiQlRl+K1Z/joSdbNJTUyJWGsKfhdhWE1fUbmLIRNSPIe88imLq1N2lK1+cLSfWVOMCfK44Oq55xWQ9U9wmbDERPsp3bwFdy0nheD49Ggzm1tUgvw3lzJzaTeRkOLS72YzFmqD5WRYq2q2a+cksiCsgvv5pq4legREIqG7MA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DBx7vApC; arc=fail smtp.client-ip=40.107.212.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DBx7vApC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=beD+4aaCgdZhFuLzPS+Sa5AQPZpCK58kFuUXksTFbW/GU0M+47L9gQ+K6nUV82BDbdexGM8pCWG3WxgdwtiFd/fS/6hoEO5UopOgtxq5AVp0HL8LMHZ1AVgqF/0Xc0U4ICjsUycYQX6IeYd0JG1NrEunhtvsr4wSaZAFu1ykYKM5zMbRPTS1vxPP3beYmKP7aTHSs4MzOU/QiftFZifl1ThYCNDoIY7jIP2W4PJfU9X1bQOneXWDIGHMvsNEfJmIDDKA1u4Nz+qjZwhsUacyt6RRfDT7iTPJoPnvZAGQRpRmoZ/yU/CYhib4iOL6baLvAsCBIdJKhTDVIzY6zSBSeQ== 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=yxWU2pc/R3JnBAriPb0jazMoal1VSV1qkHl8Q57gkXI=; b=JRa3uqBycpODNEWrmUSKpAD3zr7d1qm+GtPvj7JDuvNMAY8VUgcGknMdareG5nyQ8ATFSe4DeSYD7uFsCNu9MZ/aCbv8Oyu9wgyTj0dPJ6jXW/gd9bHTcBY2+3CyAsY6vv42Km/9gmicKGGSk6qoLfnFsQkSEkXrCxUc738Ms9vMwMZROyndcXpnky3Xxl0dz0AoWCUQIPzAZqTjXxrpl5aAYyPn5+WUKDdmHZowoPXZT0tB5tYLqbF6d+UwGhFq7tyFEpV2qA5qGRx5zQNRmTw5f+ggvnWmxcS0zITEy95C3TfRLIWiiO5M+kGNoIp9qbCrgSHLga3+uX9yprs0pQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=yxWU2pc/R3JnBAriPb0jazMoal1VSV1qkHl8Q57gkXI=; b=DBx7vApCbsUtwgh/3Dot2bQgLpOhBYXSrEm7xb0HKp33qP00QYddlRUzuwYHnw8IsFhZ2eAR/P7oS8/BNHniTLaWkXfjQxS1z1OPXb4RCcEfzrTRZkqIewZf3sKESJ5kiTKCJj4J49zy7d/ui0vyVwqhNT8FQXuP9hwe4ja4lNU= Received: from BN0PR04CA0071.namprd04.prod.outlook.com (2603:10b6:408:ea::16) by SN7PR12MB8004.namprd12.prod.outlook.com (2603:10b6:806:341::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.15; Sun, 18 Feb 2024 14:11:22 +0000 Received: from BN3PEPF0000B069.namprd21.prod.outlook.com (2603:10b6:408:ea:cafe::c3) by BN0PR04CA0071.outlook.office365.com (2603:10b6:408:ea::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.37 via Frontend Transport; Sun, 18 Feb 2024 14:11:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B069.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7339.0 via Frontend Transport; Sun, 18 Feb 2024 14:11:22 +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.35; Sun, 18 Feb 2024 08:11:21 -0600 From: Mario Limonciello To: , CC: , , Mario Limonciello Subject: [PATCH v2 1/2] platform/x86/amd/pmf: Add debugging message for missing policy data Date: Fri, 16 Feb 2024 19:41:06 -0600 Message-ID: <20240217014107.113749-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240217014107.113749-1-mario.limonciello@amd.com> References: <20240217014107.113749-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BN3PEPF0000B069:EE_|SN7PR12MB8004:EE_ X-MS-Office365-Filtering-Correlation-Id: 45b3bae5-c9cc-431a-177a-08dc308b7c3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rI5Owo4xGiSOYnTEbHw0huct/TURhOSY6mBHmMWYbGkekHM7gmKtmJ9SEExf+4R0TxNtz/1kw9wUtW7i3RJFaeg6oh65nx8B6WERcUA1waHkzQjSer7L3o/yXnhWdTMDy02chwaKA+T0+JPwvdM2UF9mGHf7LxF8v5jhoyN+WhXTZjCD7nmtRDwtXYDJO19LFb8Tdd++d5uUTlQUifFw5Ad0aEFKAoKfTLgN9h/DfVRv3uNmFPMkZuXtTQZfyrie50j73gw2s8KwOL9hnRrmcgLSjGLZu3fpb0XfkNrtVqfFGCNdGxi8TKuhC75qDbgLg2NvpPDOZTBsd/+gWJelb4JS968m8UlU+jphfIBlNl2HL2YnWkBZ5FZfLxwY6gNF82DL+Wp40JpjOIdhC/YHsg1G65Q1pKdBygTtsi/IJdHkA63MhyKRU8MvtAM/gkm1EzVhDyzRIvOXZEB9/uC/BtBY2wCiR/o4CoGAeafr5HG+2E+Rrf50eHP35uBaf9o1A8/toS1fPAAdiTGGnO8SQCzmx5bRQ7bTnd7ZMgH/24AGbUqXo6/Nj84VGij+jlWX3NU7VVGG8/60QU0DvwuD5HqI1P1Ajj8rt8dCkUhsCEGwQ0cpe7ZXttUQV74p04IMhzXYqImR78ozRww9CdsA5hFkvDoNtMPliB/V/wPhQdU= 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)(39860400002)(346002)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(82310400011)(36860700004)(40470700004)(46966006)(4744005)(44832011)(2906002)(15650500001)(5660300002)(41300700001)(26005)(1076003)(36756003)(2616005)(478600001)(16526019)(356005)(81166007)(83380400001)(426003)(336012)(82740400003)(86362001)(4326008)(8676002)(8936002)(70586007)(70206006)(7696005)(54906003)(110136005)(6666004)(316002);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 14:11:22.2199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 45b3bae5-c9cc-431a-177a-08dc308b7c3c 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: BN3PEPF0000B069.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8004 Content-Type: text/plain; charset="utf-8" If a machine advertises Smart PC support but is missing policy data show a debugging message to help clarify why Smart PC wasn't enabled. Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmf/tee-if.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/a= md/pmf/tee-if.c index 8b7e3f87702e..1359ab340f7c 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -252,8 +252,10 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_= dev *dev) cookie =3D readl(dev->policy_buf + POLICY_COOKIE_OFFSET); length =3D readl(dev->policy_buf + POLICY_COOKIE_LEN); =20 - if (cookie !=3D POLICY_SIGN_COOKIE || !length) + if (cookie !=3D POLICY_SIGN_COOKIE || !length) { + dev_dbg(dev->dev, "cookie doesn't match\n"); return -EINVAL; + } =20 /* Update the actual length */ dev->policy_sz =3D length + 512; --=20 2.34.1 From nobody Sat Feb 7 08:27:25 2026 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061.outbound.protection.outlook.com [40.107.94.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E0C66BFB2; Sun, 18 Feb 2024 14:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708265488; cv=fail; b=NweOfJaJbrj5vsz+DO9HbV8Kqnj/cFwT+0LFRSYxW+lKdVGx0HcJEop1GU0veoCulScwf6oBQnapZG7octqfJ7XhCzwwIez8/QFCJhm38lcFF+5klXoK89VoGWJdiQIqya3kZED2QrLD00q7LfQsSezIAe+E5XdkVTWu5NXJ1iU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708265488; c=relaxed/simple; bh=qXGC6IWdiAXSL7uWTWBAVuOy3niaHpwpv5xK4PeecAU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iicy4EAA4tvNRpWhkSf37Ph4J3hI/35x2jwr3gvSqQoMWcmWBERu6yF/vq208Klp6al83o8oCL01NMdf+LcLMeJ8g/4PCoCe210oz8f3H4itz0rzcLQqB189zdzLVeY/83DNeZl7fFmIeeyotH22X7PHV8K8mVwjROylIafoBUk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NAq4Y9m2; arc=fail smtp.client-ip=40.107.94.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NAq4Y9m2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmWnQKW1+5eaX+JJUzuK3kZN5rmEaAO8aehl5b6owoibSh85ZLkDnEWe2AaHKOTdNBfPZX/ILeBW73JUaEOnoh8rs7iM3Xm0TAC3kjZrg4hoSLPdRzJt4EAsvwmDEUjvVIyqHr4f5chwCBnwjj1OOn4dhN2GVcSLIoJzc+mulO3AgxBhbAS8dNZxrrlwOouEpzFSQ+IefI7TLRL0yKYktVBQKPaOEzxAkC853bmDKfZjP8t256OlCdzvTtmI7cbwfe7vxJOGgwELImSrgjZROW1dSYNXuJS0fAdtV3rIOGBDDASaTkaUWqSbQuLJRd3KPCBFEcS2tY9o9Xc8R6kyuQ== 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=YTfY1s46Gnn+KoyMlXiHprWrXxBzyGPAZ0w+HqQoTns=; b=PM+qpFS4CY7vaXzwA8NQ5HTIIQ5I/L57pcO/Onr2ju/SIMsOFJ6JfMEofymJNdOmhNFsaVL6qnL4Ld5oiFl/vFYnfnS1TptpM25X26jbTK1qGAdvEwHAGdz3gRBx4Sz/Lz6zAWlHOQ8FowFwQLoIdBHokomgZPCoXI83OFC/K7mz/nLAyB8rma6q0dXPpipWm/AoxuoTLnQt6Uj50eK+17LQ25S2oWbVDlhP/rxxAUVh4UDZn+VkExML3uEdjg2DWkqw2wnkaFZXZb63Nik4ubPe/iN/ka80sS6so+EqZxZpUyd5fGGgJP/yTSzknCmU5UcvDP94DQa3t+yLpnzd0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=YTfY1s46Gnn+KoyMlXiHprWrXxBzyGPAZ0w+HqQoTns=; b=NAq4Y9m24ElKaoDVxOc8Wuy8JYylhxL6IQlQD5z0aY1YGWy0qHDXOu0Tj6tb2eBFPJA9cnDxAxN2hq4MVW+SOsw2Tf1qH7sgpHItBzb6wzNq62r8Tb+WHltJXP+LeVx4bav7giA6Fie/vfOPjWVPCSk9/LKxdwxfRCSJ+2TFI2E= Received: from BN0PR04CA0066.namprd04.prod.outlook.com (2603:10b6:408:ea::11) by DS0PR12MB6632.namprd12.prod.outlook.com (2603:10b6:8:d0::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.16; Sun, 18 Feb 2024 14:11:23 +0000 Received: from BN3PEPF0000B069.namprd21.prod.outlook.com (2603:10b6:408:ea:cafe::d2) by BN0PR04CA0066.outlook.office365.com (2603:10b6:408:ea::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.34 via Frontend Transport; Sun, 18 Feb 2024 14:11:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN3PEPF0000B069.mail.protection.outlook.com (10.167.243.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7339.0 via Frontend Transport; Sun, 18 Feb 2024 14:11:22 +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.35; Sun, 18 Feb 2024 08:11:21 -0600 From: Mario Limonciello To: , CC: , , Mario Limonciello Subject: [PATCH v2 2/2] platform/x86/amd/pmf: Fixup error handling for amd_pmf_init_smart_pc() Date: Fri, 16 Feb 2024 19:41:07 -0600 Message-ID: <20240217014107.113749-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240217014107.113749-1-mario.limonciello@amd.com> References: <20240217014107.113749-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: BN3PEPF0000B069:EE_|DS0PR12MB6632:EE_ X-MS-Office365-Filtering-Correlation-Id: bdec73bd-4fd1-4c7f-9c23-08dc308b7ca2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: joFhiSvdYdj5b5OjZ9ArK2nnmuPssydBF/WqYpY92hRXBk6ZxaXGJg1GHVYBhAaRpEcS4m0Ro6OBCtxAILMb4Yhbr2V8/mpEasZuqfup3Jz/MGHgYprrLDM4C/uq9FcHzxbAvImU2AGW3zsoFD/rSoGRFJHxp0P90PgHvezuh7MgBBL/7nZMpcXCIyYadzSM0MqrapXAtAIf24uQ/eR8rAquDqFFeA42PsoGCnVcXNdwaRDGLigONcw3zHjhBz9u4b4aDmaqDJbpLasoIdX7zp1jzUi6M8Y3qn0XdC/a7zam09voF+eZUaVtzABDwZ9MEp355vaydVQ85tC0xNGth0MZ2l6/4kNPngDqZAgMxg3E0PBhCs8mCfrLavZEwi+AU5J6QygGhKn03FCxJfbkVTzAppnS7Ft6B6mZD+17FfgFRgjLcNpytPHkoEchhiIkN08DP50VdVRYqeK4F73j86EYzw9z4U1DDhUFgyukJKbdGc22WBmrVwhf+bTnsudG9R+KXqDO0rhsotJII/qehF98dVrLVE7uS4kANbknnqB1FDN6diz5L48cxw2Gg5RuaFp/ynXeGlwKw4kxR0+qRea1d/NTKwyFwFZ0r8u8I0BLZnxoQ74DDLl5ChdbzvZyVR5uxyS2yT+XSfkojJvCrWr2OKPiCNDd0MAebXIakTo= 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)(396003)(376002)(136003)(39860400002)(230922051799003)(82310400011)(36860700004)(1800799012)(186009)(451199024)(64100799003)(40470700004)(46966006)(6666004)(54906003)(110136005)(316002)(5660300002)(44832011)(2906002)(4326008)(8936002)(70586007)(70206006)(8676002)(86362001)(41300700001)(7696005)(478600001)(36756003)(2616005)(26005)(1076003)(81166007)(83380400001)(426003)(336012)(16526019)(356005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2024 14:11:22.8918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bdec73bd-4fd1-4c7f-9c23-08dc308b7ca2 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: BN3PEPF0000B069.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6632 Content-Type: text/plain; charset="utf-8" amd_pmf_init_smart_pc() calls out to amd_pmf_get_bios_buffer() but the error handling flow doesn't clean everything up allocated memory. As amd_pmf_get_bios_buffer() is only called by amd_pmf_init_smart_pc(), fold it into the function and add labels to clean up any step that can fail along the way. Explicitly set everything allocated to NULL as there are other features that may access some of the same variables. Fixes: 7c45534afa44 ("platform/x86/amd/pmf: Add support for PMF Policy Bina= ry") Signed-off-by: Mario Limonciello Reviewed-by: Hans de Goede --- v1->v2: * Use a single label * Move all into amd_pmf_deinit_smart_pc() * Set to NULL explicitly --- drivers/platform/x86/amd/pmf/tee-if.c | 65 ++++++++++++++++----------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/a= md/pmf/tee-if.c index 1359ab340f7c..4f74de680654 100644 --- a/drivers/platform/x86/amd/pmf/tee-if.c +++ b/drivers/platform/x86/amd/pmf/tee-if.c @@ -338,25 +338,6 @@ static void amd_pmf_remove_pb(struct amd_pmf_dev *dev)= {} static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev) {} #endif =20 -static int amd_pmf_get_bios_buffer(struct amd_pmf_dev *dev) -{ - dev->policy_buf =3D kzalloc(dev->policy_sz, GFP_KERNEL); - if (!dev->policy_buf) - return -ENOMEM; - - dev->policy_base =3D devm_ioremap(dev->dev, dev->policy_addr, dev->policy= _sz); - if (!dev->policy_base) - return -ENOMEM; - - memcpy(dev->policy_buf, dev->policy_base, dev->policy_sz); - - amd_pmf_hex_dump_pb(dev); - if (pb_side_load) - amd_pmf_open_pb(dev, dev->dbgfs_dir); - - return amd_pmf_start_policy_engine(dev); -} - static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, con= st void *data) { return ver->impl_id =3D=3D TEE_IMPL_ID_AMDTEE; @@ -455,22 +436,56 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev) return ret; =20 INIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd); - amd_pmf_set_dram_addr(dev, true); - amd_pmf_get_bios_buffer(dev); + + ret =3D amd_pmf_set_dram_addr(dev, true); + if (ret) + goto error; + + dev->policy_base =3D devm_ioremap(dev->dev, dev->policy_addr, dev->policy= _sz); + if (!dev->policy_base) { + ret =3D -ENOMEM; + goto error; + } + + dev->policy_buf =3D kzalloc(dev->policy_sz, GFP_KERNEL); + if (!dev->policy_buf) { + ret =3D -ENOMEM; + goto error; + } + + memcpy(dev->policy_buf, dev->policy_base, dev->policy_sz); + + amd_pmf_hex_dump_pb(dev); + if (pb_side_load) + amd_pmf_open_pb(dev, dev->dbgfs_dir); + dev->prev_data =3D kzalloc(sizeof(*dev->prev_data), GFP_KERNEL); if (!dev->prev_data) - return -ENOMEM; + goto error; =20 - return dev->smart_pc_enabled; + ret =3D amd_pmf_start_policy_engine(dev); + if (ret) + goto error; + + return 0; + +error: + amd_pmf_deinit_smart_pc(dev); + + return ret; } =20 void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev) { - if (pb_side_load) + if (pb_side_load && dev->esbin) amd_pmf_remove_pb(dev); =20 + cancel_delayed_work_sync(&dev->pb_work); kfree(dev->prev_data); + dev->prev_data =3D NULL; kfree(dev->policy_buf); - cancel_delayed_work_sync(&dev->pb_work); + dev->policy_buf =3D NULL; + kfree(dev->buf); + dev->buf =3D NULL; amd_pmf_tee_deinit(dev); } --=20 2.34.1