Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1305857pxv; Fri, 16 Jul 2021 06:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+AwkWAAOpYixHg22gEF+5mnLIK/HWjJehnf55H3tG1ubPXTsYQ21BevEeNkNw+dVvQHdv X-Received: by 2002:a17:906:90ca:: with SMTP id v10mr11753734ejw.325.1626442049166; Fri, 16 Jul 2021 06:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626442049; cv=none; d=google.com; s=arc-20160816; b=amBpW0Ht4D3Wwos8jGybzlOtda2Fqj20PVEhMKXSkx1+o7hI9/bgb2OApxmIRuhRim I7OPq7q/r+9PGzYf+VkTKP47htmjMiOcW+xEn94z/F/cY+6Xa83+SY3OcydzF96+4f/v AAM0w+SJdIhSqUWI/PrRaUX1fDEjOkBBrtJz5txIyu002kxntoJZD5Qjoa5unF6KSG0V LEFmHsLXs4xvtY6rc4GWvWU9Wvm9Sm8g6STu0/Umr9F34FJCR1mowI61EgvKfWubj4Rh i2wnsse7axKhF8/i1rXrrVaqPAmNxcS0sZRDQYBLajARstWs/CefEPvjFU6PIBB6iLqM 9hzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=iApEIi9Miq3UIE5s+yV3GBcv1kZmgG+1mZKk7FrnGGs=; b=vChuxVGmeGz/JRxhGzQzgvrpFBLmYzMow6KpIQx+MBlYqTakgoCXoOcUt0pc4VvJKC bSiktmCQONA0Ir3pKHfx0ELjc9nBP2dk0Nr3baY7JYO4wqmpps/1o7Eu6PHD6NYaWkmx eYGTAY1nTeByeOcDlCwMqfDUc8SXQXeLyPMcGlXGWpdntcJ7XBud+Dc2soQZdczgswCu rmkIP3Hu5YrWjll++vJM2L79zEvmctoELEl8JEjNHEOBTjb1wPifmGp+PnLP60ZpIvF8 VajpVBmUtc0ALWfXLurYYV5QD5PIhZT5WRQoGzVSpU4EqhNBYaUn040XgYdxh9aLWvFn fACA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="QAlO/7sG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si10829593edr.518.2021.07.16.06.27.01; Fri, 16 Jul 2021 06:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="QAlO/7sG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239750AbhGPN25 (ORCPT + 99 others); Fri, 16 Jul 2021 09:28:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47510 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239391AbhGPN25 (ORCPT ); Fri, 16 Jul 2021 09:28:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626441961; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iApEIi9Miq3UIE5s+yV3GBcv1kZmgG+1mZKk7FrnGGs=; b=QAlO/7sGksdBWKAP9bDZ6i53T7VqfVWX4ZXwsekzfz7BiK/O71zx8jAKeYfkxbDIuOs5jr 1VmIC9eL5fZ7nglsRcYEz1YAFwfzFzbJXjMFKTo7usWyy+/CgKj6aj+e6tsb07ESzrJxz3 cr7ebiPMZ6Ocf/0gDkcJSkB2w2LYjHQ= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11-vUCUhWssN_CmChbE3dIr5A-1; Fri, 16 Jul 2021 09:26:00 -0400 X-MC-Unique: vUCUhWssN_CmChbE3dIr5A-1 Received: by mail-ej1-f69.google.com with SMTP id r10-20020a170906350ab02904f12f4a8c69so3601664eja.12 for ; Fri, 16 Jul 2021 06:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=iApEIi9Miq3UIE5s+yV3GBcv1kZmgG+1mZKk7FrnGGs=; b=gdVF5YTOBouCah3MOpjXIWXF2qxbitGdbTv79Ut2MIhjPnYmnyDO+n5bEjUbmLqeYA SMm8H9tTiwrnGQ47PpSnlpb2bTR9hj7ZpMrith8uO2gj5UkEryeylpJdkhNsRw1b+j+Y RiT5jNp+anpcYMUQe/qflF5ZPWh3sKGwNrrMaLxIcxNWksY2oTTdPhCKLOBAe8u1NbEM qCHsPAFku6Ni5nbgHfhZMgT1PMAu1ZLtr3CryoUf+Ee7nWTBr/vyZbRkvfCfDjt/BbN4 8CGUOzrwN+6VRJ+o64WpKxPV35mz22u1yf519n2m3aLVS2TY8WSq9YX6ob8y02DxLxW0 8T9Q== X-Gm-Message-State: AOAM532PaNSgdAWPyNlMhNK0pj7fL3878itLvAbPZ0swkLGuogOs9zEC mInaOkwIPw5/xramnJwSy3Gd5gkRtNn9n8Gb52AzKiNt/Vza+/Qucq8Gg9o4/tLebuPxNLemj8c OQA21qoQgra7Tpwch9O4QA/Yq X-Received: by 2002:a17:906:c29a:: with SMTP id r26mr12015151ejz.235.1626441958095; Fri, 16 Jul 2021 06:25:58 -0700 (PDT) X-Received: by 2002:a17:906:c29a:: with SMTP id r26mr12015103ejz.235.1626441957555; Fri, 16 Jul 2021 06:25:57 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id dj16sm3781486edb.0.2021.07.16.06.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 06:25:57 -0700 (PDT) From: Vitaly Kuznetsov To: Ani Sinha , linux-kernel@vger.kernel.org Cc: anirban.sinha@nokia.com, mikelley@microsoft.com, Ani Sinha , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-hyperv@vger.kernel.org Subject: Re: [PATCH] x86/hyperv: add comment describing TSC_INVARIANT_CONTROL MSR setting bit 0 In-Reply-To: <20210716063341.2865562-1-ani@anisinha.ca> References: <20210716063341.2865562-1-ani@anisinha.ca> Date: Fri, 16 Jul 2021 15:25:55 +0200 Message-ID: <8735se1jbw.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ani Sinha writes: > Commit dce7cd62754b5 ("x86/hyperv: Allow guests to enable InvariantTSC") > added the support for HV_X64_MSR_TSC_INVARIANT_CONTROL. Setting bit 0 > of this synthetic MSR will allow hyper-v guests to report invariant TSC > CPU feature through CPUID. This comment adds this explanation to the code > and mentions where the Intel's generic platform init code reads this > feature bit from CPUID. The comment will help developers understand how > the two parts of the initialization (hyperV specific and non-hyperV > specific generic hw init) are related. > > Signed-off-by: Ani Sinha > --- > arch/x86/kernel/cpu/mshyperv.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 715458b7729a..d2429748170d 100644 > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -368,6 +368,14 @@ static void __init ms_hyperv_init_platform(void) > machine_ops.crash_shutdown = hv_machine_crash_shutdown; > #endif > if (ms_hyperv.features & HV_ACCESS_TSC_INVARIANT) { > + /* > + * Setting bit 0 of the synthetic MSR 0x40000118 enables > + * guests to report invariant TSC feature through CPUID > + * instruction, CPUID 0x800000007/EDX, bit 8. See code in > + * early_init_intel() where this bit is examined. The > + * setting of this MSR bit should happen before init_intel() > + * is called. It should probably be emphasized, that write to 0x40000118 updates/changes guest visible CPUIDs. This may not be clear as CPUIDs are generally considered 'static'. > + */ > wrmsrl(HV_X64_MSR_TSC_INVARIANT_CONTROL, 0x1); > setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); > } -- Vitaly