Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp690887rwd; Wed, 7 Jun 2023 05:48:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6sclRniEQ0AiZG2S8RtIuFhsanJ40+RsMw76m2h0IH6oikXYLok9BVH91psqCg060I4FXV X-Received: by 2002:a17:902:dacc:b0:1ac:8837:de9 with SMTP id q12-20020a170902dacc00b001ac88370de9mr2303248plx.3.1686142104254; Wed, 07 Jun 2023 05:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686142104; cv=none; d=google.com; s=arc-20160816; b=L3gZEfrI4HfGCntA6+076k1baG4+pK/u+qnSJ1GfF/I2KD2uoKkb0cQ3k4edBbA6s7 PI4W95Y9L37HhLkTR/WuD5lgbzYoPIEs9jTIf84KOZQh+yMJJ1+Z0yZFCZqszBkiCX6v o8Z3ZLdTXoGwPkFXgZmfurosSWug+ElxJBWMutrn5IZdR6Dm6uVF/nBGY/hk6RohPIxL uMSTUeIn7LuLwt/ndKNaqExCkGEsMIIJmA8VMUfqJAXfeoWZx7oUTcSnBHma2qYlOQ0F zcAhNm+1zxX1OSJs7BLVNVz50RHn51GEHxsUa9aZBZW/d2R0NMLdJuU+8ggeNQ6Cwv5w mTpA== 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=9JulaA06kDm2sGfAisFXplukNUhlKK2eT1+N5qu5QA8=; b=WTJMZQrOHD0hvPkEPWKS5mZMAMUWVwJfrke9yFnQ5Oe5ATFW3KB9+9J1eA9YDgXdnB W0KxAcf9woxn44+Xzps7bHCIMNfhAkWzZtEGAW2di3dSa/5LyotkcxcdhNFea836C3HJ OaVQ7zVEERfvY5ktFaXAr0orHY4yQU/mz4Y04OgpY9ElR2ECQo4p2MgUu4/84zQNeJQi 0QYX1bTG0YAmXm0qik493y6g9GMIbPqKsINia37MoN01o4mfShhY/5lfnhmIfW17WDd8 ImYiVJmOvJ2gBQ2lG0bCLVcfG5b/7Hwh1RCDldkw6KWkE89G9kccawaZp5wRa1CaZMup gF9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=NVaskHjN; 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 ij21-20020a170902ab5500b001aaea258805si8802095plb.134.2023.06.07.05.48.06; Wed, 07 Jun 2023 05:48:24 -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=NVaskHjN; 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 S240973AbjFGMiD (ORCPT + 99 others); Wed, 7 Jun 2023 08:38:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239871AbjFGMhb (ORCPT ); Wed, 7 Jun 2023 08:37:31 -0400 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5E261BFD; Wed, 7 Jun 2023 05:37:29 -0700 (PDT) Received: by mail-oi1-x241.google.com with SMTP id 5614622812f47-39c6a912fbfso424536b6e.2; Wed, 07 Jun 2023 05:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686141449; x=1688733449; 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=9JulaA06kDm2sGfAisFXplukNUhlKK2eT1+N5qu5QA8=; b=NVaskHjNhPFgUZLhChEdjToQh+YCHQSm9cUwDsJmmrQ5r99ZaxRwtPd4zAOqUJDcxX I4Ys104Pl/qRzOZtIsBl3AQbojPlCywRnSLiWGOJJzQQJPyNAj8Rw4R/iEAbNRmuLnJE wU25CzkIL8tiqBzpL4vM4gfdA91NsHGEMG1cr+uq5oGW1/XtK7wKh06oWmUw00CpKjU1 MqE1wszRTT8BijgVoUK+syKnOMrUtsUDt9AOmJABVtCpYJPh7UE/eVqXA7Y4lRxECQT1 WS6flTZJr6REXSHebzPNpZvJwkEjOTNrb/GhusbTn+vW87kBIxkQWqEN3J1vnmU8jXt+ Afvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686141449; x=1688733449; 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=9JulaA06kDm2sGfAisFXplukNUhlKK2eT1+N5qu5QA8=; b=lF8YK0dC3l/m3dPao1xISqgOzlbU9kZbSwnnPRGXK53KU1idnbGaBG/m5Xeqq+zom7 Y2AUzVrnRpTWs45zyV55rZCE5HfHWWwJcsakUuz731xWmlj83W9noG8gJXims3b9Gx2h e5qhL6U5wh65JbeCaKhSqWM8YLWvHB2yxgLTsKjNk/xTsh1BLyhVHEcXPTmOCPJ8izGx DDl488O1S3YUuFgvWVwXOPnkRf4nghM0/0WLwC6R2VCbVIwQVhOaET8l3wsd93e3LHXF 9qrkDZY2z6YxlP9R9PtTvTS61qlMaOEfHXzXQMhk3rluy0u/K92h6vcTCEZzMfnYiCT9 4e/w== X-Gm-Message-State: AC+VfDyCJyWJRQcdeziFsXIPybNoaZL9bpyukYa0cMh9ZQryby0GsmyN N+CkjR9GGimf5q3GDJ/DjA8= X-Received: by 2002:a54:4604:0:b0:38e:d739:6f3f with SMTP id p4-20020a544604000000b0038ed7396f3fmr4738680oip.56.1686141448942; Wed, 07 Jun 2023 05:37:28 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id k18-20020a635a52000000b00528db73ed70sm9038904pgm.3.2023.06.07.05.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:37:28 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Paolo Bonzini , 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 v3 4/4] KVM: selftests: Test gp event filters don't affect fixed event filters Date: Wed, 7 Jun 2023 20:37:00 +0800 Message-Id: <20230607123700.40229-5-cloudliang@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607123700.40229-1-cloudliang@tencent.com> References: <20230607123700.40229-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 --- .../kvm/x86_64/pmu_event_filter_test.c | 32 +++++++++++++++++++ 1 file changed, 32 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 72f7fdb821e5..79bfdb64820b 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 @@ -853,6 +853,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) { @@ -881,6 +894,25 @@ static void __test_fixed_counter_bitmap(struct kvm_vcpu *vcpu, uint8_t idx, bitmap); TEST_ASSERT(!!count == !(bitmap & BIT(idx)), "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 has higher priority than the + * events list. + */ + count = test_set_gp_and_fixed_event_filter(vcpu, + KVM_PMU_EVENT_ALLOW, + bitmap); + TEST_ASSERT(!!count == !!(bitmap & BIT(idx)), + "Fixed event filter does not work as expected."); + + count = test_set_gp_and_fixed_event_filter(vcpu, + KVM_PMU_EVENT_DENY, + bitmap); + TEST_ASSERT(!!count == !(bitmap & BIT(idx)), + "Fixed event filter does not work as expected."); } } -- 2.31.1