Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp333909rdb; Thu, 2 Nov 2023 05:17:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLgThoKhE3Mz0puppsuqkNhdvMmvkLBLM6vRsGdv6CJEE02HK22IZIf5WwnmJSC2Faxlja X-Received: by 2002:a17:90a:348d:b0:27d:1334:d266 with SMTP id p13-20020a17090a348d00b0027d1334d266mr13451587pjb.27.1698927478941; Thu, 02 Nov 2023 05:17:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698927478; cv=pass; d=google.com; s=arc-20160816; b=XhsDm6kno0DZJMRVKFWHkLwWMlneupl7pE0KG+OdVbl1oi8HxwkMsCUQgI32+/lx5T 5sSe8Ht08wK3sPVAdYueMfaBMwAQT+zYcV8WxlDkGJFiwGe1Kfu+DXFOv8wKEN1Izi7q mFfG5iH5j4Wpwg0DjYkKpYe6xbqp4iNHbUu26lRoaP6c4oRmWKfC3BS/0NT/nETg0ujo 9crL989rTbOJ29N51cXvkYTIbbtHsH6QBpjIhipDYNmrMABk4fO/fP420QskO/GrIdZS RpSu1TpEsW1+yjNnhJAQevLajYvQYC+ysY1ytU3PjsBczwzZsucZaENwzwNjh5GgvMiw Tzbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:references:cc:to:from:content-language:subject:reply-to :user-agent:date:message-id:dkim-signature; bh=QQbqYDf8Zy2qZeUbdQcG9/W5hebeCvBguL+mTPgFoG4=; fh=sNIYS00U3bMMkENftw2dfCQ9TtT5VnVOfMnL3ZBVp+o=; b=nDG4waynJYyB3Y7nxxzAU9wiHpasQrilTbUDwKSOOgbubQMAFkHIn16+g76BlE9OV+ 7Cc3Erx+efwodfo8dX2xGwthq4PPBmALO5hyZgxkHaQU56ovPr0Oabv5LT+Jx+mvchb+ 7URIVSExujksJ6lD+kU0AzPlDlkyxJGbteUntp9gynVCDbG0lbOPcJBULIc7TXK0YxOM FSEfdEo8msZHoHb5UUYJFO4/rkhJew6j/quFITivCPtY11qrfaIHTbahePPlgZN3YvCk V4Esundq4brA7bmJMRUs07NOP7dGjG9I7xqp5V4IES/iZe2c7aogOyYlfrEz1ZAtIj5N Ci8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hV+ChJWp; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id lp3-20020a17090b4a8300b00280a4a15cddsi2754372pjb.94.2023.11.02.05.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 05:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hV+ChJWp; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7ECD781552EB; Thu, 2 Nov 2023 05:17:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346817AbjKBMRK (ORCPT + 99 others); Thu, 2 Nov 2023 08:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345888AbjKBMQv (ORCPT ); Thu, 2 Nov 2023 08:16:51 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2062.outbound.protection.outlook.com [40.107.101.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903BE1A8; Thu, 2 Nov 2023 05:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSZ/XonWjHU+hkVlvGdlAf9rckvV4G4w7eW8qIOc4dwgMYjUNVAd4YPQasSLMHcbNi6coyqayEaQlzsZvUOlrG8PQBbcva2KtXadK8uskCHhv7xk8cMK/wMomtXRcDRUEEHBPY2QzmHqeYBPYIstmlz51kjQXDtEfMPlYLjD5CbsBunf6V53wA1YBBU9XK+8s7BeLmFh3xEQZufu4796JAq3MIWAv9n9IjZnG8BuljRtZvGsqP+kpJ6eT+aRx0T8x44MV1gA2XSsgc1EjPgius1hugz4izxGMd5cPvqO16EM18ss1SRrlNI/ZwSlnGrp6DGbnDMV25r2UKHQzx9MRA== 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=QQbqYDf8Zy2qZeUbdQcG9/W5hebeCvBguL+mTPgFoG4=; b=FH9d2JWZyQ/752yZt5E1YhvYfFe4LfRvQHC4c359+UZH/N3cbxWJnPqcsfH6G6w9almEsTt+JcMPOytR1lkW+Vg0h7Ri7HlxauOxNAg7V92pHK+Q0yete+EW7UrkfuuLObnD7v9gQSrqEsrnp9ldBPKq6Rsu6Kff+vOJ9dQaKnvARLvQM+6n8sYaAEwgRaYtF7FK+EQGyFTASEvVG+yr1y15K9yOn8KPGGJoKuSA8Cps5lO0o8VWL93YRjj4uTeF87dZSBTuhPIyZAuRB0/xqBkNx95cFbU9KAY99IK7YXTHWogZvypGEbzO+x1y50JFm0+0KgNAlrdBYZIInd4Pvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=QQbqYDf8Zy2qZeUbdQcG9/W5hebeCvBguL+mTPgFoG4=; b=hV+ChJWpIzgFhFClMfY308GriPoWJjS4gqpFUr5OHO/S23v5FbsiN9Ocsg7jdLm3Vd9hcyWWkTbjR8RN/p5rVK8zz0pCWKETmHmr6rkIlfxIlZniKa1bzmMxpBsVc2V+VXVRx4wHQVSZSgPLoDg7AAMvg364C8EB5cFp+zVSaOU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) by IA0PR12MB8349.namprd12.prod.outlook.com (2603:10b6:208:407::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Thu, 2 Nov 2023 12:16:39 +0000 Received: from DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::93cc:c27:4af6:b78c]) by DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::93cc:c27:4af6:b78c%2]) with mapi id 15.20.6954.019; Thu, 2 Nov 2023 12:16:39 +0000 Message-ID: Date: Thu, 2 Nov 2023 17:46:26 +0530 User-Agent: Mozilla Thunderbird Reply-To: nikunj@amd.com Subject: Re: [PATCH v5 13/14] x86/tsc: Mark Secure TSC as reliable clocksource Content-Language: en-US From: "Nikunj A. Dadhania" To: "Kirill A. Shutemov" Cc: Dave Hansen , linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, x86@kernel.org, kvm@vger.kernel.org, bp@alien8.de, mingo@redhat.com, tglx@linutronix.de, dave.hansen@linux.intel.com, dionnaglaze@google.com, pgonda@google.com, seanjc@google.com, pbonzini@redhat.com References: <20231030063652.68675-1-nikunj@amd.com> <20231030063652.68675-14-nikunj@amd.com> <57d63309-51cd-4138-889d-43fbdf5ec790@intel.com> <20231102103306.v7ydmrobd5ibs4yn@box.shutemov.name> <5d8040b2-c761-4cea-a2ec-39319603e94a@amd.com> In-Reply-To: <5d8040b2-c761-4cea-a2ec-39319603e94a@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN2PR01CA0072.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:23::17) To DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB6309:EE_|IA0PR12MB8349:EE_ X-MS-Office365-Filtering-Correlation-Id: 075d2db2-888a-44cb-66f1-08dbdb9d90a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PPTkFiJkM/WxYDk1iNL1ipH4Ceip2FWpXV83OPZLvyWnpFhfnT2ZDgPINsIJ4Ugs41fiNp7/XIOmDFnSHVWPK8W8u9CoISevITLtyVJlxUBJ4uVkpqfP9odlWPrc2SxW4Kx3pJpYq2HVzPIcuD0GYhwNuYHpyPellHSE58Rw8u/rdFZ4N4rkmlrpHXx5J2A459akzMELDSwqMHS8F/00+faxTQNh9Z4dAYcvbV2R4RWUgzM3BdrOfFZTgrv25RIEOfIdnWq5vLmk7nD4NgjNz9Mf+4Itdn74rsan1R5fDvRFAZHKakC6Mu1gF2PYMF2menLi+oWH0qFdIuRFhU3LQgYwRuYuVQ15a1qDrk4mq1EFdVE4b3H5qC85is5XVMujBvEtRGBMsXFblNvcBCEum3JYqyoeLmoDBEi0vDH2shEBizYM0JWmNSXttgD/3MfsEjY8EVHD9j5LdT8+mFh6FsB0cqVr2nj0p7p5h8TqqyXadsyHTElPYdvYVYPvqYy+8ZWyDfbTnAjIzftVLqQXuZ+xPDzIi3cyKRZ3zS7Z06mRcgszh2b6A1Zvxoge8H62MKx07qb+Unzu3067RVaSmjPOwZKWFMiibsxUGwt/zf9LQc056YWJnOeq2JaN+crOeFvuV5a768RM8CraFLvmHQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB6309.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(346002)(376002)(136003)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(3450700001)(41300700001)(7416002)(31696002)(5660300002)(36756003)(2906002)(6512007)(316002)(38100700002)(66946007)(2616005)(66556008)(66476007)(26005)(6916009)(53546011)(6666004)(6506007)(6486002)(478600001)(31686004)(83380400001)(4326008)(8936002)(8676002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dDZwaTk5STRLdVFnM1BRUzFWWm5qamJ0ZmlTTWNySHNtRGJOdFp1alJmNzNl?= =?utf-8?B?K3hNTFZpOXNDdzloUFVBbTR0NWlvdXdMTGhLeU1SZnF2cGJvcllqczk0ajVJ?= =?utf-8?B?QzZ4c0svbVRseU1qN2Y0OEE0Y2F2TStOMmxEVVpsU2k0WFJvZVRBV1FBQmVU?= =?utf-8?B?OG5vUmdFVVZwTmtWb3BDMTM1MktrOFpiUndRb2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= =?utf-8?B?Z3hObG4vS3FhZ2Q4T1Jpdi9DSjh2a1h6ZG1aTS96bVdjaHFVYXpubGtQM2tH?= =?utf-8?B?aDByQXQ2S29vSVdNNzAyRWNWSGtRbGZLd0ZTdXF3bmhydHVvSGNURGFKNm5k?= =?utf-8?Q?bUecwIfshZrMRCJASCZHrv6JV?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 075d2db2-888a-44cb-66f1-08dbdb9d90a0 X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB6309.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2023 12:16:38.9529 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fYRQl6oP0TdhY31qoG6zLB2KCT5oxsrg9v+9zY+l4wzyZi4SaUtC/flbSy6TOYO46tDWdXy43kd2oTWXx2r5tQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8349 X-Spam-Status: No, score=-1.3 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, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 05:17:37 -0700 (PDT) On 11/2/2023 5:37 PM, Nikunj A. Dadhania wrote: > On 11/2/2023 4:03 PM, Kirill A. Shutemov wrote: >> On Thu, Nov 02, 2023 at 11:23:34AM +0530, Nikunj A. Dadhania wrote: >>> On 10/30/2023 10:48 PM, Dave Hansen wrote: >>>> On 10/29/23 23:36, Nikunj A Dadhania wrote: >>>> ... >>>>> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c >>>>> index 15f97c0abc9d..b0a8546d3703 100644 >>>>> --- a/arch/x86/kernel/tsc.c >>>>> +++ b/arch/x86/kernel/tsc.c >>>>> @@ -1241,7 +1241,7 @@ static void __init check_system_tsc_reliable(void) >>>>> tsc_clocksource_reliable = 1; >>>>> } >>>>> #endif >>>>> - if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) >>>>> + if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE) || cc_platform_has(CC_ATTR_GUEST_SECURE_TSC)) >>>>> tsc_clocksource_reliable = 1; >>>> >>>> Why can't you just set X86_FEATURE_TSC_RELIABLE? >>> >>> Last time when I tried, I had removed my kvmclock changes and I had set >>> the X86_FEATURE_TSC_RELIABLE similar to Kirill's patch[1], this did not >>> select the SecureTSC. >>> >>> Let me try setting X86_FEATURE_TSC_RELIABLE and retaining my patch for >>> skipping kvmclock. >> >> kvmclock lowers its rating if TSC is good enough: >> >> if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && >> boot_cpu_has(X86_FEATURE_NONSTOP_TSC) && >> !check_tsc_unstable()) >> kvm_clock.rating = 299; >> >> Does your TSC meet the requirements? > > I have set TscInvariant (bit 8) in CPUID_8000_0007_edx and TSC is set as reliable. > > With this I see kvm_clock rating being lowered, but kvm-clock is still being picked as clock-source. Ah.. at later point TSC is picked up, is this expected ? [ 2.564052] clocksource: Switched to clocksource kvm-clock [ 2.678136] clocksource: Switched to clocksource tsc Regards Nikunj