Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1446229ybg; Thu, 4 Jun 2020 09:54:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfcuQ+yq18qhFwTLV6AnBC8gHTmLSoXJonWe1gg4kUxdK9zWBjyFGcoIHT5wQUeOaBomGH X-Received: by 2002:a05:6402:155:: with SMTP id s21mr5086844edu.144.1591289684551; Thu, 04 Jun 2020 09:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591289684; cv=none; d=google.com; s=arc-20160816; b=G0RaudCR70EErBwl0kpDmyIsfEhnPTcmwnH24+oY/zA1TSb8T+ahwCsdko5PsnGPOV rA924sGbgWwsEPrspRY7JjK2ZPtzX0PGbIGkS1/wNWq8S0nm9P+VA/AAJfaqAoT9E/As CbyWxWJQu8lMIXz7wChouQI4Blk3bpTx09ewAsej1GGkEpfPyn7FJZ7aLMZVobtTm0XO 2f/FQ5k65iDhemSiRx5sNpeQl5874xwpmJ52IaIrnj4AXNVJudnV4puI0/kMR9PoDz/U 7hNB3uneXcNG2dFgh+4e3ArPXbI10ht1pP41fZpLFhts9D9aEKnFqRcng0tcSMg6OMWf gn1w== 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=oSloQZeBlmDu003tkw98+MiGlwjq8F4b7bZsC7a+EE8=; b=eAJeB1MktevxNbaHk/6EAWxY0dLCY/XiEhFkzaeK8HdcGM/l80+6UYbkV1dCCNG+24 2ct+fq2wc7hZDwFiIrLo8x+Luzo1RJpG506P2ZmQ2BdAK5Q7Qi7rEPGH5LRkT9YQYbDu MnMyXCR3YLDsZ7pg2wHeHY1se5tttEAFkOnaHS3D7nsBd5kU0dfRqCroLXwY/RozoVRm GNA26mEjBE3G17L4HgC4ed5hno1mgUqOwN3Iv+yH2J/9hg3uUnrpq8lnPttU5XNc40Iz k3lE38wBVpY3mqva9Xp2UKUEqpSsyM7rcKUkr1YoTMbgRL4f0pxKuafuxDfCoUKUWF5L RM/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZukNzRkE; 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 dn16si2263353ejc.427.2020.06.04.09.54.21; Thu, 04 Jun 2020 09:54:44 -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=ZukNzRkE; 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 S1729954AbgFDQtt (ORCPT + 99 others); Thu, 4 Jun 2020 12:49:49 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28604 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729893AbgFDQtt (ORCPT ); Thu, 4 Jun 2020 12:49:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591289388; 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=oSloQZeBlmDu003tkw98+MiGlwjq8F4b7bZsC7a+EE8=; b=ZukNzRkE+/Id7oKoUo9EfaSGS80I5HbqFoA8tCIgbqE3Kq27Xa48zL2KivKexaeOJQzyiy 6UXHEihlECkPnI4jY9yz9imACFBpO2N4YkMDn7KJRf+9MfQiaE/xoxQSPeXhorld580bRa ZuMhaM64EWV44j5Bh1CqKxl9hA74DQo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-fDRDo8yyNLaune0VjWkebg-1; Thu, 04 Jun 2020 12:49:46 -0400 X-MC-Unique: fDRDo8yyNLaune0VjWkebg-1 Received: by mail-wr1-f72.google.com with SMTP id f4so2650259wrp.21 for ; Thu, 04 Jun 2020 09:49:46 -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=oSloQZeBlmDu003tkw98+MiGlwjq8F4b7bZsC7a+EE8=; b=U4TA3B7r2mordnRBew+YLUTFNRg0jwdoVJr3Z8UJjwLJzMVwtZqol8muxZUzlMkzic tVKCzJ3kSHudyw4S9rhf4EUqZoLqCN+k9x+G1/Ehm+NPYqlbo556Zt6VHu/8rdKnMU1j kk3nk8LP6nfS2jo7cRRchld4GT1S8xkRDPHcOsMkuEs0T0SxxdMaEUrMdEPfQCAhBpah 7wbLxpcolinfgQPfslNyZchoIrGW8559/4JTqQKI+5TRGcX2smXAQl+O8WE27newwtQo LMFL2vtznE3ZaSzFVxEI91P4VkkxwchgfTpeiPNxLjzC5Ld2jWZ18d5IQLG8OLENlIQJ TICA== X-Gm-Message-State: AOAM5339CDlCecn/Her5r8RbNIRVG324o109ffnDFhgYmqvFOPQueG51 Ae9lyrmEeWLZngwt12ZQ5j3mXi5wqhXLT0qDCn6uyve/g6FVeqkZ5K6ZYw63i41mMd6t/P6f8Mc 8vtppKXwYhqu8+UYUnIbf/v+m X-Received: by 2002:a1c:230a:: with SMTP id j10mr4793478wmj.124.1591289385464; Thu, 04 Jun 2020 09:49:45 -0700 (PDT) X-Received: by 2002:a1c:230a:: with SMTP id j10mr4793461wmj.124.1591289385262; Thu, 04 Jun 2020 09:49:45 -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 t7sm8832001wrq.41.2020.06.04.09.49.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Jun 2020 09:49:44 -0700 (PDT) Subject: Re: [PATCH] KVM: VMX: Always treat MSR_IA32_PERF_CAPABILITIES as a valid PMU MSR To: Jim Mattson Cc: Sean Christopherson , "Xu, Like" , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , 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: <285863c6-ef4b-a6f0-d223-ebc7cc515f84@redhat.com> Date: Thu, 4 Jun 2020 18:49:44 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/06/20 18:44, Jim Mattson wrote: >>> 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. > > Is that an assumption or an invariant? Both, I guess (a valid assumption for userspace, an invariant to be respected for the kernel code). The part where we don't fare to well, is that a bunch of MSRs that need save/restore are _not_ included in KVM_GET_MSR_INDEX_LIST (and the PMU is the biggest if not the only offender there). Paolo