Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp220251lqh; Thu, 30 May 2024 21:43:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyFuFGqX6YGk9BJ6QBbmeqM/e4uvhfZ4fOebk5BiBGZHU+i+PX9WjV+Zu3Gb+OoBkwiVRrBKIqvTDtzpEOz6fvt7raAocKq+Ih8RXPpg== X-Google-Smtp-Source: AGHT+IEVWrZ1UJQqcgG7v+UiATVmjWlcVewPOZY+nt5DRnhKYsYqcKO5pjON6DNmWQWNAd/04gQv X-Received: by 2002:a17:902:c40d:b0:1e4:7adf:b85d with SMTP id d9443c01a7336-1f636fedfa5mr9651105ad.17.1717130610411; Thu, 30 May 2024 21:43:30 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63241c8ecsi8556825ad.618.2024.05.30.21.43.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 21:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=nQiM5mja; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-196271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 31B08B26018 for ; Fri, 31 May 2024 04:39:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F19080BF7; Fri, 31 May 2024 04:35:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="nQiM5mja" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2040.outbound.protection.outlook.com [40.107.244.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 DF4D080635; Fri, 31 May 2024 04:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.40 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130123; cv=fail; b=h8d6YQiqZKXC3Sou5Fj4vsxRdnUjRsR5gD9EoLh0s3BSFykjlOot0bEcduqt8wBu2RJjZ5IGSklR1m/sNh9nUsFj3F2qsZL5HbVuUZ2paRGIdTCDNqQjufBhsutGBj84slEIGfhowcCzJx+LIbi5RdATzIoxe1G8EPpaFeteXKk= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717130123; c=relaxed/simple; bh=vnPjgsazrE0DLG/RAQFERCMwjQJODdgEwWkp1VPdOSg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MYzkOtN4OGmmToxFb3zB0YK/PZ78VwGW8sAoAGJtQXTEc6XefSTsErAtfYJbOTl5/IWpSlNb73+VhTDo+nTO/vzDdf0WfkWvNtT5NVcaFxWQmYkYWFKM+h6ugVfD5s0L2rAy4fJP1/PNFcyTcVV4KrU+AWxGMEL0sy0Z9Fe6h38= 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=nQiM5mja; arc=fail smtp.client-ip=40.107.244.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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kIVcmELYfvONud3j4LmqueE4TIrhpTUqOYt1n33zUZZbqtO/73D1QXkftYEIRzVuZ/GMVoVeq/rpStzKXyYKu6hBtKblIgAyUKeG2et3hjX7Vs1sJ78Eh683gWTh71xwTwWuhR1SuuRLIP1AeDvFfcTXxbsqcERCbykojL4rTE9PVai1nB5DmB76ublUFssox2xxCP74B3CnxTrXw334ifhN1qarztDWYXQrwpgMNiz51GEeVc5kAafjvpgSNuKfVkA5y16CAi0Px50flG4+FRzrYR2L1aC5+zXdMjJ3c0MVvJBjWsxKkBzbnB/rJZPP13N6knjhmphJGCyWMp/pWQ== 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=E6Lxe5JM+FwSNitnLsD3ANphwWwHa5rTM9keIbTAN0o=; b=K2G6IWYePPmAMPZrkwTW0vmROcw1jtW2jF0K4MFMy5Z5wPmSHMsTpskkDRS203giuSMxHE/2Dt7idp5cBYQYyoPusr4BijttaXtCKtThJhLS5y4CYsmWg4UbZUdHnIrvp3q1UX8PKLdss+Tpr8YJJWlN4G1lIBlPGbi92UMeTf5UpDbZOEBDyvpRl8eIR9UhOXD10ExocFRLCRbBOUtf/FhXAJ4t36H+Foz9saggROKt56Xsa8WQ7lhOSmNHQl221pne5xoWKDm9xy/KmVL3i1f+smPOou/caN8q+U/y7Z0kAw49lk7jCLGUDJ2lXlCjr1gi2hAKdt6oI0ziHz6kgA== 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=E6Lxe5JM+FwSNitnLsD3ANphwWwHa5rTM9keIbTAN0o=; b=nQiM5mjaLhb8XVlcVS8efT/T2Pup1VcqGCRiy4A54Dwis3AC6maEZ8B3dEWCpUwJJFsSIqW9p/VeBuUzsxq6bmHGJXflzwetFjIzWdxEfALBwpPZ41NLEChR8C8DFHB7l1n7zd3aWau+Y0dz2oFh1We79dTnNDZLKp4GhtC5ozQ= Received: from DM6PR03CA0013.namprd03.prod.outlook.com (2603:10b6:5:40::26) by BL1PR12MB5756.namprd12.prod.outlook.com (2603:10b6:208:393::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Fri, 31 May 2024 04:35:19 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:5:40:cafe::91) by DM6PR03CA0013.outlook.office365.com (2603:10b6:5:40::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.22 via Frontend Transport; Fri, 31 May 2024 04:35:19 +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 DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Fri, 31 May 2024 04:35:19 +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.35; Thu, 30 May 2024 23:34:50 -0500 From: Nikunj A Dadhania To: , , , , CC: , , , , , , Subject: [PATCH v9 22/24] x86/sev: Mark Secure TSC as reliable Date: Fri, 31 May 2024 10:00:36 +0530 Message-ID: <20240531043038.3370793-23-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240531043038.3370793-1-nikunj@amd.com> References: <20240531043038.3370793-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: 8bit Content-Type: text/plain 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: DS3PEPF000099D4:EE_|BL1PR12MB5756:EE_ X-MS-Office365-Filtering-Correlation-Id: e857bd07-0a99-4b32-99b3-08dc812b13d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|82310400017|36860700004|376005|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Bqz8vnDFXAMogvlQjFPsC3qKR/dXVL/jx5TOaio/J5HAp2KqClZU0hlkIU0F?= =?us-ascii?Q?CvoYsQ04VEIYTUWk8PN36HGniw8E7RotAIxUDtGeQ6tPWm6rXA8D8yHrzOYg?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M605UJaM4l5TWTE8rGdgsF3V8FUaGk4d2QJqy1a?= =?us-ascii?Q?kshqx0OxqN6F1lSAtnOcUUMlE3Tw8tZebfNE+H4aPy3vJjY8cSP6IOVNz0F/?= =?us-ascii?Q?pQ58PIjx7RiqHUlTGGzsmUhFEY6jChoctim+oc1C5TvgZqQdcbirRoPENnC1?= =?us-ascii?Q?ZPw2a7PwgQ+ltcOs+uaddnau6XbLPPjYDV99E6Z9YQmiGMzDof+3Tf642R0r?= =?us-ascii?Q?mwvu2BDdjZpHKaaolAftnZEqlDKSlPEbCbHdZQCs9/FdfNmMy4ZKOlZES6sj?= =?us-ascii?Q?xHKWlm4rywuoaOokXxtcpmEzMmZBkJqHMNtfzYl5KNFa15ROQgrNDaJjHn/+?= =?us-ascii?Q?onuzWoBMB/PMlzqUryjJpzTW863dDrlmuTMtU2H/5tpX7EMNaduGJNS77Kiz?= =?us-ascii?Q?+RbrY/AJlp1IeiN7oNeUUgwtFztm?= 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)(1800799015)(82310400017)(36860700004)(376005)(7416005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2024 04:35:19.5147 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e857bd07-0a99-4b32-99b3-08dc812b13d7 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: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5756 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 422602f6039b..e275741eb073 100644 --- a/arch/x86/mm/mem_encrypt_amd.c +++ b/arch/x86/mm/mem_encrypt_amd.c @@ -510,6 +510,10 @@ void __init sme_early_init(void) */ x86_init.resources.dmi_setup = snp_dmi_setup; } + + /* 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) -- 2.34.1