Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13817772pxu; Mon, 4 Jan 2021 05:25:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJya8gWskvznrgwtoHSzZX2uwB1REnoQct53SroooydQGSjrEBcYZmP6psHiSe0guqqkYD8i X-Received: by 2002:a17:906:ae55:: with SMTP id lf21mr66711488ejb.101.1609766757640; Mon, 04 Jan 2021 05:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609766757; cv=none; d=google.com; s=arc-20160816; b=TiClgnu/WbWLQhQd++dfRSPpcAiA6uP5lh9A5scaRSkNsH2KvP/AzsqdAmQtDcij3N EhHW6rDn+zG61SKylYvrBhaHTuFBlw7Y6XfUBl/qhKEnOwQqy9KmP0AceeKQYllPtAry /HZZEOSKI/i5f/3bU1vO9lr60RxkD3zXbx4+OhAFQ6kOauomr06S1/V50e86q1Ffp1Nq uxnJZW4aTcsir416FcldIAAAqcG7WOAVPdIlDEXFuhiVuL/GbySjIp0bLCIDotR1fD7Y 8YSEGVq/oeNdPxeEUEymNDOkPthOgN0k8PQfzrp93DBBupUHxnoYJMkTmASYbih38X5J jbsQ== 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 :ironport-sdr:ironport-sdr; bh=zNk6KEA2jRLaiJZPZ4UoNE++jOWIqfuebDjzN3izGqE=; b=zG0Cf+ntkig8Xmdt+OOsEU9Cf+70gY7OH5A6IZovcVMQ1luwzBGiz2MyTvISjKBlfa NMIifhdDnAT3sA99B5oiLCRyKVVJb6C08xglL0/mIaHiWVR16BZTnNfYiVlewxQB6Kgh /7tjSn+2Ure9gMlhsMRW9pfSqP79v+oO+A1Fn4Mc2FX79hTj1kNmFBC4YFeT++nyfR+l glrDQwVyDcb7e0h+7o6nfwYw85itJmOinQHmmnEmyRB8c/unpfPBRorFXnEK7HDMtJPZ EoqxoTe2sggpp59/temM/jAV/5x/qX0IemFLHj8zIp0nHLkGY5UARs+eStXRXh3k2Krb bwHQ== 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 nw24si28816933ejb.647.2021.01.04.05.25.34; Mon, 04 Jan 2021 05:25:57 -0800 (PST) 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 S1727106AbhADNXs (ORCPT + 99 others); Mon, 4 Jan 2021 08:23:48 -0500 Received: from mga07.intel.com ([134.134.136.100]:23246 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbhADNXs (ORCPT ); Mon, 4 Jan 2021 08:23:48 -0500 IronPort-SDR: 9p3odE7WzXEoN1Zibw7uN85UZP1GWYftErRYavq70538zRR0H9tXZ29dbpVNRB5MaHEW8+xqjv d4VL03y9+A8g== X-IronPort-AV: E=McAfee;i="6000,8403,9853"; a="241034281" X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="241034281" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 05:22:02 -0800 IronPort-SDR: PbsYVrggunTjJG9WroORn0Ml13OzSR3mXiaXkiAvZFtOdX8wJDGHdAqzeGGtir0tpmzqr7PoNM F9D+0dJXJcyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,474,1599548400"; d="scan'208";a="461944514" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga001.fm.intel.com with ESMTP; 04 Jan 2021 05:21:58 -0800 From: Like Xu To: Peter Zijlstra , Paolo Bonzini , eranian@google.com, kvm@vger.kernel.org Cc: Ingo Molnar , Sean Christopherson , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Andi Kleen , Kan Liang , wei.w.wang@intel.com, luwei.kang@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 01/17] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON bit when vPMU is enabled Date: Mon, 4 Jan 2021 21:15:26 +0800 Message-Id: <20210104131542.495413-2-like.xu@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104131542.495413-1-like.xu@linux.intel.com> References: <20210104131542.495413-1-like.xu@linux.intel.com> 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. It's dependent on the PMU being enabled for the guest and 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 648c677b12e9..87f97ffa9966 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3094,6 +3094,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.29.2