Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4055304pxj; Tue, 11 May 2021 19:02:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxliQP1NEI8DFDeq/+yvaItpgr97HdmqE3oLSl+MLwK3S16XL9XmifMJXXUBCjeZ/eaX3i5 X-Received: by 2002:a17:906:6d43:: with SMTP id a3mr35210008ejt.142.1620784949158; Tue, 11 May 2021 19:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620784949; cv=none; d=google.com; s=arc-20160816; b=vScVy2mWcBEk8nCDjl1KVK9Nnd4wfWIrAYiTsOIyhzkCn6J26ykuEnH6LcVzOKKkm1 QCdh28EBfk42wtkOIC846fvAVPwncopHeWUBlXh3cgjzJQ+zaTcorAw8zmi/nTw7KAPB usuO2uQeqvDLDEDFfZ3Hp2R8UXcV5S+OVKKqyovRAx0mWiS5lkcYzp1hP+1X/xpDpUsI RNLu25hp5SYgnp4SEDPPn5/ReSOkI9DNMBmrJRI+bPk/QJrCmYpGm+8qbK6S5JlZOSf/ 7HqnLJurcMyHGAtvZKNnaJx3othjiBU0exfz8N3EQj7rCgljvnAOZwhwY1ZD5HOYEmwl ablQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:references :in-reply-to:mime-version:dkim-signature; bh=uT4uDQPhl0Mt9nIZvogG/i4OqNBAVKbl0dDaNitDe7o=; b=VRMGJ70zPjNCLbrqHiN4LuhE+wRJP80ctGpNWJ4ZWzBBlhBjk0Iz7kVLiPx6YrDWG3 mVjW9dTNtYyid1q8+H0LBTRyENHK7i8mY3T/PYyULwyXOsdtvewkDoqhTBs5J3v/Du8g iq6kvhuASCZjgy05JGR3elnZ5xnIw3fAgqS59QaVgtuS4iSaMPKPne+tiqyIrVn6fomy dMYz1z8S/rbKeljbpzXgJdp9ERjdpsIz2caSiubfKSyD/pllgM6dTfQMVww63q4IHxtK gBkbN5ggVKeeuvSGODyc4ATCGBvzLkdrQlOGUwdARoh8HKhT88NjEv2ReNgh7uwawCDJ JS5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="ohZRK2/r"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx19si17692721edb.389.2021.05.11.19.02.05; Tue, 11 May 2021 19:02:29 -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; dkim=pass header.i=@chromium.org header.s=google header.b="ohZRK2/r"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230246AbhELB7t (ORCPT + 99 others); Tue, 11 May 2021 21:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbhELB7s (ORCPT ); Tue, 11 May 2021 21:59:48 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19226C061574 for ; Tue, 11 May 2021 18:58:41 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id c8-20020a9d78480000b0290289e9d1b7bcso19276225otm.4 for ; Tue, 11 May 2021 18:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=uT4uDQPhl0Mt9nIZvogG/i4OqNBAVKbl0dDaNitDe7o=; b=ohZRK2/rQTHNxe9lLS8mpbrsxUPHddjpjeL19IDZtz0r5ZrJWv1+xJn9zwFbQg+Z1b GH2r6SL5Dv304n+11Kg1wJ4rwMMHk8x9nv4m8El98NWMABtzOpUubk02B/WNj2pzufFP KjyLZnqQdm0Nh9qpBpTU5EBk/h6EF7c8Phb5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=uT4uDQPhl0Mt9nIZvogG/i4OqNBAVKbl0dDaNitDe7o=; b=nGzVVtd22vs5ZEtdGa5pj8FjO+RZc8VGmqzng0dKw5D1qXViCj3A6KoEREX5O3QL09 7rcpKlPD6uWlOY+6CSrjdRyGyuGrOuNs6UqPMHMyFuqvMfjB/kIuNVMsF9iQqWXzO/5A LEa7VO4I+VOpPohsHiKeJqBC+fIyi1SXGqCeECQnAXIeFib/fVv5N4gIzE2Abiogg+AP p82+9J8cMjySqprCK3kwaLI5Z+e/aBhGAhdYg2wMUYA8D322cTlpeE6NSFAuDGlQkIKB 5a6VFlQY1/puhFjnLuLkoWcHeqySlLU/3IqytG8PW7KTBy9G7S+oC3yh1pVz+fudYnid PKvQ== X-Gm-Message-State: AOAM532np10ctd5xYtH18GtY21xOT04YdDnnozAHDLCVNrEeTNMa7A82 LFJPu4/dWUwgXDpBMMHfaaoEz7WWXEV/Z5pUUCfDDA== X-Received: by 2002:a9d:764f:: with SMTP id o15mr29165323otl.164.1620784720531; Tue, 11 May 2021 18:58:40 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:a05:0:0:0:0:0 with HTTP; Tue, 11 May 2021 18:58:39 -0700 (PDT) In-Reply-To: <20210511024214.280733-5-like.xu@linux.intel.com> References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-5-like.xu@linux.intel.com> From: Venkatesh Srinivas Date: Tue, 11 May 2021 18:58:39 -0700 Message-ID: Subject: Re: [PATCH v6 04/16] KVM: x86/pmu: Set MSR_IA32_MISC_ENABLE_EMON bit when vPMU is enabled To: Like Xu Cc: Peter Zijlstra , Paolo Bonzini , 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, Yao Yuan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/10/21, Like Xu wrote: > 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. Is the behavior that writes to IA32_MISC_ENABLE[7] are ignored (rather than #GP) documented someplace? Reviewed-by: Venkatesh Srinivas > 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 > >