Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1566145rda; Mon, 23 Oct 2023 17:26:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5ZJS2AqCTtsRHyC11WpErJn0VxRg1Kp51QN57fhchCAAzVoxtGcngU/WXFilzotpWj7o+ X-Received: by 2002:a17:90b:4b8a:b0:27d:4282:e3d2 with SMTP id lr10-20020a17090b4b8a00b0027d4282e3d2mr7619658pjb.30.1698107215121; Mon, 23 Oct 2023 17:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698107215; cv=none; d=google.com; s=arc-20160816; b=cAhVN7ZMp/UtrPnXqrEbGiz2uSl31LaGAOEDjDUhDwIHc1ZrEP0PyBZ5Gl4AYI5PO/ ktg7+st7ZbXiWUpLCePdHTXL1laydKpvN5uUBx1N5oeNGAlNGSsgFkE6fXp6/7d4Evb7 mCS9ETDQJsYmsXdOp+Dyma/9as7gdbBShj1jA18UB7DgdXltylqP3paNPrI7hhLu/MVm 6CcjtV3YPHWTqqFxllblGwqFGqc3JKen3Sjhy9iXLybZo7HI3b6dn4xef8JIGAXvVHKx KFlq+6Vj+QmJPBZChPyKFvUNzX5fLkdrIdDSRegFf/rCg5VheNjIXfF854uFwp4KTvvv EaAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :reply-to:dkim-signature; bh=wbzzjILwprMa7QV/3rEm9217vDHRa2W9i0FThHihDYc=; fh=D//PLXZS63mgWSQM2kcZZyW+2k64a7rh3i2k12EZPR4=; b=Wtx3iuqa0c2ozPSV4QrYPl1Q+8Km8dC92bIurG/bypkuXQKGGbd8W2Lm+WRKZAqKrF 1HKMg03E5DVhbuLeXHNynO2QktoauNckftTzMnU1bdzKfF4aviZHzkgtJJPMRvljPeQR Zax+pDvoVMLPF8Zgujkmv2GAw9rGV5Mf+66qzjPt4m+NFY4vX1Yh8IdHln9ZKK78xeNi EZMau0j7kAatRip3iL70XqRxBU4gjnLMEQMgnuUiw7KlBf8eQwHz+aeG32QftebNKOqr n9H/44PcxdSh/QMV7NFAIoLxy4pE6fGSYd3U5YufJPgQrw7fRlhMLS60T5uyBgHtrH1o lNZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xGRuFJVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id gj19-20020a17090b109300b0027d0c811520si9465320pjb.95.2023.10.23.17.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 17:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xGRuFJVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 43914803EF04; Mon, 23 Oct 2023 17:26:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbjJXA0k (ORCPT + 99 others); Mon, 23 Oct 2023 20:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjJXA0j (ORCPT ); Mon, 23 Oct 2023 20:26:39 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A287310D for ; Mon, 23 Oct 2023 17:26:37 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5a7c97d5d5aso55024057b3.3 for ; Mon, 23 Oct 2023 17:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698107197; x=1698711997; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=wbzzjILwprMa7QV/3rEm9217vDHRa2W9i0FThHihDYc=; b=xGRuFJVMi5QWO6WElspl/zpMuWQu4WXiv6m7rDSEHFe0kjcC3tNFhHkSqV9BteIIAG 1JfrJcakG94sB0NGf1ocOBY4Kc3Mse9aEbj4wb7p6Ymd38Xe16PwdETotMNTKePjo849 I1MbI28tLLG39Gh6BywNP2cBmjygwLfsS+sfY7TKee145t2YrtNesIp35glUFH28U/2Q QrAeRRGEETHFuWcwrHEI0fEnzDPpRaCdaa1H3l3cbc8WKudA+KM8rSXN38PGmiZrvMCG l46edwoa6HntJEsMFSKMkWT+lCO99Ybg69hcG4oO8bgesLIl+uFUc+mRONPbFAyWHKqB Fwqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698107197; x=1698711997; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wbzzjILwprMa7QV/3rEm9217vDHRa2W9i0FThHihDYc=; b=ZfLhunmOpGRZLiHk8sla27303uxRBN0HUTtiUbh4T4EEK/gSm6PFJkz6uKn+jYtpDG 1Iyq5s0wro7O/WQ4i+64b36ap5laHaLoAqJkTetOmRzBG+hhNcmFn7swmvhbm0U1RtOG guin6D2LZpuFykbY/7ywJ13BiywXHCOt35jDjMEAkY8v0rGP6fYeOUB1okQRK+wAQVzz +xNPKTEozUP5a9Pb9NYnCvYHHmOkOs7pR4n05oafvJh0SwPiHj2OiTOAO/8A/TarZChl GnCEhPqxAe8mivSxBaFGQ3em1w7JanMcEkj0Y6lORt1POdGhopfU2dpTatoH4sWGHSuo +dVQ== X-Gm-Message-State: AOJu0YwNtMSCnzJzGmj8kinIEsyOnYP7MJ+AkgYvNCvmnfomiblTNn7H G5UqkXrvgbxd5szRMSvWICnJAZUQptg= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:4e0e:0:b0:5a7:a929:5b1d with SMTP id c14-20020a814e0e000000b005a7a9295b1dmr234676ywb.4.1698107196918; Mon, 23 Oct 2023 17:26:36 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 23 Oct 2023 17:26:20 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Message-ID: <20231024002633.2540714-1-seanjc@google.com> Subject: [PATCH v5 00/13] KVM: x86/pmu: selftests: Fixes and new tests From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jinrong Liang , Like Xu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 23 Oct 2023 17:26:49 -0700 (PDT) This is effectively v5 of Jinrong's series to add more PMU selftests, with a focus on architectural events, fixed counters, and CPUID configurations. I reworked things quite a bit, but the core concepts and what's being tested are more or less unchanged. The first three patches are minor fixes for KVM's handling of fixed counters. Patch 3 deals with an area in the PMU architecture that is somewhat open to interpretation, i.e. could probably use a bit of dicsussion to make sure we're all on the same page. Jinrong and/or Like, please double check and rerun everything, my confidence level with PMU stuff is still quite low relative to the rest of KVM. v4: https://lore.kernel.org/all/20230911114347.85882-1-cloudliang@tencent.com v3: https://lore.kernel.org/kvm/20230814115108.45741-1-cloudliang@tencent.com Jinrong Liang (7): KVM: selftests: Add vcpu_set_cpuid_property() to set properties KVM: selftests: Add pmu.h and lib/pmu.c for common PMU assets 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: Add functional test for Intel's fixed PMU counters Sean Christopherson (6): KVM: x86/pmu: Don't allow exposing unsupported architectural events KVM: x86/pmu: Don't enumerate support for fixed counters KVM can't virtualize KVM: x86/pmu: Always treat Fixed counters as available when supported KVM: selftests: Drop the "name" param from KVM_X86_PMU_FEATURE() KVM: selftests: Extend {kvm,this}_pmu_has() to support fixed counters KVM: selftests: Extend PMU counters test to permute on vPMU version arch/x86/kvm/pmu.h | 4 + arch/x86/kvm/vmx/pmu_intel.c | 48 +- tools/testing/selftests/kvm/Makefile | 2 + tools/testing/selftests/kvm/include/pmu.h | 84 ++++ .../selftests/kvm/include/x86_64/processor.h | 67 ++- tools/testing/selftests/kvm/lib/pmu.c | 28 ++ .../selftests/kvm/lib/x86_64/processor.c | 12 +- .../selftests/kvm/x86_64/pmu_counters_test.c | 438 ++++++++++++++++++ .../kvm/x86_64/pmu_event_filter_test.c | 32 +- .../smaller_maxphyaddr_emulation_test.c | 2 +- 10 files changed, 669 insertions(+), 48 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/pmu.h create mode 100644 tools/testing/selftests/kvm/lib/pmu.c create mode 100644 tools/testing/selftests/kvm/x86_64/pmu_counters_test.c base-commit: c076acf10c78c0d7e1aa50670e9cc4c91e8d59b4 -- 2.42.0.758.gaed0368e0e-goog