Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1328104rwd; Thu, 25 May 2023 10:59:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4T5VeMQTSPNOznLpXBVrCEzqHCplAt9zgFW59RvfOGfuMoovhxNj3U7SIdBoRtiFAtrUCL X-Received: by 2002:a05:6a00:c8d:b0:64f:3fc8:5d26 with SMTP id a13-20020a056a000c8d00b0064f3fc85d26mr9160426pfv.9.1685037553219; Thu, 25 May 2023 10:59:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685037553; cv=none; d=google.com; s=arc-20160816; b=tvtPXboxt/lZtazBqenqoy+4t+KPXLL4U/rmtDEPNttfqLcP1hKl6UrM1SpdEugh9N LvxCJXaVboMiTcB6Pi1L5ZPEcLUjNzV+wD3Dnr0kH4D+RnKr5Arm0I6ABrdjNa8NZgK2 Ke9JZCEMcTdxzAne8ZdeC8ki/tfOcbNKHV6PyQb7GUsLgVAd8SPQOPkqOWe/FM/3TdWL 9L0WUg7FXBjJa5InUr0atJlM5ZOdgkpwntDOeBrRfPhswpIpK6917kGlLc1RYTzkog4d 4/F9+2qDpH25drNozPO+RLrlS8TW2L+PPr2nVQqnAKRig/Kxqg1EkERhifeZVqbW83Mm cCtw== 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=6xpqqXPrAvFJvmn1X4m04iFO9lqyLz151DsCgMF2J2A=; b=08sK8tjJnYseJfEyUcgS0XDZKFxnOnaY6k2fJGJR0dNaQMyScvQt1Y3euDwFXojN+T qNqp6Yj5kfFjArJLRj5UYvULMg/gYWFqTVtN6phbKipk8vcuP9yd/GIzzmXCdI4uKEu0 OuaIGUmM3lDyCR2aN97vqPWzFwq9eacxngahu6dA/7e/WGRngcZW0nxBisy5/36t5nTD mBTqPbre2jBsZCKtsLbbugDVXHfAOBLuJnR76vURVEA7D27UswFtImsIYcEknBpf4xZk nsbQJTUhAk26e8X3OPSzwV6OEre2xZX75tndiTbyJILODvvhKibj/VI8dnjChYSLdp/x nuog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vsGHJnds; 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 q10-20020aa7982a000000b00635ebd8854esi2012841pfl.173.2023.05.25.10.58.58; Thu, 25 May 2023 10:59:13 -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=vsGHJnds; 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 S233502AbjEYRqu (ORCPT + 99 others); Thu, 25 May 2023 13:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239698AbjEYRqi (ORCPT ); Thu, 25 May 2023 13:46:38 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CAD1A7 for ; Thu, 25 May 2023 10:46:17 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5618857518dso11873397b3.2 for ; Thu, 25 May 2023 10:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685036776; x=1687628776; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6xpqqXPrAvFJvmn1X4m04iFO9lqyLz151DsCgMF2J2A=; b=vsGHJndszpsQgsdTVc/Azi40HECtyqi5XkDlxGBY6rgqlIl1PWECEjZy+H+NbkelvI +2l57sQdXnaIZSlMjZhOTiV6TEQKfdPsAvNE3iG2iq2G3Y7SCMqyQj/kw2tufMtbMCcA o7wBhpZIWOYH0dgYE6ChQUtyv0bo7CDTBOEOVj63onjziAuTcrTf8A9x2LB1DwJymdCN To1ewi+4lz8kZPupTR1kWQ4hC4Ulo4tXxWHQtFUJ3gadgLqiWxqFCExouCIyJUtqnC8B hd9nf4QGoSu8fdDf0plkasadfslHp+FzcHo3IqGNHNjurioOjg97iT4oMCDmBejQnJmi KS4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685036776; x=1687628776; 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=6xpqqXPrAvFJvmn1X4m04iFO9lqyLz151DsCgMF2J2A=; b=TWdy+LdtfRdKLS0to7pfwprWD4tkRGkYT7MoUColPrMvz91m7/gO1yF1rkAgR+wZEL vx+aM8Wq3wXV9gpIcFb4rVykLg5gsBxcuB4AomvS+9gB0DA+uQrupmUVdW88bL2tMmLa wbDqsu3AMDXVmNjsLLlHFuppeDACiNpqf3haaThuLJc+e1d0Bi2gftfcUWGDqC0SoS3r mi2l3t8+q2twmiv2iDS46fdtaxHZj5rzaW1zxqWpmKzcXYAo86J7w/iZcG4czJmNbrpd KWA19p5GZzDZ0S3FqWV4Q3u2OKrkx18TFnXNbCJmS4o2G2IXKUO0B4kvi8xbQv80Z/KF f/IA== X-Gm-Message-State: AC+VfDw3ZljrItALxpikzs8wCZioS49tdaUbuM//JeyvnY492pZB0SKY U/kWHW5OzrmU7EwmEYbIRVRGFwRErug= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:b606:0:b0:561:c4ef:1def with SMTP id u6-20020a81b606000000b00561c4ef1defmr227363ywh.0.1685036776503; Thu, 25 May 2023 10:46:16 -0700 (PDT) Date: Thu, 25 May 2023 10:46:15 -0700 In-Reply-To: <20230420104622.12504-4-ljrcore@126.com> Mime-Version: 1.0 References: <20230420104622.12504-1-ljrcore@126.com> <20230420104622.12504-4-ljrcore@126.com> Message-ID: Subject: Re: [PATCH v2 3/7] KVM: selftests: Test unavailable event filters are rejected From: Sean Christopherson To: Jinrong Liang Cc: Like Xu , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Bagas Sanjaya , Jinrong Liang , linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, 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 Thu, Apr 20, 2023, Jinrong Liang wrote: > From: Jinrong Liang > > From: Jinrong Liang > > Adds unsupported input test cases for PMU filter. Specifically, > it tests the input of unsupported "action" values, unsupported > "flags" values, and unsupported "nevents" values, which should > all return an error, as they are currently unsupported by the > filter. Additionally, the patch tests setting non-exist fixed > counters in the fixed bitmap doesn't fail. > > This change aims to improve the testing of the PMU filter and > ensure that it functions correctly in all supported use cases. > The patch has been tested and verified to function correctly. > > Signed-off-by: Jinrong Liang > --- > .../kvm/x86_64/pmu_event_filter_test.c | 52 +++++++++++++++++++ > 1 file changed, 52 insertions(+) > > diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > index 4e87eea6986b..a3d5c30ce914 100644 > --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c > @@ -27,6 +27,10 @@ > #define ARCH_PERFMON_BRANCHES_RETIRED 5 > > #define NUM_BRANCHES 42 > +#define FIXED_CTR_NUM_MASK GENMASK_ULL(4, 0) > +#define PMU_EVENT_FILTER_INVALID_ACTION (KVM_PMU_EVENT_DENY + 1) > +#define PMU_EVENT_FILTER_INVALID_FLAGS (KVM_PMU_EVENT_FLAG_MASKED_EVENTS + 1) > +#define PMU_EVENT_FILTER_INVALID_NEVENTS (MAX_FILTER_EVENTS + 1) > > /* > * This is how the event selector and unit mask are stored in an AMD > @@ -743,10 +747,22 @@ static int run_filter_test(struct kvm_vcpu *vcpu, const uint64_t *events, > return r; > } > > +static uint8_t get_kvm_supported_fixed_num(void) > +{ > + const struct kvm_cpuid_entry2 *kvm_entry; > + > + if (host_cpu_is_amd) > + return 0; > + > + kvm_entry = get_cpuid_entry(kvm_get_supported_cpuid(), 0xa, 0); > + return kvm_entry->edx & FIXED_CTR_NUM_MASK; Ah, I got ahead of myself. This is where the KVM_X86_PROPERTY comes in.