Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4572765pxu; Tue, 20 Oct 2020 22:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc0ZSjZUutRyVvbKPk7jZjO53Pmu6SCegrYHrD5iUY15e5ItzYq2g6/aA/1o4yHzeW51FC X-Received: by 2002:a17:906:3e48:: with SMTP id t8mr1795358eji.104.1603259942707; Tue, 20 Oct 2020 22:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603259942; cv=none; d=google.com; s=arc-20160816; b=E0F7CGqkZbkSFRMTKcJaCVO2LLD6sCvP/f80061Fw4K+5qtIPxSTpbdLRhrZW7ZQpj eSiynCnRlmNbrWwiEt6A56m32AN/dauIdWdze8QdQm63r0dy9h+kqJBQFYzDC02tAbgk 0w1GS+hhrsx1JVCmaxn9z8RWLvW72uTR8emUrOGf5bke5vnHe21g16s9xJNptAX7NtK6 8B9aU0B225QzpYWqc8Wa1Gg4+tEq2Tz2QKH+SCcbVABihxiDfffWVWHucjSBuoaofCa8 Ra5PQaqBRsG3YSqodLhON1pfr5FNyQIu5nIW5w8679ufDxqvXLsVYwNW4Y0ER0jwwNrX uJcw== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=NB31YLzOD3IenE6/sOBZLAbkFAO8UdGXB5oeIznIsP8=; b=D4qJ0YHRfbycqbI1bFjsooxnJuWM2m9HF+ZSx4sd+lnJkODJP3M9yw3cxN6fT3FEjG tqMG77SlQOGeVxZL5maj0OR3C4Su3In1/hO8TjIk6OWEfbC1QiQ5iiqxYsSghr18bWsC SUQ8xt7Fd/5NRAj9FKrwraN1GCrKB8CH8oLw+2qnIQKh5nNkwWspFABirifhbPQ+T2ax O29Ypee7FMyPhn+VIjq2v47Rnom2Utn4ZcroQ3PCM462rY3OYrRQmuPxFW98K8gbI31g DQAMoO7QyJ4Ero4zJOJQQWgO4gUdnIjAJudO6fs37fgP2duv/D0mC/KEdEHPCMeEQ7xF CddQ== 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 u17si647120ejk.29.2020.10.20.22.58.40; Tue, 20 Oct 2020 22:59:02 -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 S2407021AbgJTPCX (ORCPT + 99 others); Tue, 20 Oct 2020 11:02:23 -0400 Received: from mga06.intel.com ([134.134.136.31]:19882 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405917AbgJTPCV (ORCPT ); Tue, 20 Oct 2020 11:02:21 -0400 IronPort-SDR: 46untAN8+2JQILsBWGwtbxzP1i2uAoqziEjAT2r4chyviY3CjlHxg2uh1u0d8+/18PuPmSOg6k OrBAQ/IcMeRw== X-IronPort-AV: E=McAfee;i="6000,8403,9779"; a="228851185" X-IronPort-AV: E=Sophos;i="5.77,397,1596524400"; d="scan'208";a="228851185" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2020 08:02:20 -0700 IronPort-SDR: nNCBEpHhd0zpQmNwiJUP5M5g6ce2a1I459p2Lx776XxNZVx+WRtl9io7EwY9zj3AFVRQ8+SMDT EWe/qPObeGcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,397,1596524400"; d="scan'208";a="301755401" Received: from sqa-gate.sh.intel.com (HELO clx-ap-likexu.tsp.org) ([10.239.48.212]) by fmsmga007.fm.intel.com with ESMTP; 20 Oct 2020 08:02:16 -0700 From: Like Xu To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON when vPMU is enabled Date: Tue, 20 Oct 2020 22:57:54 +0800 Message-Id: <20201020145755.122333-1-like.xu@linux.intel.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Intel platforms, software may uses IA32_MISC_ENABLE[7] bit to detect whether the performance monitoring facility is supported in the processor. A write to this PMU available bit will be ignored. Cc: Yao Yuan Signed-off-by: Like Xu --- arch/x86/kvm/vmx/pmu_intel.c | 2 ++ arch/x86/kvm/x86.c | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index a886a47daebd..01c7d84ecf3e 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -339,6 +339,8 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu) if (!pmu->version) return; + vcpu->arch.ia32_misc_enable_msr |= MSR_IA32_MISC_ENABLE_EMON; + perf_get_x86_pmu_capability(&x86_pmu); if (guest_cpuid_has(vcpu, X86_FEATURE_PDCM)) vcpu->arch.perf_capabilities = vmx_get_perf_capabilities(); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c4015a43cc8a..d7b8f98ada93 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3042,6 +3042,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) } break; case MSR_IA32_MISC_ENABLE: + data &= ~MSR_IA32_MISC_ENABLE_EMON; if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT) && ((vcpu->arch.ia32_misc_enable_msr ^ data) & MSR_IA32_MISC_ENABLE_MWAIT)) { if (!guest_cpuid_has(vcpu, X86_FEATURE_XMM3)) -- 2.21.3