From patchwork Fri Jun 21 12:39:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 13707562 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2063.outbound.protection.outlook.com [40.107.212.63]) (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 5082D155A43; Fri, 21 Jun 2024 12:40:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718973654; cv=fail; b=rdN/mdeCqFIA/bknPZOIo/jEtwRmFvUSGL/cmybEWzlmwyQS+xl3FkRYro9M08m5CLMQHPvDK4MhQPmRknN34nLhaTq2o++gNaU3rFSH52nqjQaQNt3d+2fZTV0zeDlt3c56unka/nF7WANzpw2v5W21IwTAEplsYLMdIxO7B7I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718973654; c=relaxed/simple; bh=NjtLdLL/fizBHeKJ9hNhhOGJEnNvjH/UY0HtJMj6jnc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NKhn6WzXBzIIkucuJ0HVnpHHz1pZZThhzFGktOKWwsfLbBzZcOks4gxfns7uyf0xE6JmVb1Jsg5DcKlhGzVST3aBC9U7eBfzVhLGhERqvJp3Zp65aeOgIMqkh7l+SYNRJ8GTRlka61oz2E8JgfqD54IyAtF+EAzt8Ui0aKBR0vI= 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=ZJlWVgrH; arc=fail smtp.client-ip=40.107.212.63 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="ZJlWVgrH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QSUzzUpvBmyqpDh+PAmLQey0sjvzKAMbMsikLXpAb/2bSWy6RUzUCI45IENwNCkLIKeCp4zW1a/jPv25INW6zYx0hxrRiIRCf6pZ6QrHeQtZstk/s8Vs6L9Z8rO3X7hoZv1u30vgJTUeHQznLEp37rvsz2mHwBI/TtKOXyjCoXNRcVGI1MPMkYFN3m6gJYtN1L06anqeo/NFpqlx4CNtY9sQSy37VMknXTD7CHdiE4jmpabOMhWcm26qqTI9g/UnB3UNDGuJURpZOVp2UgDfqUfYLPika0NOcgHLaHjZgSAFhIdkL2n0wxPydCmrY6B0QIs6YFikU6MR3upO/91lrA== 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=kwMhuWhXBTLejC/8NnGn9qapu7ahiSKE8vXxKfognq4=; b=IkNvHJgozXwMy9UZ71z68msuYJ06pRINKt8p+SD6AeehjF3KG88JMw8/0Q4cdg6b0qFQpvTJqa2Eq8fIV/4SXgUicnqeA4KWTrHi4FkON0vn8uLas5qM+4H1e8ffnx7L63cPV+Xd2fFu6pcNDnDsAgU7FRJu5ZbRKn+5rYKxxE9fKcgloYJU5hCaCu8TsvjbDldM6fTFnr2VL7U5g9DorttzoqWUNwo1h8lQQ76oEfwyrnAkROuHHkBdLxaffK5XIOI2wsUteUWMwHQ5NmlpbC3SiFuQMapGJmf3k3Fx5iUBak5O35BBHrIvsEBt+HJmVB9e+Gr2JcRue2UYtGde6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org 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=kwMhuWhXBTLejC/8NnGn9qapu7ahiSKE8vXxKfognq4=; b=ZJlWVgrHyQWU0UoiWYfNIU7DqzUQN14JVXeEl8vh5+q710xPSX/GK/ijTdhNXItvMreLdQwhPWyi6ORPbY4OpG2+KHO8mRD1HD0BvcNSpxQUT/sLgmJxqlU6kPbUWi6L6xn4WSvX12k2yQBqWaFcGcvP2tCOraWsWszYJEd2t70= Received: from DS7PR03CA0233.namprd03.prod.outlook.com (2603:10b6:5:3ba::28) by PH0PR12MB8051.namprd12.prod.outlook.com (2603:10b6:510:26d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.37; Fri, 21 Jun 2024 12:40:46 +0000 Received: from DS3PEPF0000C37C.namprd04.prod.outlook.com (2603:10b6:5:3ba:cafe::cc) by DS7PR03CA0233.outlook.office365.com (2603:10b6:5:3ba::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.33 via Frontend Transport; Fri, 21 Jun 2024 12:40:46 +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 DS3PEPF0000C37C.mail.protection.outlook.com (10.167.23.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Fri, 21 Jun 2024 12:40:45 +0000 Received: from gomati.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.39; Fri, 21 Jun 2024 07:40:41 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v10 22/24] x86/sev: Mark Secure TSC as reliable Date: Fri, 21 Jun 2024 18:09:01 +0530 Message-ID: <20240621123903.2411843-23-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240621123903.2411843-1-nikunj@amd.com> References: <20240621123903.2411843-1-nikunj@amd.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: DS3PEPF0000C37C:EE_|PH0PR12MB8051:EE_ X-MS-Office365-Filtering-Correlation-Id: 23deef32-92cf-4992-af07-08dc91ef5f48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|82310400023|1800799021|36860700010|7416011|376011; X-Microsoft-Antispam-Message-Info: aTefokz2F3KuIgfgA8/GFnMJ7dWFw4cAs3Q4unOZrvRLv0fUwuUtQiWw3yNHAux3tLyZ3NB0eEZvYngBNwpRiPN7xXq2+XvT5IHPvPsAqHqdh4vZ93dbJXsn0iIoNADnqZC3cWUj47wXBtZ38Umbu4sjujWMpCUGz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G5XPA6Nsj/yr6GCGanIFKd/Ufkn5KF4GJuN4f1DQ/OjvzimieDp0V6cKoTA/twzNM3z29DNVzXzpqR+ZhCRlfT5x8LRNwbSsCDYCT30Ypi4ohLzQFqofoeANNAlWhCNi7y8hknVTFM58B13dUaCXtFRAZTtNnuPSzqVhS68YVxw8d4z2qjV+DbNtW1yUg== 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:(13230037)(82310400023)(1800799021)(36860700010)(7416011)(376011);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 12:40:45.9859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23deef32-92cf-4992-af07-08dc91ef5f48 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: DS3PEPF0000C37C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8051 AMD SNP guests may have Secure TSC feature enabled. Use the Secure TSC as the only reliable clock source in SEV-SNP guests when enabled, bypassing unstable calibration. Signed-off-by: Nikunj A Dadhania Tested-by: Peter Gonda --- arch/x86/mm/mem_encrypt_amd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c index 84624ae83b71..8331bd02000f 100644 --- a/arch/x86/mm/mem_encrypt_amd.c +++ b/arch/x86/mm/mem_encrypt_amd.c @@ -516,6 +516,10 @@ void __init sme_early_init(void) * kernel mapped. */ snp_update_svsm_ca(); + + /* Mark the TSC as reliable when Secure TSC is enabled */ + if (sev_status & MSR_AMD64_SNP_SECURE_TSC) + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); } void __init mem_encrypt_free_decrypted_mem(void)