From nobody Tue Nov 26 09:53:22 2024 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (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 6DA9E1CF5E1; Mon, 21 Oct 2024 05:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729490280; cv=fail; b=c6B7ZL4067m9B0oFy3tRovQ/vX7TYb1AVN/Ys1VJx4BLUQYQDSQxyhWDmzRTFIG1kASQHjV+rztbB/BIDb+u0bOceSYdz4qdNFJmRsf0KxQvJY5Or5OJMenoz/ZvUEJBCbHXv/X1FcUa8vW1KaNZ7tN/bjrXY/FSgIoqRN8XCkk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729490280; c=relaxed/simple; bh=wTiiW3zg+ZEXEs6HyoUwSSwd2a1sEJVoTxWCh49OUQg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IhUpztMP7gLAB9Rl9LBIYlmfxtCQykeBQSnQveNtuQ3AW6l2Gpx2Ar+HeX+xv0YfmraL9FYk9RD/tNTwhLiSsWEf9P1GJekyEEmgTdq4N1D6z1uBE5IhM4TFQy4PHz5BTjQqs/4tgrZa5osgcYU9ow92EJUkdSszKD+jaBr0tSQ= 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=Ne9sbKsA; arc=fail smtp.client-ip=40.107.237.51 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="Ne9sbKsA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xOSU6zK84t6IdvsfjVtV+1aeElsbwN9SfBgljnatFTu0JVjoiu11CZ9cTLJholNG5vqaXHrGKwlQRRQKCAcudNICnwel+4uIRf99sPwdMh704R62wDO1QeBWfaWqjMlrzsrnVvLhzhYZdWPGjwkQewpUOT8lGWiVl5iLWwBOUntW+MROUpsTn/gsGquZIUUvq0pHXs51gf7E/r+jTAYucMoCp9C8LeqaqttFl4l1SVY18yCb1hOcVHf+9XpgFDDGkaQxLdNuKelabsfZRu5ncoE//w2dKkQx6pbpH+6anvy0+1bH9UA+ZcAkGeNUZxhVqIfuRYEknXSmOYmyp0G0ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gJbrswFKIOzOu5VNK+d/iLVqlwq3bvmZy+UUG5Gjm70=; b=kMsH56VEXhmZAvWTdMSovWATaPuyND3x4PXHfQjKJ9W5u4I9fklAx7VmJlw4Fp4I+FpMoOMKKOHZ4PGDIQANIP33tGeKd3bzg1AzJ43kkGHZdfX0hcHl6cPKcQ1zddhD4uBu9d5Qv6xmYnC/X4gDBhCvvwyqebP/IZ1o3/zHJpabhqY5UxHnlIHTljVDLE0zcT0jOF26zZsHl7RFa+i9Ri8ysSopy7XgoO1rz58MJTsEsaqc8zlZJeiFL4YqPbjVH9IxhNPojldqcKHDfuDDEfbKYcfjvlYkSAawsui/zMazp16S1ykavp2vRaMFHLDJwXdoYjAmJvSoIPtlXdSyNw== 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=gJbrswFKIOzOu5VNK+d/iLVqlwq3bvmZy+UUG5Gjm70=; b=Ne9sbKsAlTdhyrlZ4DgqM8VjBHE1GXa/b68aLZDCCXSu2zaS/uGuXy1g0k7mp04xTs7ExebdSFBNwi6Aw1+LaCyc0JWJAubVl4XkIPkkAhXFQR7ddZnGfR44p3ayNXisFIiNjzsP32jBI6TUz8l0IdROFQcValPCI3TqX2rxMcc= Received: from BYAPR03CA0001.namprd03.prod.outlook.com (2603:10b6:a02:a8::14) by PH7PR12MB7796.namprd12.prod.outlook.com (2603:10b6:510:275::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Mon, 21 Oct 2024 05:57:54 +0000 Received: from SJ5PEPF000001D7.namprd05.prod.outlook.com (2603:10b6:a02:a8:cafe::4) by BYAPR03CA0001.outlook.office365.com (2603:10b6:a02:a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Mon, 21 Oct 2024 05:57:54 +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 SJ5PEPF000001D7.mail.protection.outlook.com (10.167.242.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8093.14 via Frontend Transport; Mon, 21 Oct 2024 05:57:53 +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; Mon, 21 Oct 2024 00:57:39 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v13 07/13] x86/sev: Mark Secure TSC as reliable clocksource Date: Mon, 21 Oct 2024 11:21:50 +0530 Message-ID: <20241021055156.2342564-8-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241021055156.2342564-1-nikunj@amd.com> References: <20241021055156.2342564-1-nikunj@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: SJ5PEPF000001D7:EE_|PH7PR12MB7796:EE_ X-MS-Office365-Filtering-Correlation-Id: 3669d558-2210-4608-53bf-08dcf1954dde X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?1QwyJCDkbQs+/RFGoZFnbU11ntjkeCVnib06sq8dD6oUSEQP09ysY4fpvHrn?= =?us-ascii?Q?vAYWvjBwLfMRvZxEN/+IyLrnOO8ctD9ysDKhJJtqL9RZWPWSDDjJ0MgUGikA?= =?us-ascii?Q?o+jfu5uyg3jpkq7AOumxMuPgbaa93GkakT4weEVMkvFlNa5G3mjbAj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YG9o5hYI5hdfLRTSEBjK5Ol42Qjio5Vq?= =?us-ascii?Q?exax1k86uwuBw6IHDwq/9WYT3HNCE49rAwq0M9F/HH7cMNYBrshhXdkVozIB?= =?us-ascii?Q?+FahxbJXLiUa1taRWnhGfTBeE+TSBycrvsvR8u1IC0kax3jzQEzpMVpTKhkr?= =?us-ascii?Q?3oGNWhbmQK1HbdK9U24GIVmqaX81kLylfWJCzNoZIfoFDbVYkF3ezmx6pIvT?= =?us-ascii?Q?jMEbiSTORXy5p312W9Qrc2ClnnpgTznOYolZrwzSpijfaiObvZRxvNAktfsx?= =?us-ascii?Q?5TcOeJeC/1KUUecbR1dFc7qKrbie1ssmPGoR3XyCqOvNXh7T4gQs2y2a4+ls?= =?us-ascii?Q?iVUJviBCTRQUzf2wKf9KXFpSpHvS0bhbcPKJYa7dc3cBCTAVwg=3D=3D?= 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:(13230040)(36860700013)(376014)(82310400026)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2024 05:57:53.7198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3669d558-2210-4608-53bf-08dcf1954dde 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: SJ5PEPF000001D7.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7796 Content-Type: text/plain; charset="utf-8" In SNP guest environment with Secure TSC enabled, unlike other clock sources (such as HPET, ACPI timer, APIC, etc.), the RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. Hence, mark Secure TSC as the only reliable clock source, bypassing unstable calibration. Signed-off-by: Nikunj A Dadhania Tested-by: Peter Gonda Reviewed-by: Tom Lendacky --- 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 86a476a426c2..e9fb5f24703a 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); } =20 void __init mem_encrypt_free_decrypted_mem(void) --=20 2.34.1