Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19778802rwd; Wed, 28 Jun 2023 14:16:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JCqKv1AydwRmRUr6negYW5Bl4gk2gdL6m+VjzxsZ5DYfczZkv5SjQl1CJJb306CB90jNY X-Received: by 2002:a17:907:3e97:b0:991:ed4e:1c84 with SMTP id hs23-20020a1709073e9700b00991ed4e1c84mr7554654ejc.25.1687986971506; Wed, 28 Jun 2023 14:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687986971; cv=none; d=google.com; s=arc-20160816; b=Ik96qZ/7VOOt7sFOS6ROc6ZiYiz530dog1mfl2DYf6JAI69uz6XsQOZuWTUdVcmD/D 4oTij86RnQCYQ4f548MP4kok6ygs3H2zlwCw4nVlA2PzJt37IvGwEZAtM3G45/FIVSZK MOGfCsrCOjalyOb1iZF9xbf6nx57+VxyWNH5WFehh9ekV89+fseEYhVQesFtORPL798v tYrn88da/eszKwJYGwkziKfydSED6M/aoSKXYSvnVVVr+lO41LCNL/GlH/6ww/5tWeKj 5nYcJiCXsDxsatxm7B6fmOWf+SHW1o6bbBW8Wff6DoYtHYWzPyPjbVelppxfCiUKkIjp BO8g== 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:references :mime-version:in-reply-to:date:dkim-signature; bh=iTvXYleREN2yij4E2iUrdc4+zuDCLfU8CgECkdsXphw=; fh=NZar1lo+0Rhg/9fJqaygQT5vsrjdPJfNAdYFy36OmiM=; b=VYn2fJxg2t2vd3dUCDsozqHZ6BOORk/eRzzOW6g+0PAYC1BoACPTeYfJG+nFMyA6fj OFOMa2048uei9q5t2wmlDqGbgpe2o4aFTccxeVIh9HJCxQMgQVCDjjKVScAqqV54G1uw TKF127AuyC69VeIBz4Pt5enBHgOqIxQ7FRY152tGCE8skpSAjNpXkLH6E8EoBLTLGiOL QjeERYCLehqWUHJn7VAZzUbQerUC7LFAlMouIoRPyarXnLD19XjPg1V8nTVi3sa9O5sw 4nDjzoC1cm8dACCSVfCN8n5N1wQgemr7WWBw5/zbZVCuhGL0XG9/7GJPrCbyCMpkUDyq 2NPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cWI8VVVE; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020a170906054800b00986539d1693si5721773eja.924.2023.06.28.14.15.43; Wed, 28 Jun 2023 14:16:11 -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=cWI8VVVE; 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 S232056AbjF1VFi (ORCPT + 99 others); Wed, 28 Jun 2023 17:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231410AbjF1VFc (ORCPT ); Wed, 28 Jun 2023 17:05:32 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC261FCD for ; Wed, 28 Jun 2023 14:05:30 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-528ab7097afso86288a12.1 for ; Wed, 28 Jun 2023 14:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687986330; x=1690578330; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=iTvXYleREN2yij4E2iUrdc4+zuDCLfU8CgECkdsXphw=; b=cWI8VVVE+Ru56ZbxlSZbx0tMknUOLoqjPH2JPTt5mLCocaJ8gX7Q5GfqTwyw8XGY8y PfVI/cEtyzXfxg7+mvUwpRuRl8eqK2/VCy6afjdbJRkR8A2uHG24VcLPUGeumDdw6wjW /fjXoTwo87IoY9+EB/D/baO17ET5i726YMsEH7tSlt/sXxBioH+K8WmOXUlU72OViZfg ZrNji/5MZPDtDPaMe82Gi1qOcIgK2lfxMPkYbzXrIFmxCb2H+Cj9fBUE3W7ZP0ZiojA7 RD2Bb+g+RkrEX3P7+KT+cZ5/6FqEUiHFxd5KyRD8R+ssSw+LTo8zcHZgVs1QkDkyi08X miIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687986330; x=1690578330; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iTvXYleREN2yij4E2iUrdc4+zuDCLfU8CgECkdsXphw=; b=EFLzrzK2aMOymAgVM/8VM+ueEKOKzBpGSORRQYFtiPXhScz0e941BaWsFpO7KJzBbv /s1Np77ekZE9BQNM4jOOuwlzDmbvHbUqGV4Wcrf2Byzv9U4vYVNJvYadVEu9EueQ7KpC g/UAx5joXknNRk4jQpLnw/rXn/4YpUZvKs09TIhiD6R6FDJXxdcHW2v7Tr/2vcnhFUh7 2CRi7i+ftMGGQQjYfFoWOMMPTeti9bYAuCO5xWDRBx2fmyY1oan5tFVQMiH3FpURaYau pfo5qJRr+LOSbWTMJpykY9G1qzHfyz15FLIPjIs9W9722KCDstn324jh67THre8CT9Mi cpgw== X-Gm-Message-State: AC+VfDxz7CHovrzWv3OCs9W9tSDhn48YmI+xhmZ1gNeB5ibGvYsefGlN SwEJ7/3BAwCRWnLder5YnMscEJMe/ns= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:e954:0:b0:55a:c91e:4121 with SMTP id q20-20020a63e954000000b0055ac91e4121mr969253pgj.5.1687986330389; Wed, 28 Jun 2023 14:05:30 -0700 (PDT) Date: Wed, 28 Jun 2023 14:05:28 -0700 In-Reply-To: <20230530134248.23998-8-cloudliang@tencent.com> Mime-Version: 1.0 References: <20230530134248.23998-1-cloudliang@tencent.com> <20230530134248.23998-8-cloudliang@tencent.com> Message-ID: Subject: Re: [PATCH v2 7/8] KVM: selftests: Test Intel supported fixed counters bit mask From: Sean Christopherson To: Jinrong Liang Cc: Paolo Bonzini , Like Xu , David Matlack , Aaron Lewis , Vitaly Kuznetsov , Wanpeng Li , Jinrong Liang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" 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=ham 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 On Tue, May 30, 2023, Jinrong Liang wrote: > +static void test_fixed_counters_setup(struct kvm_vcpu *vcpu, uint8_t edx_fix_num, > + uint32_t fixed_bitmask, bool expected) > +{ > + struct kvm_cpuid_entry2 *entry; > + uint8_t max_fixed_num = X86_INTEL_MAX_FIXED_CTR_NUM; > + uint64_t supported_bitmask = 0; > + uint64_t msr_val; > + unsigned int i; > + > + entry = vcpu_get_cpuid_entry(vcpu, 0xa); > + entry->ecx = fixed_bitmask; > + entry->edx = (entry->edx & ~FIXED_CTR_NUM_MASK) | edx_fix_num; > + vcpu_set_cpuid(vcpu); > + > + for (i = 0; i < max_fixed_num; i++) { > + if (entry->ecx & BIT_ULL(i) || > + ((entry->edx & FIXED_CTR_NUM_MASK) > i)) > + supported_bitmask |= BIT_ULL(i); > + } > + > + vcpu_args_set(vcpu, 2, supported_bitmask, max_fixed_num); All of this can be queried from the guest, no? Then you also verify that KVM is passing in the correct CPUID info too. > + while (run_vcpu(vcpu, &msr_val) != UCALL_DONE) > + TEST_ASSERT(!!msr_val == expected, > + "Unexpected when testing fixed counter."); ASSERT_EQ()