Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1886119pxv; Fri, 2 Jul 2021 15:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3/pM8D9uBYtz/Yn9Pp9CfhgPass7c8zHI9j7d/ijFfreyIVeRDgG9LDqROnfVicMTS7U X-Received: by 2002:a17:906:7304:: with SMTP id di4mr1788725ejc.531.1625263797185; Fri, 02 Jul 2021 15:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263797; cv=none; d=google.com; s=arc-20160816; b=cg4TM+l4EYrhJ9/qfuPq6j4P3oiQos7Y1eAa4Vr0YBJGfQYQ1W5MI1Hc6q/EQbY8Ni XAwzRwVMBFHmePkxe0M0qxzxoe+yh39vd0a1abJKt7Rf9bVtsoE3EtPUKwnWuIm2Gero tO+sTLQ08YwljCSjqiahKZ1ZSe6vhjZ+bBiTBBM6CKT2dZTjlnVyGLD7zAgQ/Vxc2YiM TSezlIoOjti2MNHI4RmVBRNi+vB5cVBn9DrnU6J50d/7IeXZnVdK/8xSsLG+cBqz+WjX nT6MCSPK3PuiYZfMcRy38xYYLc8uX1tMGoKVjcJjizc9zPz2KU7P2cPwkN155/bvigqI /6Yg== ARC-Message-Signature: i=1; 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; bh=TTiafBkedEseu35hAhHXoCbGiuxr8EyXTc02jtFDyzM=; b=sHqlSOteorKLqph4TWv2Stmb7NXrC5ma5XmWO73azYIxanxpc9VVWNjt01R+L3AZjw IJd0+bsAr5XW4ku1/WODB5A3OdSaWziYEpSzRQOG1tsDoxj1zqPB6yw0pYRUjiIF7GfA GkQ4R4wu0cvlhcaJUVLjtULPwGrkEGK06EI9FWkglb7VshI7MxRlfddFADGmFcc6zPZU byHbMyoMvj1mhIlK+fXyXwerUg10YVePK177H5usxd+kg5R/osLlODht70YsActu5pc+ vK3K9T/2bIUQdaYGVWknBpQbMhi8x/wGK+dsKtjp8yVePuoAytvDUsy9cOB4tD8zziQX pfAw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si4341447edh.404.2021.07.02.15.09.34; Fri, 02 Jul 2021 15:09:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbhGBWKu (ORCPT + 99 others); Fri, 2 Jul 2021 18:10:50 -0400 Received: from mga17.intel.com ([192.55.52.151]:15273 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234044AbhGBWJB (ORCPT ); Fri, 2 Jul 2021 18:09:01 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="189168418" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="189168418" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:32 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814896" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:32 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Xiaoyao Li Subject: [RFC PATCH v2 65/69] KVM: X86: Introduce initial_tsc_khz in struct kvm_arch Date: Fri, 2 Jul 2021 15:05:11 -0700 Message-Id: <5f87f0b888555b52041a0fe32280adee0d563e63.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoyao Li Introduce a per-vm variable initial_tsc_khz to hold the default tsc_khz for kvm_arch_vcpu_create(). This field is going to be used by TDX since TSC frequency for TD guest is configured at TD VM initialization phase. Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/x86.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index a47e17892258..ae8b96e15e71 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1030,6 +1030,7 @@ struct kvm_arch { u64 last_tsc_nsec; u64 last_tsc_write; u32 last_tsc_khz; + u32 initial_tsc_khz; u64 cur_tsc_nsec; u64 cur_tsc_write; u64 cur_tsc_offset; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a8299add443f..d3ebed784eac 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10441,7 +10441,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) else vcpu->arch.mp_state = KVM_MP_STATE_UNINITIALIZED; - kvm_set_tsc_khz(vcpu, max_tsc_khz); + kvm_set_tsc_khz(vcpu, vcpu->kvm->arch.initial_tsc_khz); r = kvm_mmu_create(vcpu); if (r < 0) @@ -10894,6 +10894,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) pvclock_update_vm_gtod_copy(kvm); kvm->arch.guest_can_read_msr_platform_info = true; + kvm->arch.initial_tsc_khz = max_tsc_khz; INIT_DELAYED_WORK(&kvm->arch.kvmclock_update_work, kvmclock_update_fn); INIT_DELAYED_WORK(&kvm->arch.kvmclock_sync_work, kvmclock_sync_fn); -- 2.25.1