Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp353511rwe; Fri, 14 Apr 2023 04:03:07 -0700 (PDT) X-Google-Smtp-Source: AKy350YF0hqPU8A3HmNVXjp2INE6JgAscRmBvSrClzoEf3CqTnX7TyXgdC9ybdMMblCwEhEniYhR X-Received: by 2002:a05:6a20:8f06:b0:ec:9437:84c5 with SMTP id b6-20020a056a208f0600b000ec943784c5mr5121746pzk.37.1681470187663; Fri, 14 Apr 2023 04:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681470187; cv=none; d=google.com; s=arc-20160816; b=pDwDA9dna4DokqLL/ao3NTds3JNUEnVOLGxqzKIuH8KKHThpNaBR/27WOuYKcjZxsm x6/Xt8rajoBqzj3CPNBI0PLZOg1syiFlb71FM4dLjmjbgDG+RGtzRliGJjFY56nI+27c vce5T0h5IDuleFZgvriktBVusSavwpHbSFVQGEsnpvrYOu9b012C7n20lb/FqTyLnJAs wsM0D9W6COZoggXnBCGSdyOevNMIrz8YJfzjxY3ZRYB5xHE3FrCwBjYw61jBwhUaG8PM 2MGy+YuAgRD9DofLXhqhGGeNY/tBhNzERkPfAawNnYT08MWjZLA4CXqjN01I8wASqIq2 XiZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SK9pwOgB2nPITqmSfwvLaMyb+zQIu3ReFYaoFX7ikX4=; b=FmWgoOlI4jv3lEZpepNjb85PFNr0Vb3AvvnnmhVy5pZFYF/h6jlbhgHnPpE6pPxAOZ CD5YVbOdCUR9OXwh6nNbIoes6LNbOQX5p3beMWSdXnV28db63O8a1iMC/XIj3H2wZFGe M2ehx+thkqO0JkZZRGlRRARtcuoOb4eIsz++ra9trtQlx87uDvDyFky5UALQ/Vyvtih9 5DC6JPk44hcbK5/E1bSEMTNhggLIfSW6T4NDw+w+dc9xKJMBl3UVplfinxAHOphfyvnj bQ58qImIpBvLfd9kW4xy6xZbmhAHmv7riWXD6nnCtz+tg9kWur8shqnmIVI2hZFJYuCU 4kGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PljFlbRI; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r21-20020a63ce55000000b0050c0763b32csi4320948pgi.233.2023.04.14.04.02.56; Fri, 14 Apr 2023 04:03:07 -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=@gmail.com header.s=20221208 header.b=PljFlbRI; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjDNLCI (ORCPT + 99 others); Fri, 14 Apr 2023 07:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbjDNLBy (ORCPT ); Fri, 14 Apr 2023 07:01:54 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EBE5AD12; Fri, 14 Apr 2023 04:01:28 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id m18so17885186plx.5; Fri, 14 Apr 2023 04:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681470088; x=1684062088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SK9pwOgB2nPITqmSfwvLaMyb+zQIu3ReFYaoFX7ikX4=; b=PljFlbRIrwC3l66d28sWfITf4lXIEcrg1199QsL6Xk8ADfdMZnqIiOKwFCpcjEvkvg DgtYI0mGZqCc2Ijsn2/1l3eWUFmD37wK1Ts/fhqWfWgtXHmReAsT7pzBsBBL9sDdPEVe tTWNjc9/aG6BUsBFqFpBzuJ5HPhW30Vq0BsArrL4kAgRIN1wHnOVYhLcWT0wj4wwfGwf M9ee1OIE5JtBhzizP7j/pSxzhxogCRGkvM0WGJP3DUY+/UanhWPp1TeQN1ndPxkPj9R5 wmX/mTTkWcNbzcMuxt3FfqtPq9gaTBgeNlRNQhqMKGhDpBTF4/2tSBGR4uZsARWgJqcN MzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681470088; x=1684062088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SK9pwOgB2nPITqmSfwvLaMyb+zQIu3ReFYaoFX7ikX4=; b=mDGgmOoDUGV2rxphMn7tus7iC+xt/7J75zApZXT0ttKfnsXh/noVzF4SuT/+46Zy1g 0eyEAFlsBq2iJK5oDpvcgsdlQq/I3kNLx7hh1GPwbcbM+EKrjA9VOM2svv9EsbtO+sX5 GE+8PbthBN/wpwlLdrZRX7fbp5kUgZZDxVHYEA1sKGDWWGQ5djGGIwwCtb06v2YOhUPk 7DrgJjUVRCtxc5HlQq4DeOOBqHntBsaeKw4IjnfbBsF3OYDnbnsN/A0S6r/RJ++OJE3c az7bQ9gn/URcNUeQn1b1AGhvKX8QVtE8u+UVNgoTFfRM1rObsP4hqK7tJN3OPsFxWuBG O/YA== X-Gm-Message-State: AAQBX9eWzP5yUPCQ9Z9wdGBfHU9FjbYKV5UxPrwhlWsaXx+XiZH8SPA2 O0scb1RJpLdjKuV3XFZwpqE= X-Received: by 2002:a17:902:e552:b0:1a6:6f09:6736 with SMTP id n18-20020a170902e55200b001a66f096736mr2768923plf.20.1681470088177; Fri, 14 Apr 2023 04:01:28 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id r4-20020a170902ea4400b00194caf3e975sm2835821plg.208.2023.04.14.04.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 04:01:27 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Like Xu , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Jinrong Liang , linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] KVM: selftests: Check gp event filters without affecting fixed event filters Date: Fri, 14 Apr 2023 19:00:55 +0800 Message-Id: <20230414110056.19665-7-cloudliang@tencent.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414110056.19665-1-cloudliang@tencent.com> References: <20230414110056.19665-1-cloudliang@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jinrong Liang Add a test to ensure that setting both generic and fixed performance event filters does not affect the consistency of the fixed performance filter behavior in KVM. This test helps to ensure that the fixed performance filter works as expected even when generic performance event filters are also set. Signed-off-by: Jinrong Liang --- .../selftests/kvm/x86_64/pmu_event_filter_test.c | 14 ++++++++++++++ 1 file changed, 14 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 0f54c53d7fff..9be4c6f8fb7e 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 @@ -889,6 +889,7 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu, uint32_t bitmap; uint64_t count; bool expected; + struct kvm_pmu_event_filter *f; /* * Check the fixed performance counter can count normally works when @@ -902,6 +903,19 @@ static void test_fixed_ctr_action_and_bitmap(struct kvm_vcpu *vcpu, expected = fixed_ctr_is_allowed(fixed_ctr_idx, actions[i], bitmap); count = test_fixed_ctr_with_filter(vcpu, actions[i], bitmap); + TEST_ASSERT(expected == !!count, + "Fixed event filter does not work as expected."); + + /* + * Check that setting both events[] and fixed_counter_bitmap + * does not affect the consistency of the fixed ctrs' behaviour. + * + * Note, the fixed_counter_bitmap rule has high priority. + */ + f = event_filter(actions[i]); + f->fixed_counter_bitmap = bitmap; + count = test_with_filter(vcpu, f); + TEST_ASSERT(expected == !!count, "Fixed event filter does not work as expected."); } -- 2.31.1