Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2900297pxb; Sun, 8 Nov 2020 18:19:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0Xtg47Wth5ZwSqUuham1dhZFsYKwyZ+LFPKyneOnOhon1/mKxu0yJlodYtah/FL8hUMGO X-Received: by 2002:a17:906:f186:: with SMTP id gs6mr13468033ejb.171.1604888342944; Sun, 08 Nov 2020 18:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604888342; cv=none; d=google.com; s=arc-20160816; b=NlH88Rd1g3UCt5cPKGSN6mQmMLADJRX5ys6/IHStk5zpwOJCNkEXRSKlXOMzNvHieE +8eWXX8Kv3Qm2dlaxh1g2wuuwmCamvJT30D9W/I21WeISvlscfp1tTw3Mhp3KXoCK20u u23RLCuKAVbkNq3dP0noBFWllMantabkkHnx10/yxUqvlJhTsurDttujftzovUeYcSDN 017iGvSuIrn6rwW+b5DktpguS2VVk8xXw/401/FobI5KS33JpIWGcG9KAOA/n5rpUTyt 0rMDaXJoVuUDrAQPItQf993iBaQ7QTmetsmcXNI6gUA0v329XCJMHYgarB6dWb+KBf/k SplQ== 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=0Njn4Prq4RoVZ+Roal3/leG0ByvRddDCDJ9J1MRqEq4=; b=gRJDOQHIfwSJ0/AjFF30bJtRVT8zewvbyiEhguQgy4BKZFIZmty1lKCfce2GDFDw/P Xw8lT9yg0vZx7Btpcjaz//Iz0/NSEvj4Ui7XXxEZsNDogO0dxLrlgNavxsCjbqXeFTZ4 JuHvAIa4qUZ8KaPcIFlA1eSHbOtsNrj3uP5SWe1n2tr0UyShsuCt8AlI1qZ8R7dHqjBS LPCwuvhPGpehCp7WGPbO69ORXPl0MWcJRlO9X+DbZrJZ/luHFmXxr3crTmA45vra9F4k tL8/dRheY+aXLtwkr8GJzjSfZSXvpOMFFkUP23baLKOils43HzLZfOUIh9hISuvvHigg 7frQ== 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 z19si6198225edx.461.2020.11.08.18.18.40; Sun, 08 Nov 2020 18:19:02 -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 S1729167AbgKICQz (ORCPT + 99 others); Sun, 8 Nov 2020 21:16:55 -0500 Received: from mga01.intel.com ([192.55.52.88]:64875 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbgKICQy (ORCPT ); Sun, 8 Nov 2020 21:16:54 -0500 IronPort-SDR: 9asik7ZeqCxYAszx8qL1EeLLOBOVd3Wsw8l5BQfZ539BLHpUcjCoXXB1kyeZciDwAJij09sFmD j7h5UFQy7UPw== X-IronPort-AV: E=McAfee;i="6000,8403,9799"; a="187684547" X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="187684547" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2020 18:16:53 -0800 IronPort-SDR: RHRTPYuFxvARrvejKIp3C65zMLqxBTSqZVLnnyLn0asaQ3RPDqho9kg8zBt7Um72ZJpZdoalGt 48N1WQVw1H6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,462,1596524400"; d="scan'208";a="540646110" Received: from e5-2699-v4-likexu.sh.intel.com ([10.239.48.39]) by orsmga005.jf.intel.com with ESMTP; 08 Nov 2020 18:16:49 -0800 From: Like Xu To: Peter Zijlstra , Paolo Bonzini , kvm@vger.kernel.org Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Kan Liang , luwei.kang@intel.com, Thomas Gleixner , wei.w.wang@intel.com, Tony Luck , Stephane Eranian , Mark Gross , Srinivas Pandruvada , linux-kernel@vger.kernel.org Subject: [PATCH v2 01/17] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON bit when vPMU is enabled Date: Mon, 9 Nov 2020 10:12:38 +0800 Message-Id: <20201109021254.79755-2-like.xu@linux.intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201109021254.79755-1-like.xu@linux.intel.com> References: <20201109021254.79755-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 397f599b20e5..c89e423f6f5e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3086,6 +3086,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