Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2560665rdg; Mon, 14 Aug 2023 06:34:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5EnVzooVMRtcvdmGw/d8FLmiH4pmIO5mO7um1li7+feOM44nasjf9Km1vFkOwEB5wpuva X-Received: by 2002:a05:6512:1154:b0:4f8:5885:61e with SMTP id m20-20020a056512115400b004f85885061emr7575638lfg.40.1692020047363; Mon, 14 Aug 2023 06:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692020047; cv=none; d=google.com; s=arc-20160816; b=VqIaCMPG9UcHTrD0z5joMLsFQtDmot5j06fhTWfV8UmOBeyOIbkM6Q6xDi0q0XabK9 hzroUfNG+LTt3eQJb4ptqBYIWR5uKDMHEMyLe3L2D/xf+dlMm3wRhn9E7AgNgUqmernI HSbTA2Y+MO2VUEebb230icTjGCKuSLN0sYLzXH1mFLCLMwE0gAf2xg1efiwc1wRUZJ8W bTiRdyEZsnwl17gRM4MYtJVZ46D6Q5vvYhIZhnsv98EhMmrNLDn/RvBaFBMs98BjsikV R4Mx79I/z6lHj+Q2S1kGsWzH3tRK7J5w32pEPS8CI0F+EuzO84o/SWT7+U7FKGqr6hGi 7tpA== 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=v2vJq0VX4ItkqoKSCpNwc42J1U8uTSXSOUgRoMRwKmk=; fh=DvD9bWv0QfYvJ3c1TOyVFnexb+PklxLMx4mXX5CNcBw=; b=H8e5EOaLryhtPOP2sVbyqqEhY9NZO/rK5f9caoY/4pSFsOmmrELNwIypwyg4beQzFh ldGwvXORq7Lr6UXKKMMn5dqDqoiBGRpADMLxj8F1iYVAW9Y13l+B+zEIH1w4irt06ltb CuI+J3hO/rT1Ssnu27fv5C89IzeS2lSLghqIpdp+dEub8xPZQ1Qi8HL1ZeX6JsDuOsZ4 sNupagfGyL/wW8uQsz2WMOxPjKKQ6ylOablhFSipNUoJ0KGMPW1vBFaIeUIuQkO7jrLz UHC3dg1SttftC9HYjRPhxJvH04uaFvBaXuoU52VK5ogCMbqTHShEw4kSugC4nR8Tbtzd Em+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CMCvbdHz; 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 l11-20020aa7c3cb000000b0052338eb3957si8147405edr.155.2023.08.14.06.33.42; Mon, 14 Aug 2023 06:34: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=CMCvbdHz; 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 S229530AbjHNLv2 (ORCPT + 99 others); Mon, 14 Aug 2023 07:51:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbjHNLvY (ORCPT ); Mon, 14 Aug 2023 07:51:24 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12411EA; Mon, 14 Aug 2023 04:51:24 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3a76cbd4bbfso4076550b6e.3; Mon, 14 Aug 2023 04:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692013883; x=1692618683; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=v2vJq0VX4ItkqoKSCpNwc42J1U8uTSXSOUgRoMRwKmk=; b=CMCvbdHzjLDaE3gR3GCdb41fed1pC3kjgfQ7tXnqEEdhuhy5Jdf4Wa5DqEXIIB+bnG kXxUaFAquxx0kwerGQBdV5bAIFdrAPbjE5hS7ig8aK/FwuBO87fLP6qR7V79+1LRnHNJ +Xi0jgiYiMPtzxXuy5MsuSUVU57PRqZ85SVtCk2DA3cgViDAyWEQi9kIXuEta0DuNmqm t3nw2oPL9/hFf1t5HkYpnL8bwMNX2gEvkpgw94mttk1sLgS19ngkxxlMp21cLRFl5pmV hl+g4c3Vq6z21I8gNwfayKkXclqyArXP2qveiRkFvBvj2jV0PCtrXV2kuwhM+CCh5jfH qvfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692013883; x=1692618683; 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=v2vJq0VX4ItkqoKSCpNwc42J1U8uTSXSOUgRoMRwKmk=; b=ZC8pW/yj6UdtX6+yreU49HcYGwW7/7QjqfWHXdPTpOI0mdga6O+JcD9DrwihIfgIk9 TKZ4rwhgtkZWJiaR75MsAimSS6Q84QVJT5UfVlE9O2wSnatzWYTAOtCbwX9xFv+Da5Er EjtIWO9okHmrSB7sdZtSAmripKWS/zSeJjCaTZQrdZA7bvdlHPr9j+Q+ppVcu/x4gz3C +4sfOto0+2J0iCUxhQ9+F1yNaDM5jw0FWiZ7D2dAWwl15Q0HmemN+q1NxgKolF73nTeH Wd0a1S0Nskoi86AMlhSlpYpOwEdGJelmVcS5HzZVW3GwOq3xBgW4n1NdqKP0GKD6bXPL Mdpw== X-Gm-Message-State: AOJu0YzWmvBj+U8CIUsM682wwikTcipi37SxhySz6WK3yK3W+JfpvpHC Vq8m7R1pEXx0L5GnGB5BBPGuuh6ulmYTtQY4 X-Received: by 2002:a05:6808:b27:b0:3a7:540f:ca71 with SMTP id t7-20020a0568080b2700b003a7540fca71mr9995520oij.53.1692013883151; Mon, 14 Aug 2023 04:51:23 -0700 (PDT) Received: from CLOUDLIANG-MB2.tencent.com ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id x7-20020a63b207000000b0055386b1415dsm8407848pge.51.2023.08.14.04.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 04:51:22 -0700 (PDT) From: Jinrong Liang X-Google-Original-From: Jinrong Liang To: Sean Christopherson Cc: Paolo Bonzini , Like Xu , David Matlack , Aaron Lewis , Vitaly Kuznetsov , Wanpeng Li , Jinrong Liang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 00/11] KVM: selftests: Test the consistency of the PMU's CPUID and its features Date: Mon, 14 Aug 2023 19:50:57 +0800 Message-Id: <20230814115108.45741-1-cloudliang@tencent.com> X-Mailer: git-send-email 2.40.1 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 Hi, The KVM selftests show advantages over KUT in terms of finding defects through flexible and varied guest settings from the KVM user space. This patchset tests whether the Intel vPMU works properly with different Intel CPUID.0xA configurations. It also provides test scaffolding and a sufficient number of PMU test cases to subsequently offer adequate code coverage of AMD vPMU or Intel complex features, such as LBR or PEBS, in selftests. All patches have been tested on both Intel and AMD machines, with one exception patch 11 "KVM: selftests: Test AMD Guest PerfMonV2" has not been tested on my AMD machine, as does not support PerfMonV2. Any feedback or suggestions are greatly appreciated. Sincerely, Jinrong Liang Please note that following patch should be applied before this patch series: https://lore.kernel.org/kvm/20230810090945.16053-2-cloudliang@tencent.com/ Changelog: v3: - Rebased to 74c2185c5b74(tag: kvm-x86-next-2023.08.02) - Add a new patch to test AMD PMU legacy four performance counters. - Add a new patch to test AMD Guest PerfMonV2. - Refactor code to simplify logic and improve readability. - Use TEST_ASSERT_EQ() instead of ASSERT_EQ() when checking return values. - Add vcpu_set_cpuid_property() helper for setting properties. (Sean) - Add arch_event_is_supported() helper to check if an event is supported. (Sean) - Add fixed_counter_is_supported() helper to check if a fixed counter is supported. (Sean) - Drop macros that hides important details. (Sean) - Use enumerations to avoid performance events magic numbers. (Sean) - TEST_FAIL() instead of TEST_ASSERT() in run_vcpu() wrapper. (Sean) - Update variable names for better readability and consistency. (Sean) - Rename functions to better reflect their purpose. (Sean) - Improve comments for better clarity and understanding of the code. (Sean, Jim) v2: https://lore.kernel.org/kvm/20230530134248.23998-1-cloudliang@tencent.com/T/ Jinrong Liang (11): KVM: selftests: Add vcpu_set_cpuid_property() to set properties KVM: selftests: Add pmu.h for PMU events and common masks KVM: selftests: Test Intel PMU architectural events on gp counters KVM: selftests: Test Intel PMU architectural events on fixed counters KVM: selftests: Test consistency of CPUID with num of gp counters KVM: selftests: Test consistency of CPUID with num of fixed counters KVM: selftests: Test Intel supported fixed counters bit mask KVM: selftests: Test consistency of PMU MSRs with Intel PMU version KVM: selftests: Add x86 feature and properties for AMD PMU in processor.h KVM: selftests: Test AMD PMU events on legacy four performance counters KVM: selftests: Test AMD Guest PerfMonV2 tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/pmu.h | 124 +++++ .../selftests/kvm/include/x86_64/processor.h | 11 + .../selftests/kvm/lib/x86_64/processor.c | 14 + .../kvm/x86_64/pmu_basic_functionality_test.c | 505 ++++++++++++++++++ 5 files changed, 655 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/x86_64/pmu.h create mode 100644 tools/testing/selftests/kvm/x86_64/pmu_basic_functionality_test.c base-commit: 74c2185c5b74fd0ae91133ad5afe8684f6a02b91 prerequisite-patch-id: 8718ffb8c05e453db9aae9896787cb6650d3cd52 -- 2.39.3