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 C9425C7EE2C for ; Thu, 25 May 2023 17:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231869AbjEYRqt (ORCPT ); Thu, 25 May 2023 13:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239967AbjEYRqj (ORCPT ); Thu, 25 May 2023 13:46:39 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35E7B1B1 for ; Thu, 25 May 2023 10:46:17 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-565a33c35f6so2606177b3.1 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=ANvPIuYy8ARk8PBEmZtc/XeALj3ylAueUYKIGjtPq5R9So7KF8j+pAgi24V3XgKDIZ Tf2rHFCG92QmWz6HHVVM6P3qZNdx+sr7wHJaQLytXaeFWCMN8ukP755WZjf0gdhkukf8 SUZHsKicFp+6uFZIwM3ghhpSZcmtu5nwcrmWOhInFhswBHEy/ycS4k/khKksGzmrEkbv 12q3f+ofF4x8JtVo5c+2Gs8we2I3AMD829pna6gSborNwh/WqJ+uW85Pd+Wv9Z2tVWrI RaB7jSHC8TtKg1tRePPZvB4lseAjzxq4BuwKgx7tEJDSDXuN1ECqz45o+2heLiUD2T8H XSRg== X-Gm-Message-State: AC+VfDx3EPE0eshYjROHpsjmMWA2EJ6BSy0bTwEUnoLi04166Zbqn37S CNOCYXdwtI0koyJJLildpQh8D9HPXJw= 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-doc@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.