Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1524276ybg; Thu, 4 Jun 2020 11:52:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTPt4NZoazOipl2PdEWyH5d3kM32V8fFva7v82KoYjrCV4l0nUWqbA6Mumn947q/+tjvEr X-Received: by 2002:a17:906:d153:: with SMTP id br19mr5154020ejb.201.1591296756654; Thu, 04 Jun 2020 11:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591296756; cv=none; d=google.com; s=arc-20160816; b=EF0bnyvBg6+T1wml2xOlxHCgf1WQ39bj3j0b50MMLXhf1x8lr1KrU0TznSw+sg9jmI NMa3QJZzV49InLUbVFfx0GSrm6jHvDvIZop51/WxUOdf5glk0z+Rhtnd6sH08L/L5vj4 M2NmmfOqkZ9W8bfnqrMA0pvzPJablNOnK6ThkQGA3q8A4Z6CQlpN2ZrLOTw8jQFdsQCD /b+/Zg+aghIM4sNfSIioTwOddOWElW16PPVKY/sOEyi5UiPEkGRE+9CIvCP9INPwvQzZ JPhUfm6IW5yXsgQWJXzaLJSOL6upW6jof3knBTEJCyKWNY3UiczisDlGYJJb6KW+usNG KAaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=c0B1gOCQB3tsMAy6nQWjh9wldszMTnQJEuaouLyuBOY=; b=kc1Li+94MEHwQqYglBM6RT6HYz53iyGlKOWNmP8KPR1Y4NDkOax4BTdu7BJKcWPlOc NlWwtPHjRPmNjdPDppEj/Alqt7qwp2MeShOHLNua9bFKZ0c80RxrHruNnQB9dzgQJ0Ae DX4ta1K0cEEjlqv+LGRJHOcD+o5vK4Xmr+iDa4TKuy4qrla7zfWejjg95v4Mr3a546oY rfXGFqbVjk8OnxEhxeYVZL0IjfWDD8q1MlVTJRNyKo7phT2iMz0iygvUGgUBM5C6uN6H hUqH5dw3en0YTYSZJmOm5Ls2ouTID+5GLI2gNslrZPZQpJa1xeHyZSeIVgN95ho30OCk 7ILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NkmlohsQ; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 65si2141646edn.401.2020.06.04.11.52.13; Thu, 04 Jun 2020 11:52:36 -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=@redhat.com header.s=mimecast20190719 header.b=NkmlohsQ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729800AbgFDQUg (ORCPT + 99 others); Thu, 4 Jun 2020 12:20:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:45082 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729765AbgFDQUf (ORCPT ); Thu, 4 Jun 2020 12:20:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591287634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c0B1gOCQB3tsMAy6nQWjh9wldszMTnQJEuaouLyuBOY=; b=NkmlohsQlfsbJ8hHTHYZ8kXQe/aggq074zd3ZZ1pDa6DAkfIAw0AN0+K4m/yO3mu1uPF0H d1V4OQh00meymQR8jOYUGQQKHWuJSIWxpt23iPPdo5TW05tqL38I0yBNC5DrLyKXcj+Aax aK1BOGxK2AcIVQF+OOlmQSXZBOqcQKY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-BkptHBVwPQqQAU5QwNFBhg-1; Thu, 04 Jun 2020 12:20:33 -0400 X-MC-Unique: BkptHBVwPQqQAU5QwNFBhg-1 Received: by mail-wr1-f69.google.com with SMTP id l1so2619074wrc.8 for ; Thu, 04 Jun 2020 09:20:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c0B1gOCQB3tsMAy6nQWjh9wldszMTnQJEuaouLyuBOY=; b=ff+9H0i+TfFladok78pu8ZQBcEd4MwpaEDrYsWx3cR2Y0ymNtFPWKEjj5iDdOluc2A UtCg0fSaPuKd120pZ5kH9zgi+kPJ4RAVQsl5qJk0428zPCGWXB4LIVcUUv8/yIC2ZSyu BQ1R/ndW6isHGsSLgbB2O/jCfagyuHkf12HHhFNDIDcKe4UrANr7lS3TJoKk25yX/qNa vYmhlwQ3MZ2VdLvlLTYoOPo+S6FKy7ExDbz2ZwNTbH23g6HH9yRh1U4sCR+EzOFdHmoB UL0TmSwmu8JtvAI3WfIU01o5PCNPU2HzmeFop/k2vsu0lonYFNys14+gQ24wtuHxB5J7 /ttQ== X-Gm-Message-State: AOAM533d8kA56NDmd5GWZAQmjgrz8IKLKweK+C19OhiXx8DeZVuUDYbx 7BKTK6jzt0GiEM4wOBdmx1p2tMHBGGEpVqNi5XKR53sTXSCK+mXd6JwcFyugH312KFef1EYeIWh 9DaSXYsf2bkV5gS2W0PJ5PbVV X-Received: by 2002:adf:e285:: with SMTP id v5mr5042139wri.129.1591287631529; Thu, 04 Jun 2020 09:20:31 -0700 (PDT) X-Received: by 2002:adf:e285:: with SMTP id v5mr5042116wri.129.1591287631274; Thu, 04 Jun 2020 09:20:31 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:a0c0:5d2e:1d35:17bb? ([2001:b07:6468:f312:a0c0:5d2e:1d35:17bb]) by smtp.gmail.com with ESMTPSA id q1sm7570203wmc.12.2020.06.04.09.20.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Jun 2020 09:20:30 -0700 (PDT) Subject: Re: [PATCH] KVM: VMX: Always treat MSR_IA32_PERF_CAPABILITIES as a valid PMU MSR To: Sean Christopherson , "Xu, Like" Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu References: <20200603203303.28545-1-sean.j.christopherson@intel.com> <46f57aa8-e278-b4fd-7ac8-523836308051@intel.com> <20200604151638.GD30223@linux.intel.com> From: Paolo Bonzini Message-ID: Date: Thu, 4 Jun 2020 18:20:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200604151638.GD30223@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/20 17:16, Sean Christopherson wrote: > On Thu, Jun 04, 2020 at 09:37:59AM +0800, Xu, Like wrote: >> On 2020/6/4 4:33, Sean Christopherson wrote: >>> Unconditionally return true when querying the validity of >>> MSR_IA32_PERF_CAPABILITIES so as to defer the validity check to >>> intel_pmu_{get,set}_msr(), which can properly give the MSR a pass when >>> the access is initiated from host userspace. >> Regardless of  the MSR is emulated or not, is it a really good assumption that >> the guest cpuids are not properly ready when we do initialization from host >> userspace >> ? > > I don't know if I would call it a "good assumption" so much as a "necessary > assumption". KVM_{GET,SET}_MSRS are allowed, and must function correctly, > if they're called prior to KVM_SET_CPUID{2}. Generally speaking this is not the case for the PMU; get_gp_pmc for example depends on pmu->nr_arch_gp_counters which is initialized based on CPUID leaf 0xA. The assumption that this patch fixes is that you can blindly take the output of KVM_GET_MSR_INDEX_LIST and pass it to KVM_{GET,SET}_MSRS. Paolo