From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AF84C7EE2F for ; Thu, 25 May 2023 17:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbjEYRqv (ORCPT ); Thu, 25 May 2023 13:46:51 -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-Google-Smtp-Source: ACHHUZ6uecTzKvghpOusKXyvvuAFO92WI6ZAoaZZajrASjfWuYLGwgqWAH1KX8n/LYSi4fQ+kXcbOnBKe+w= 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" 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.