From patchwork Tue Nov 28 12:59:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikunj A. Dadhania" X-Patchwork-Id: 170773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp3899353vqx; Tue, 28 Nov 2023 05:03:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6QAJwJ9xJ752llyw4UgG2qOREP+lOgltvm7t+eF6VJ2vCpzCGCBW7nsDmRLAnzMd0lhav X-Received: by 2002:a5e:9247:0:b0:7b3:92f8:9ef4 with SMTP id z7-20020a5e9247000000b007b392f89ef4mr10968531iop.2.1701176595901; Tue, 28 Nov 2023 05:03:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701176595; cv=pass; d=google.com; s=arc-20160816; b=ywGzMl4tJqI9JOQJELGpqT4YOXxO3Bbmx5lcnj0i2jaMqwICqZAU45ng5tAU4M379N u61wMEuauCvaViijfjkbodVHyRTaQseXWfthSnr6PfjFzxt/REM/8xwRFRLeObna3306 J/EDCBueim2kb7bcNw7ueTMCee8GjkMrZZ69cMBQM6NWZkVKN117YDfxOn8CIcL2jjzc GJY5SveSiLPQOpeHAb2Vd5Y1mx2alNC6tjkRsZanYT4N2V0r6d6DzwUKDigkm+HAOp1G vqXCKUr5wCq2FrdO6LKDRhRAM8uE6erg7qahsmQgCc+0dRwQObZDpEGQo2ly0HFELDtu h83g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FcicsXzeHKGsZEHzGC3Fwt0OSe+q3g1tdVXDopm2fUk=; fh=GrBYTfaCmKSBoJ0OQBiloTDpWB/NcGHvBdTqN4MlWVs=; b=sal7+fzvP3+Yj1x0AqCqQu6F+i8n+mBIQ5qnTP1Un7Ka4A7s7O5QloEvcA4fi0kY25 mzMjI7XInpoy7CjgEB7tdMMbfPn56XOEhw4AmcNe86bvtAiiGTsoKStr0pSnE/CoL1Sv ge5eU+ND2/626TjY9Gd8NvBMEthpEBKpAdeK6morANdbxX1s2L8eB3JzK3TB687XvLwF m3lqqO5qF/q3cvaKGm3mxOEP+50zrebPGGNqcT8jhgT8yd3bj8y3vYl1N//uw/LM2WJX Qzt49YWBouX9LvoSKaTdZP9saAQoS7/GRs12eq7pCaWe+J3PAQwqZh5ATBTeHzy6T63/ 6pCA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TOk6rHj2; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i22-20020a6bf416000000b007b39620661csi479250iog.127.2023.11.28.05.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 05:03:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TOk6rHj2; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9C96C8058A38; Tue, 28 Nov 2023 05:03:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345111AbjK1NCv (ORCPT + 99 others); Tue, 28 Nov 2023 08:02:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345073AbjK1NCV (ORCPT ); Tue, 28 Nov 2023 08:02:21 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2072.outbound.protection.outlook.com [40.107.237.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F3B11BC6; Tue, 28 Nov 2023 05:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PpzXL3tKA1xbZdTASFCi4lxvz9+Ycnu2lkPsEPDtVNOB5ZtuIcZ5v0A+g2rgPBJC9HhlI9rg4QjNf2RWYNAUvwubIABuhTmwW6Sh8vgNQ3nVkIS/eko6ItLPHvkTEkFNvIWk3T7ZEZ7aC86So+haJcIZZbhkEeSDxWAfy/xDA2ZzHK4x2ba1LYGjkdWsx7r8PILbmzpc8GaaWkFzSo2iRGgaQdkrpL6Bag6o5BKHsbIheXtmj0Ke12dz48GWk4E0tRcRCE0xJeGiQdgHQWtzkCRfydXt9xJlgdvwFKFi9de3AqJAPwi2PIrSuZ7phKc05Nojd+oodQko8Bskk758zg== 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=FcicsXzeHKGsZEHzGC3Fwt0OSe+q3g1tdVXDopm2fUk=; b=R7AmRD0E7AJOBAkA6k+IcOS0TnFOJ8IThgEQswfTzF4e0ZS32X2q96DGPWAWBafn1lX/eAa9d5nLYpvWHhVOn7GcaTDglis9VCCNckxonwi6I9dZTteokgK4j8Otw90KO9W+JjPhVlskAqo0WGV2CgjRjy9Kozf03yGEppAzB4OI92o2HaN+waNCf+twD5hV5+rtN6fFvO94fF+/eP2058m+dEy/KVxmpeq/4u0Zp1gv2/Mi6msdXTyYYHAiFNFVfLnK7kGfZHDvtP6QiH8Is2nhMXEHvqWH/VimKKFGYyb7q4BUE36wBjR8BFfXTZn7gaJz1nVR/rQhvmIhhD4F3w== 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=FcicsXzeHKGsZEHzGC3Fwt0OSe+q3g1tdVXDopm2fUk=; b=TOk6rHj2DpChmD+6wy6EZE7qrcMWgvfC/LHgceLut1i2qn47y+0aFlpr/W8r/MOUL/AcxKD6k29Dpl1YmciLgBpHM7WckzR3DSsm/yYZWLhW/AW/sHqF1DJZ57YSMR8AvZflkmy58TUIt47yIzDQR3o9kmrKTubYk0Lb1lL3a6I= Received: from CY5PR19CA0113.namprd19.prod.outlook.com (2603:10b6:930:64::9) by CH3PR12MB8851.namprd12.prod.outlook.com (2603:10b6:610:180::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29; Tue, 28 Nov 2023 13:02:09 +0000 Received: from CY4PEPF0000EE30.namprd05.prod.outlook.com (2603:10b6:930:64:cafe::54) by CY5PR19CA0113.outlook.office365.com (2603:10b6:930:64::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29 via Frontend Transport; Tue, 28 Nov 2023 13:02:09 +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 CY4PEPF0000EE30.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Tue, 28 Nov 2023 13:02:08 +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.34; Tue, 28 Nov 2023 07:02:03 -0600 From: Nikunj A Dadhania To: , , , CC: , , , , , , , , Subject: [PATCH v6 14/16] x86/sev: Mark Secure TSC as reliable Date: Tue, 28 Nov 2023 18:29:57 +0530 Message-ID: <20231128125959.1810039-15-nikunj@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231128125959.1810039-1-nikunj@amd.com> References: <20231128125959.1810039-1-nikunj@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: CY4PEPF0000EE30:EE_|CH3PR12MB8851:EE_ X-MS-Office365-Filtering-Correlation-Id: f3683ba9-4087-4223-31a8-08dbf0123acf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 663YGp0GjRXV/LFAnd+3kqoY3xu8q0YBgDnhhcfTIpr/v7sD8YcnE6d+P66UfbDN9ErFmt/1oJ9cwrveDC38M8DOecjdNN32QcsWZBXVAH8iJvc+u/IFyY0Nrs4k6o3vjva4+h7pJnFA9uVLo6BLVdHCYEz2fi6zCGrtD5HiDwAZq4akRhi/fgzhkATY7b43mry1xKqgMlBNeFtk8WyGqi4QRhiiYAx348dDvoGoI3Xsnq/cA0HTYDY1NSfR68wLXGWwpSNPgqbE5uA3/aWACFlhj9lN+l7DJB+jYhvYzYbNIZKN25vNOuf61zMhq8EuC98kyOCPDa0EKY/BUIBcWhKFgakblfPEOa0GSxj30JPeBzm0KboBahpDSSqBgyAE1XwCi2kZJvEPf4MK5kQGa0BOVT/MXnRzKdzlMSKKFmb3dTupUwWrkTb4BG1E2LHIFAPjxCAnXlezvqIEP7jeKhIyVRTlywTtslExQZ8abJKNzbF2ARFv4/1gxa+wZXl+i7vgqRie5ZYL5CSuQCSaRIhM/y1I7dmUoJd0hcZP3HCvBZlrlemThgUlQjlVK3V/86Fankj5RxBiGcaM35V2cgT8cBJDGCeO0u9pCjOgrGdVFQ8wsd5JW96h1vWzWp/aiRM5kqpjtWgZ9iEi15pcYDK2t3M5HS/38EMrHF/3Nxv9RaauZQYzLii//4wdQRsWQqUo71TnJXyVdDdEWwTiKFlIA9IpqT2RKlhFYb7rWkq18m7JEj0FhX04wkCJZ4ilsuEDLY0hMtGbhncn7wWKtA== 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)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(1800799012)(186009)(64100799003)(82310400011)(451199024)(40470700004)(46966006)(36840700001)(2906002)(4744005)(7416002)(110136005)(316002)(54906003)(70586007)(6666004)(7696005)(70206006)(41300700001)(4326008)(8676002)(8936002)(478600001)(5660300002)(2616005)(16526019)(26005)(40480700001)(426003)(336012)(83380400001)(1076003)(47076005)(36860700001)(40460700003)(356005)(82740400003)(81166007)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2023 13:02:08.8698 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3683ba9-4087-4223-31a8-08dbf0123acf 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: CY4PEPF0000EE30.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8851 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 05:03:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783812949795901079 X-GMAIL-MSGID: 1783812949795901079 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 --- arch/x86/mm/mem_encrypt_amd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c index f561753fc94d..8614c3028adb 100644 --- a/arch/x86/mm/mem_encrypt_amd.c +++ b/arch/x86/mm/mem_encrypt_amd.c @@ -487,6 +487,9 @@ void __init sme_early_init(void) */ if (sev_status & MSR_AMD64_SEV_ES_ENABLED) x86_cpuinit.parallel_bringup = false; + + if (sev_status & MSR_AMD64_SNP_SECURE_TSC) + setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); } void __init mem_encrypt_free_decrypted_mem(void)