Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp351737rwe; Fri, 14 Apr 2023 04:01:54 -0700 (PDT) X-Google-Smtp-Source: AKy350akmNGerbELbWRefy8/UbuTlXaxMX2FYxeurrtb8p3JdEdVAuYUINwZsMi8CP+EE5vH6dF2 X-Received: by 2002:a05:6870:d18f:b0:183:f806:29e1 with SMTP id a15-20020a056870d18f00b00183f80629e1mr3323188oac.19.1681470114582; Fri, 14 Apr 2023 04:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681470114; cv=none; d=google.com; s=arc-20160816; b=B4x4J7tSPQOaqrGuLoZhw5JOJaPN3o6XL/7UP6uWzNiYd1ZUW95gtqV6R8lqlbGyQ6 CJjM+w6xN5EUVYHUsm7g5o6Il+g9hnu1uhI/6dP7GuRz8kKtjOysqFpKV4caEOAy8t8m GTtSMi7py/A6wSg45MkTx9FnEmGQeIER3KEYDiSGmLGHrkuXtA9ysyQTENoMTC25oArC jThHFZjmyCIKBWM0sTuoTHNnzB13oeqr65VPUOQkDhwNL59A1gXObpK9JF0hEfTgU+YH u0VQVVejQRfeyJHiRjAbW1L+UEmJ/dkcEXl/62VUg1AGU9gQEUZSizDxdXDiq+1dpKnQ XYMg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=SXpcj70JoUaJaQ0NFshY48FX4MFUJATqGyPFJPRajLc=; b=AcOsM3z2btsBaWY8nAN07eLcs2HQedPqCiR2uGpsRgeIvChcm7ZrxilmJu50Hnrx6x KUvXNff0nVk6jLwTyplQfYTwviqx+io9Zw6bAx7a2yPVq7uu4XCQCp8xHWG/5KHUWUWR B811rcYL4u5KWWCdMtIpPb/aRSgaXIZHI+kU0pyYkprcY9H7R5fhsL1Uu7pR7OC3PKV0 e64WgKoA02Rd4QVDS06hV0OU92/SSQeETR79yxLUowKn2s6zbEc9RqsJBlNUb0OOQJ5X zzKhuIdXOCYT/nDGyylRoGm5BJdJ0wR05FQMQR9xf9s5E3rmvty9sK/f9SRD6z076fpj wIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EApi17XE; 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 a21-20020a056870b15500b00187bbc06740si220536oal.109.2023.04.14.04.01.37; Fri, 14 Apr 2023 04:01:54 -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=EApi17XE; 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 S230188AbjDNLBO (ORCPT + 99 others); Fri, 14 Apr 2023 07:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjDNLBM (ORCPT ); Fri, 14 Apr 2023 07:01:12 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECE5F59C5; Fri, 14 Apr 2023 04:01:07 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id o2so17929301plg.4; Fri, 14 Apr 2023 04:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681470067; x=1684062067; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SXpcj70JoUaJaQ0NFshY48FX4MFUJATqGyPFJPRajLc=; b=EApi17XEoO7KVLD25sQ3EXFiWunGLgsXGTs5ZivpM9H0+tlXadOfm2LoeDTpiMvORF pS1IuXe0wT6hrCKl90O3/JeOM0dhKy7ACjlNIjElFe/RfEBGlDthJQhz+PIXaj8fm75z 4pO6BaxQIYhKMjgtBfBmajBpoj99NOac/ryk2HZbZTugnV6gSlgWJng7knM7D4sXerD+ EEBzPCNvTDXRvFQxnsbTehkoEPc1t7oXu8LO4NfpHT22hWTdm6fqqlylY+SvGgpmOpES DraSrGtOx/8K8XMdAPGtyMngsjXiTxkXOlwWYKBWId0xr3KJiibobtrxwsSL4HA8V8AA esog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681470067; x=1684062067; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SXpcj70JoUaJaQ0NFshY48FX4MFUJATqGyPFJPRajLc=; b=P6qoUq1UcskdgaLrkWfSUKCVAKOlYQhYudwx0aW/PUHUbyZwJGWlUeAK2ty29JSHqh YCRQv8NvxYYvhRv5o8/cFaruEY5l/0Ny6P9TuWyvdLL+ofboRNohFxxWgCOJkoG8HWK2 Cer7KrJRPsJOPLE4yjiZVJxugU47yi280WuQfVmjeJXrd8qD6gK13vqlnHL5tvnBGjl9 7u3xwoWCyylBe2XsJG+lvRifte2/iFxwQt1FrRM6d5MxbPL3cLkSy716XQ3EVo0j7Lx1 VaD8VJopbmHbhOqJx0iFgBbpsHF/qo/gv9BjfxfauZ8/lKSD84jfG+AN7aHcaiTSPAZt abeg== X-Gm-Message-State: AAQBX9eZixw4fq41adtdyxWKmAXLM3u+Du0WvzFPxsNMD8Dx7ag1m94h IY0aHD+N5UZp7otx1fxd7xT9jhcIZdfU2yssbvY= X-Received: by 2002:a17:902:ecc4:b0:19a:9880:175f with SMTP id a4-20020a170902ecc400b0019a9880175fmr2733094plh.51.1681470067189; Fri, 14 Apr 2023 04:01:07 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 04:01:06 -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 0/7] KVM: selftests: Add tests for pmu event filter Date: Fri, 14 Apr 2023 19:00:49 +0800 Message-Id: <20230414110056.19665-1-cloudliang@tencent.com> X-Mailer: git-send-email 2.39.2 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 Hi, This patch set adds some tests to ensure consistent PMU performance event filter behavior. Specifically, the patches aim to improve KVM's PMU event filter by strengthening the test coverage, adding documentation, and making other small changes. The first patch replaces int with uint32_t for nevents to ensure consistency and readability in the code. The second patch adds fixed_counter_bitmap to create_pmu_event_filter() to support the use of the same creator to control the use of guest fixed counters. The third patch adds test cases for unsupported input values in PMU filter, including unsupported "action" values, unsupported "flags" values, and unsupported "nevents" values. Also, it tests setting non-existent fixed counters in the fixed bitmap doesn't fail. The fourth patch updates the documentation for KVM_SET_PMU_EVENT_FILTER ioctl to include a detailed description of how fixed performance events are handled in the pmu filter. The fifth patch adds tests to cover that pmu_event_filter works as expected when applied to fixed performance counters, even if there is no fixed counter exists. The sixth patch adds 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. The seventh patch adds a test to verify the behavior of the pmu event filter when an incomplete kvm_pmu_event_filter structure is used. These changes help to ensure that KVM's PMU event filter functions as expected in all supported use cases. These patches have been tested and verified to function properly. Thanks for your review and feedback. Sincerely, Jinrong Liang Jinrong Liang (7): KVM: selftests: Replace int with uint32_t for nevents KVM: selftests: Apply create_pmu_event_filter() to fixed ctrs KVM: selftests: Test unavailable event filters are rejected KVM: x86/pmu: Add documentation for fixed ctr on PMU filter KVM: selftests: Check if pmu_event_filter meets expectations on fixed ctrs KVM: selftests: Check gp event filters without affecting fixed event filters KVM: selftests: Test pmu event filter with incompatible kvm_pmu_event_filter Documentation/virt/kvm/api.rst | 21 ++ .../kvm/x86_64/pmu_event_filter_test.c | 239 ++++++++++++++++-- 2 files changed, 243 insertions(+), 17 deletions(-) base-commit: a25497a280bbd7bbcc08c87ddb2b3909affc8402 -- 2.31.1