Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3349798pxf; Sun, 28 Mar 2021 22:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqQH+b4U8zk+5iL6l/+PdBGmkeyKufqoR+kTRdExsOyNMrr1VQ+G1Q9o/9uEZppw3hEZXE X-Received: by 2002:aa7:d4ca:: with SMTP id t10mr26551879edr.388.1616997122887; Sun, 28 Mar 2021 22:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616997122; cv=none; d=google.com; s=arc-20160816; b=FUf4I+txbSehdwirb4s8FjriaZzl/mp09XUC1z9bKxNf1qUeMvSoiW8wnkxbMKtewA C7LaDR3mgAMBTtK4uO29KtszeVOO9URMYcBnr3sA/rJsbT/Q82GnK/7B4AMQC2yIXZwF RUt1pscc5SvI3TK43hdoQilnX3zHkCKBjx6PKjnkhmmnuKrb9CfKBIoS1DySlu/9jmSa 87D/E13xcMBHQjtn5BIbB6HiYsJbRgfcWrK5M1y05EsYoFUkTBDTdWjRVOPTgqOny0JA Vtq8ZeI3Fj44zOkEbaQb1Z7e5UaftrF+Ne/X6JSjkTGAoY+5wFQJiVvr1B37ZwEZhsT8 967Q== 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=fFhapCyNqwK5e+y0+Dmk3o7hIMUfb6sMrfO3HLHkohg=; b=e6BBqPByd0yVUDjp91KitvZAc4JM/U6E0WrWV3v6eiYN3rpDScoH2PGWY6KNM7SGLw FsMvgjs5v6dDD0g4dZlyRAZv1+K621bP2FSdonu4H+k+vLxPi7oPMlPoJuKGlK2s51Et nENVJvF5bPxksH72Saqz94BrC8K9/DLhdI/di0/+OXibjCe/lOZMANXCVe7YT08/Z/mh LijI/YDRL+DZuaBdIEHrJMpi2/p+2ZhghIWxcPkbmZRktsh8/ZjXD+DqC6mDLRtsHoca OtMlBj3LzwwyXy14Y4IE2vtX1VYKVM1s/HV/r2kB2a6bE/HsCJVxrNQIBwDqD+/Wwdz9 g3SA== 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 cf5si11919708ejb.346.2021.03.28.22.51.40; Sun, 28 Mar 2021 22:52: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 S230493AbhC2Ftp (ORCPT + 99 others); Mon, 29 Mar 2021 01:49:45 -0400 Received: from mga07.intel.com ([134.134.136.100]:15632 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbhC2Ftj (ORCPT ); Mon, 29 Mar 2021 01:49:39 -0400 IronPort-SDR: +CLglwajrjfCM0187w0+26ZKq6kQJYWkq1VOfP9suNEBhKYUPEB7PRVyHGGfrnOG3p7HgRuq0K 2H6GvdmTMz4A== X-IronPort-AV: E=McAfee;i="6000,8403,9937"; a="255478731" X-IronPort-AV: E=Sophos;i="5.81,285,1610438400"; d="scan'208";a="255478731" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2021 22:49:39 -0700 IronPort-SDR: DyxNaJLyc8unW5YIXh8z0tmu1vlLey9MGIUWhg5sJCWxhFbIfgbunXI6XDVgXLdM6o1o2nrhb/ uWHv80tY73gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,285,1610438400"; d="scan'208";a="417506742" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by orsmga008.jf.intel.com with ESMTP; 28 Mar 2021 22:49:35 -0700 From: Like Xu To: peterz@infradead.org, Sean Christopherson , Paolo Bonzini Cc: eranian@google.com, andi@firstfloor.org, kan.liang@linux.intel.com, wei.w.wang@intel.com, Wanpeng Li , Vitaly Kuznetsov , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Like Xu , Yao Yuan Subject: [PATCH v4 04/16] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON bit when vPMU is enabled Date: Mon, 29 Mar 2021 13:41:25 +0800 Message-Id: <20210329054137.120994-5-like.xu@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210329054137.120994-1-like.xu@linux.intel.com> References: <20210329054137.120994-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 | 1 + arch/x86/kvm/x86.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 9efc1a6b8693..d9dbebe03cae 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -488,6 +488,7 @@ 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); pmu->nr_arch_gp_counters = min_t(int, eax.split.num_counters, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a9d95f90a048..536b64360b75 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3125,6 +3125,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