Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3127102pxj; Mon, 10 May 2021 19:45:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0xKVVmzrZpx4ZPcN1a8nn5xr/PxxlW9nhqDDjH6kOe1JVWr/Tk3Il5lYVZuAPqJlrlzWw X-Received: by 2002:a05:6402:31a7:: with SMTP id dj7mr32859685edb.314.1620701107263; Mon, 10 May 2021 19:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620701107; cv=none; d=google.com; s=arc-20160816; b=bd00nQ32yNvZS7JwRYBbuHp51tFlJmHUy+2BUS0ass/kf0/0HEntxI5m7r18oMru23 r90uRBbE33oi2kqgv0bkqvrQkcuv9k1qHBsurJtum09J3oiCTlk523xapd6dYDlLRyFT QZW76IV9anbOypWXjQyRdFhVRfVnLnBjxc/oFB3qAEdQaxnINYtbEqVpoNGErUv1Y5nc 3pjIIxv4NSyQwuftA4UqyPd/STS8QjUR1MNobNsdj3cC4lLUd7fX5yrKRrUTrpNdZ1yl poECluL5p+xv3XRdNAGOJdB2qsRkVu5sudQpvMwYbuzYfexwTw0v0WVSpsSZ688XmkoF 46Rg== 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=izYQhqM+/LHkQ43+cArYYBdFS/5eUQT5pex/KtAA7Qw=; b=gL7eHtVhI9bM6B+e/2y5W9dC2HrVW2OwJSxDZ7RHnx1nvr18A1v2GxFmqtq/ZU5LUi FOEfagLrM0AzUjamGnDQ6uhwboePV95Z74DMftaw/phuZPFp3yOf3ODS7jfGllxwc/Ti OSPzxL6v6dz+GjJvTeLj4SypS0Nq2gNVA275HZdQmvQOrYeXkTj2+Xt5wF9uBqX25XCg ypAEJKMRodH76cyblZoanxkDBsGxlLya+CfBimOtZ56/hRQ1bAr2qqwAxKUEy+p2XYuo H+ioGJVF5BAcv1VOjn0GXmIzw0EmCB5XxKJVVBU6rX1Hk6C0FLlhcFNvErWzeqQdARe7 wA0Q== 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 g10si15036544eji.695.2021.05.10.19.44.43; Mon, 10 May 2021 19:45:07 -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 S230186AbhEKCoW (ORCPT + 99 others); Mon, 10 May 2021 22:44:22 -0400 Received: from mga03.intel.com ([134.134.136.65]:7532 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhEKCoU (ORCPT ); Mon, 10 May 2021 22:44:20 -0400 IronPort-SDR: 3RzsOG9pnBVifdtTkwNmc+f8J04RGHBDa6PAoH8jp0CTpHJvv70P4y2WPZ477pxRFsOSnRyNCs CguihnwmFEIw== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="199391197" X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="199391197" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 19:43:14 -0700 IronPort-SDR: 40xd/JUe5ZgE95lt8IJ+obmWzoCK59tCv8KnnfQMelB9q+wiHZkfbB+/PJdbzosTrhmuFrPW2p vkXryNIpA8oA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,290,1613462400"; d="scan'208";a="468591684" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga002.fm.intel.com with ESMTP; 10 May 2021 19:43:11 -0700 From: Like Xu To: Peter Zijlstra , Paolo Bonzini Cc: Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Like Xu , Yao Yuan Subject: [PATCH v6 04/16] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON bit when vPMU is enabled Date: Tue, 11 May 2021 10:42:02 +0800 Message-Id: <20210511024214.280733-5-like.xu@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511024214.280733-1-like.xu@linux.intel.com> References: <20210511024214.280733-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, the software can use the IA32_MISC_ENABLE[7] bit to detect whether the processor supports performance monitoring facility. It depends on the PMU is enabled for the guest, and a software write operation to this 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 5bd550eaf683..abe3ea69078c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3211,6 +3211,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.31.1