From patchwork Tue Jun 23 11:58:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyao Li X-Patchwork-Id: 11620539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5115F618 for ; Tue, 23 Jun 2020 11:58:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 353EA20771 for ; Tue, 23 Jun 2020 11:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732607AbgFWL6s (ORCPT ); Tue, 23 Jun 2020 07:58:48 -0400 Received: from mga05.intel.com ([192.55.52.43]:58504 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732573AbgFWL6g (ORCPT ); Tue, 23 Jun 2020 07:58:36 -0400 IronPort-SDR: /WRj2zkPRtphHbgM1RZpE9UKcT7hnadmIj1fLw6AHQHUvvEtebhIX5VL5yq8CUxYyM/cmiZ+w3 kJy5ZViqy/dw== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="228710130" X-IronPort-AV: E=Sophos;i="5.75,271,1589266800"; d="scan'208";a="228710130" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 04:58:35 -0700 IronPort-SDR: QQ7CDnuUnAEQCREM7br5D5atlamStPOi32CNc0BXOcYtjsI/yIQmd1TFXls1qQV4BEp9sF2CSj 9k3OC1QMYZkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,271,1589266800"; d="scan'208";a="285746081" Received: from lxy-dell.sh.intel.com ([10.239.159.21]) by orsmga007.jf.intel.com with ESMTP; 23 Jun 2020 04:58:33 -0700 From: Xiaoyao Li To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov Cc: Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li Subject: [PATCH v2 6/7] KVM: X86: Move kvm_x86_ops.update_vcpu_model() into kvm_update_vcpu_model() Date: Tue, 23 Jun 2020 19:58:15 +0800 Message-Id: <20200623115816.24132-7-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20200623115816.24132-1-xiaoyao.li@intel.com> References: <20200623115816.24132-1-xiaoyao.li@intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org kvm_x86_ops.update_vcpu_model() is used to update vmx/svm vcpu settings based on updated CPUID settings. So it's supposed to be called after CPUIDs are fully updated, i.e., kvm_update_cpuid(). Move it in kvm_update_vcpu_model(). Signed-off-by: Xiaoyao Li --- --- arch/x86/kvm/cpuid.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index d2f93823f9fd..5decc2dd5448 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -121,6 +121,8 @@ void kvm_update_vcpu_model(struct kvm_vcpu *vcpu) struct kvm_lapic *apic = vcpu->arch.apic; struct kvm_cpuid_entry2 *best; + kvm_x86_ops.update_vcpu_model(vcpu); + best = kvm_find_cpuid_entry(vcpu, 1, 0); if (best && apic) { if (cpuid_entry_has(best, X86_FEATURE_TSC_DEADLINE_TIMER)) @@ -136,6 +138,7 @@ void kvm_update_vcpu_model(struct kvm_vcpu *vcpu) vcpu->arch.guest_supported_xcr0 = (best->eax | ((u64)best->edx << 32)) & supported_xcr0; + /* Note, maxphyaddr must be updated before tdp_level. */ vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); vcpu->arch.tdp_level = kvm_x86_ops.get_tdp_level(vcpu); @@ -224,7 +227,6 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, cpuid_fix_nx_cap(vcpu); kvm_apic_set_version(vcpu); - kvm_x86_ops.update_vcpu_model(vcpu); kvm_update_cpuid(vcpu); kvm_update_vcpu_model(vcpu); @@ -254,7 +256,6 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu, } kvm_apic_set_version(vcpu); - kvm_x86_ops.update_vcpu_model(vcpu); kvm_update_cpuid(vcpu); kvm_update_vcpu_model(vcpu); out: