Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp850699rwl; Thu, 10 Aug 2023 02:36:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfGbvKi0UYvk+lmxuaXSJa3rr7RsbPcqiQYDP8SMFCIWq/P/VmiqAYvi0/45uV94x8r7r2 X-Received: by 2002:a17:902:e810:b0:1bc:98e2:e395 with SMTP id u16-20020a170902e81000b001bc98e2e395mr1788939plg.59.1691660181784; Thu, 10 Aug 2023 02:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691660181; cv=none; d=google.com; s=arc-20160816; b=XmMn6nB5wajNgvY1ZeogJ0VRi6GiSdA7FU2D+Cka4g0Wt2ZWxN3ys+6AzXAxMzdu/T cdz2VNPQ9+MnjYB9Py6PFerZ8ozzhRJ7t0KsIQJjk44V5WH9c78kn2xQlc68fEEangc2 P5P8Taq6/XnUoEHhi3H6+vbqRBo02tO3TBY6WOciQLacLxifnwZvdXsZBQbcCQNkIz8N FSPvOawHnIva/GTaOXBgwfIbZBSxWYH0+F0PyqiO8MoenxUO8Cfr1NWjOe94t3/1T9QJ h3uCaMfUCJDl+fIdSHptFACHJWJOI/vDsP+NQ9eXOcunofBfJizAUcjmvMGwcRjhhMii KaNg== 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=sCYgAfd5bZuG3/28sUikGuYme1J7pykWX651228hrR8=; fh=/iGrNW+RblIWj1LrqUEdrz6IGW99Ktsuyq3EPKx0UEk=; b=gJ7uojEElTS/uKM0O67HwCs3XbDHChE1HEC+Cx6Uc+BqvNRzgxLNW6AVIcHcNM6Kmx Fm/x4urA9XmoobCSzE4NfnOrkacZhj75JeDg8Q2qlwiv0PQezIM1VvoZrZVx5UKn0rqX 2umT+89ZZz4YuxkWJl22oQwJzLAG0qd7PJiPC6eu2q0TCVYqmujTIY7eLaWvMo5KMfcp 9Px6VbQbZFsAmfwodyJ5Tlonkj+qLsOAj8IavdfT5Kh65Yg9aiqiMx14emn6DSCETkvt mYXRqFHt5MBBH+6ck8sM1Y7ouYsPQfmk82kM5snBjT4nuXCYT/+57FkHBVXadpIXf2G1 g3Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VvXorgPL; 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 t11-20020a170902d28b00b001bc650255b6si1140051plc.390.2023.08.10.02.36.09; Thu, 10 Aug 2023 02:36:21 -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=VvXorgPL; 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 S234505AbjHJJKm (ORCPT + 99 others); Thu, 10 Aug 2023 05:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234447AbjHJJKY (ORCPT ); Thu, 10 Aug 2023 05:10:24 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 686F7211E; Thu, 10 Aug 2023 02:10:22 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 41be03b00d2f7-564a0d2d35eso460328a12.0; Thu, 10 Aug 2023 02:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691658622; x=1692263422; 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=sCYgAfd5bZuG3/28sUikGuYme1J7pykWX651228hrR8=; b=VvXorgPLVm/eEiFpVC0OIv0jPwu7sPvvMO30Dp8Chf7YNfeYIlXawKXW0/rSn0rQgx DwuRLG/LX09ieLeAebicdXsSAJn2sw6vdBOsVYNyAqGEAgUX3JbW3JynOHl/rdGgA7Ao orGR7iyF80qBS57wSzBaMZWk0hKIzTzJO5ysUnCizqY4vMyjQ2moL1+4E8cxB5Jsmm5F lbxXG/gnVylwiMaPPmMsJQQvd+D8YKG2Oj+jA4EN1JhVWIfDm6PLtwM+7wPqsAWjEOtV 4LNS+ApgsMLFD6LuVOdkxvIoIeWhfNN+MQ684U+66FYCVGpkgN0A+hshXDvSvgXDw8ta 6FsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691658622; x=1692263422; 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=sCYgAfd5bZuG3/28sUikGuYme1J7pykWX651228hrR8=; b=aYaZQSD8QB0MHjyGTre6jWUO/3kTrS1QmUHHCkeOYDxGuJU7plOo+hN1DOGxSCD6aW PwmnQbQLaP9U7oeWDajeCfYOl3z7Z3oCafW+nax8MS9c8aXS5B7b4gUCEl7kElv/blJP Tom4gYD7W4k9JEkS66zTZPrCQJ2yqtiv05/nbVv2B4Dq6ODgPYLkc9ymJRMiQl9qENMw q/yejSTfuP3Ky0ZJUrHg72j+k4KVh6WbQIzTzfpaMqd81uRWHL7+NXpeC40dVP/Ivxlh I3M+8agbQ7Lwg1Cfo7ZJaW7txOqW98cSSASq++LLRDOEWDXZm+ReQC7Wg+Z80zyiRX2A 7mMw== X-Gm-Message-State: AOJu0YxL9cxXaAMBXWu316dAVxNJ++iymfvwivoXwLnyHExCvBAbjVEm rKMltDJcS92OiNiL/rQ8MjY= X-Received: by 2002:a17:90a:9747:b0:269:96e:7d52 with SMTP id i7-20020a17090a974700b00269096e7d52mr1291397pjw.26.1691658621801; Thu, 10 Aug 2023 02:10:21 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id pc16-20020a17090b3b9000b00263154aab24sm970704pjb.57.2023.08.10.02.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 02:10:21 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Paolo Bonzini , Isaku Yamahata , Jim Mattson , Shuah Khan , Aaron Lewis , David Matlack , Vishal Annapurve , Wanpeng Li , Like Xu , Jinrong Liang , linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/6] KVM: selftests: Test gp event filters don't affect fixed event filters Date: Thu, 10 Aug 2023 17:09:45 +0800 Message-Id: <20230810090945.16053-7-cloudliang@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230810090945.16053-1-cloudliang@tencent.com> References: <20230810090945.16053-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_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 event filter behavior in KVM. Signed-off-by: Jinrong Liang --- .../kvm/x86_64/pmu_event_filter_test.c | 27 +++++++++++++++++++ 1 file changed, 27 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 732c76c41bb0..2166b4085ca3 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 @@ -838,6 +838,19 @@ static uint64_t test_with_fixed_counter_filter(struct kvm_vcpu *vcpu, return run_vcpu_to_sync(vcpu); } +static uint64_t test_set_gp_and_fixed_event_filter(struct kvm_vcpu *vcpu, + uint32_t action, + uint32_t bitmap) +{ + struct __kvm_pmu_event_filter f = base_event_filter; + + f.action = action; + f.fixed_counter_bitmap = bitmap; + do_vcpu_set_pmu_event_filter(vcpu, &f); + + return run_vcpu_to_sync(vcpu); +} + static void __test_fixed_counter_bitmap(struct kvm_vcpu *vcpu, uint8_t idx, uint8_t nr_fixed_counters) { @@ -864,6 +877,20 @@ static void __test_fixed_counter_bitmap(struct kvm_vcpu *vcpu, uint8_t idx, count = test_with_fixed_counter_filter(vcpu, KVM_PMU_EVENT_DENY, bitmap); TEST_ASSERT_EQ(!!count, !(bitmap & BIT(idx))); + + /* + * Check that fixed_counter_bitmap has higher priority than + * events[] when both are set. + */ + count = test_set_gp_and_fixed_event_filter(vcpu, + KVM_PMU_EVENT_ALLOW, + bitmap); + TEST_ASSERT_EQ(!!count, !!(bitmap & BIT(idx))); + + count = test_set_gp_and_fixed_event_filter(vcpu, + KVM_PMU_EVENT_DENY, + bitmap); + TEST_ASSERT_EQ(!!count, !(bitmap & BIT(idx))); } } -- 2.39.3