From patchwork Wed Jun 7 00:46:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 104165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3768347vqr; Tue, 6 Jun 2023 17:56:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7iHIJNWRF/XeQJUEHecIWzJySaPqD0OpQohshR2NvOM01a2RItSWqhfoYQHJMEOKYuX/1s X-Received: by 2002:a05:6808:8fb:b0:39a:5ea3:6b16 with SMTP id d27-20020a05680808fb00b0039a5ea36b16mr3488367oic.41.1686099386193; Tue, 06 Jun 2023 17:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686099386; cv=none; d=google.com; s=arc-20160816; b=NS/zSm6T588aHXRUF0giAS8lnJsASzefrB1DSKuFJ9ThEZXK1AFg+TT2fUaq3uKy2g O17QqjB6Qkpe4b/KkHJ31JN/X1cLmLL1LMigv5I0rzd0vWXRoqX4RTa1yg4E7G3J6MUc McnzpMfinE6zmKAkBTH8ZPUUaoEaZPt/EfhK2TNaa/lPZRsUi8DZzERGXYp0CkG98Hd2 IbrEUrAcbOtU+1/YIanr+mlNRYkMKjv6tZ4WmQGqbsLxO3GlQ86My7/Oj8AGc8ZEbLf6 +N5669dAqA8qePk0YavPR1MC21mntT75ysNHQH2ZM0BMPC5SyniRVO5tRkeXkVRqe1PA sBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :reply-to:dkim-signature; bh=/VjdTgpDcT/dS1LNnv8iDFQQueMacBncHOzc48DAKj8=; b=hivE+sMYdSfLo2F/iPZwv/IdA+XqOkjxCCZltKXcAsb4WLHEqOR01yUAz7IpO7eJoC VlscBDRbLufpsrIUouBy3KFO7B1r9DBXfiUNLnID7RQsds60esqTMfrkZdRxUOlNG6mj dmQYMiMIDn1bck/BY5jlvBXQWWXPSpC/LEb87o9Thx+z/hFOZzIGMbuh/S0sReKrVkRA 3RKILphIUJSjlbq/JUejGn0zQFQN4n1I/ngZswHZHPVYcAgMioyGwVBRiMRS1w5WEqB3 Fngs4RPiNhL3sR5ThrfVtw0fojC9VLyUBPr8TdYTFsr7ntTqljW2c1HOAkpusKP3sacF cxdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=c9AsXxDW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a170902f54c00b001b045d65af0si8445850plf.76.2023.06.06.17.56.13; Tue, 06 Jun 2023 17:56:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=c9AsXxDW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240310AbjFGAqm (ORCPT + 99 others); Tue, 6 Jun 2023 20:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240084AbjFGAql (ORCPT ); Tue, 6 Jun 2023 20:46:41 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C91510F8 for ; Tue, 6 Jun 2023 17:46:39 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-53f6e194e7bso5965733a12.1 for ; Tue, 06 Jun 2023 17:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686098799; x=1688690799; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=/VjdTgpDcT/dS1LNnv8iDFQQueMacBncHOzc48DAKj8=; b=c9AsXxDWT0gzp5q/ErKD1QiqLU2yryyO83LQCVlwv1EUlMSi0tX/m04vbma2cdeLMw Ri+hIPgk9ELtir4CkCRQPZKacnJeuweXNPSFZTHLrPJLdQlXXLHFlJcjRgu786HvdwDG Oj3gd+ZMMq6WzWagrOhbuqUE+nug6FsxF1/tgX83odv9rQQinUzNaQdGS9WYFlFTjc04 4lUHOjQhfQqk7+CrW7WW9ZRKlglcYdVsKyQnch5pW8x9YB8EN/XSOrsM4wFFFyG3+b6E vbwt1Iro+OYvtb9cR4bXN28eiV++f6XJmgMDMG335qAmy7iGENda63hRxjEZWQpYtT9H S9ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686098799; x=1688690799; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/VjdTgpDcT/dS1LNnv8iDFQQueMacBncHOzc48DAKj8=; b=ACColakc5qmAR4DtVKbMt6ZS6W2mqk6epHnMk4KGlfhkWrHtov2pI3HTE9rCBvWjAt 7UbWn3Oi/WN32AbHsZ3LRjtVQzu6fu/7n3QCDGQZr3+BJ6PZ8U0HvNTMlYFPG0UCpqPP ge4BZNxK48h9+t6Nwejn2cvMJ/IZd2DgIkKvAl7I6j60soKcdj2UUc/75evUpfBiiKbT 6EcFcxzQBoFZcBYV1waTtm4PlA5xWLxv34XfFct+nfwHWN8r/2vsW3/B0SK5vxCNBUAz bmMBsaV1OzKA1B/e9gRZ6IflTCOIWNeo+tjhrTzoJ+cNwSb/YhJ91u+xzHW1d4JK0cL2 ec8g== X-Gm-Message-State: AC+VfDznxLfmZypE16r9IbrmhydAagTKmB4bibWrGF3GJ66W3j1sfRgb EauMzE67VeNdQMJs1CJ1Vq25o/a+P7U= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:225b:0:b0:519:d08d:a4d5 with SMTP id t27-20020a63225b000000b00519d08da4d5mr824334pgm.6.1686098799145; Tue, 06 Jun 2023 17:46:39 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 6 Jun 2023 17:46:36 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230607004636.1421424-1-seanjc@google.com> Subject: [PATCH] KVM: x86: Update comments about MSR lists exposed to userspace From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Binbin Wu X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768003349866883167?= X-GMAIL-MSGID: =?utf-8?q?1768003349866883167?= Refresh comments about msrs_to_save, emulated_msrs, and msr_based_features to remove stale references left behind by commit 2374b7310b66 (KVM: x86/pmu: Use separate array for defining "PMU MSRs to save"), and to better reflect the current reality, e.g. emulated_msrs is no longer just for MSRs that are "kvm-specific". Reported-by: Binbin Wu Signed-off-by: Sean Christopherson --- arch/x86/kvm/x86.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) base-commit: 31b4fc3bc64aadd660c5bfa5178c86a7ba61e0f7 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5ad55ef71433..c77f72cf6dc8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1427,15 +1427,14 @@ int kvm_emulate_rdpmc(struct kvm_vcpu *vcpu) EXPORT_SYMBOL_GPL(kvm_emulate_rdpmc); /* - * List of msr numbers which we expose to userspace through KVM_GET_MSRS - * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. - * - * The three MSR lists(msrs_to_save, emulated_msrs, msr_based_features) - * extract the supported MSRs from the related const lists. - * msrs_to_save is selected from the msrs_to_save_all to reflect the - * capabilities of the host cpu. This capabilities test skips MSRs that are - * kvm-specific. Those are put in emulated_msrs_all; filtering of emulated_msrs - * may depend on host virtualization features rather than host cpu features. + * The three MSR lists(msrs_to_save, emulated_msrs, msr_based_features) track + * the set of MSRs that KVM exposes to userspace through KVM_GET_MSRS, + * KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. msrs_to_save holds MSRs that + * require host support, i.e. should be probed via RDMSR. emulated_msrs holds + * MSRs that emulates without strictly requiring host support. + * msr_based_features holds MSRs that enumerate features, i.e. are effectively + * CPUID leafs. Note, msr_based_features isn't mutually exclusive with + * msrs_to_save and emulated_msrs. */ static const u32 msrs_to_save_base[] = { @@ -1531,11 +1530,11 @@ static const u32 emulated_msrs_all[] = { MSR_IA32_UCODE_REV, /* - * The following list leaves out MSRs whose values are determined - * by arch/x86/kvm/vmx/nested.c based on CPUID or other MSRs. - * We always support the "true" VMX control MSRs, even if the host - * processor does not, so I am putting these registers here rather - * than in msrs_to_save_all. + * KVM always supports the "true" VMX control MSRs, even if the host + * does not. The VMX MSRs as a whole are considered "emulated" as KVM + * doesn't strictly require them to exist in the host (ignoring that + * KVM would refuse to load in the first place if the core set of MSRs + * aren't supported). */ MSR_IA32_VMX_BASIC, MSR_IA32_VMX_TRUE_PINBASED_CTLS,