From nobody Fri Nov 29 14:50:00 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A52A1CA6A5 for ; Wed, 18 Sep 2024 20:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692841; cv=none; b=W8mjEa5vZ2EYhgPaZE6Uqxh+0I21bTpjR8wLG8XOTN7M7SfEEDIzlzOY865H86jkvf4Ws3RRgDgKK3gSfP+jYhioaq6VNJbcl5fct7UMlXjMNvZg1PRe5W1YqGJ/k6tUkq1pPooqTX1dPkOadOLdzBmszTihOyX/bO23up+wyV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692841; c=relaxed/simple; bh=7LFbPeFjkQq1UTJ8lEzVj85jrHSO5Ur9v/Y+l3mM/6A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CHC5PRhM4ZJONpaSfMG+fSPWXpLu//KythAR/CmAEE0ld1usy0vNQozvlVIo2xJvclnOp8G9Ca63ji1zE3cRXi2BwJzZUKAWjPdehN7sgBI5S0+QCped3rtk1rBM8AV3rYXNo00hErfAdEYeXQ4h/LU+7l9nj++eudQjdr2m2Yk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aTlvEM/I; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aTlvEM/I" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0b3d35ccfbso289728276.3 for ; Wed, 18 Sep 2024 13:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692839; x=1727297639; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8rJ/KpP7ZLjH/baI+Q4VTgii8fM80xVyJoccolaGcXA=; b=aTlvEM/I8pCaQl8i/1OmC4g4gkSXYcpZlslWxUhWtYTDfGfjGRQb1zxEyVl6KgEk+k VfTE69P1955Qkmyc/WQHANhsb8ujWKbDFrmbIBv3BKH3Wfa/2MZAe7Zx632BfbUCRCTZ or/OHZq1VxZO0cbT8PrMFjedQJqKwX4DFFZ3SKlG/ns7rj44sbv4k9nz6lnpZ0cr9Hks L41kaJeehLWKjfjGoIyZCOEHHHnZo6Acdu3xCiop+kpIzG5FdYiLIHuASpTv0p/BQbT1 Jx9F9Fi7PAw1lLP8SJA/FHwT1eABd6neOJ6qBAonXdyD9IU6+4wlJwM967qkBCIyzKjg VkIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692839; x=1727297639; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8rJ/KpP7ZLjH/baI+Q4VTgii8fM80xVyJoccolaGcXA=; b=fRNmycY+Xlvs9WO5q2wjzv4MPQAeiK9RhCo6IdTo9HJPuh7CI0qVkQlChCgqhZt8NJ n3j/wTKLL98sdfcunJS7ze1dQT0c3jBnVVVyA9eqpSXPWqNhSoNkhapqYMsvOUIFaaM2 42ZJWufPcUWvAPs0+XYbtyT4TwUXdwvBK593N+3iPApKPYSHGsAiFzqncqQv3UGyhs9D YLDm+Qm0Dds3RYcOAwZJpglJtRVOkaPLWCQ2pk/3TSmi4k8e/pZpKb08bKnFgmFPQqg0 2Sb6hweHpR+xyUv2ILmA9weokMWVFYyg/EYNAwZqUvEzjH1/9Vwc+TwRGVU35lwPT7oy cDvA== X-Forwarded-Encrypted: i=1; AJvYcCVXVSxvnhtu4iCLZfXn2EQWCtCxhdocR1IL251NIzK+nvY428e/l5+kD8nwnsCtvhz/3tgeCm6SaD48VEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwrTdRXXFTDL+bKcETbf1asCuBoA69SOy43T2DuCr9G+bZXHuQp SOPuW426fQEB+p15eCsaOjsAgnJpL5fUNKyPVY7UHSaIEMZILemcxIdGeg8272WVR6BHGxrnrWj jMhWwjnJATKWCY6hBdsI06w== X-Google-Smtp-Source: AGHT+IE19c7uHgFQDSF5lDBOr6e84MO4hTZGPdwklurCeZKa3gXSTOztaJSR5dLNDju6LDGeGsq93ws0AB9ttpRl9Q== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a25:f304:0:b0:e11:7105:956a with SMTP id 3f1490d57ef6-e1d9db9c23fmr34188276.3.1726692839006; Wed, 18 Sep 2024 13:53:59 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:14 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-2-coltonlewis@google.com> Subject: [PATCH v2 1/6] KVM: x86: selftests: Fix typos in macro variable use From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Without the leading underscore, these variables are referencing a variable in the calling scope. It only worked before by accident because all calling scopes had a variable with the right name. Fixes: cd34fd8c758e ("KVM: selftests: Test PMC virtualization with forced e= mulation") Signed-off-by: Colton Lewis --- tools/testing/selftests/kvm/x86_64/pmu_counters_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools= /testing/selftests/kvm/x86_64/pmu_counters_test.c index 698cb36989db..0e305e43a93b 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c @@ -174,7 +174,7 @@ do { \ =20 #define GUEST_TEST_EVENT(_idx, _event, _pmc, _pmc_msr, _ctrl_msr, _value, = FEP) \ do { \ - wrmsr(pmc_msr, 0); \ + wrmsr(_pmc_msr, 0); \ \ if (this_cpu_has(X86_FEATURE_CLFLUSHOPT)) \ GUEST_MEASURE_EVENT(_ctrl_msr, _value, "clflushopt .", FEP); \ @@ -331,9 +331,9 @@ __GUEST_ASSERT(expect_gp ? vector =3D=3D GP_VECTOR : !v= ector, \ expect_gp ? "#GP" : "no fault", msr, vector) \ =20 #define GUEST_ASSERT_PMC_VALUE(insn, msr, val, expected) \ - __GUEST_ASSERT(val =3D=3D expected_val, \ + __GUEST_ASSERT(val =3D=3D expected, \ "Expected " #insn "(0x%x) to yield 0x%lx, got 0x%lx", \ - msr, expected_val, val); + msr, expected, val); =20 static void guest_test_rdpmc(uint32_t rdpmc_idx, bool expect_success, uint64_t expected_val) --=20 2.46.0.662.g92d0881bb0-goog From nobody Fri Nov 29 14:50:00 2024 Received: from mail-io1-f73.google.com (mail-io1-f73.google.com [209.85.166.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B71C71CB30F for ; Wed, 18 Sep 2024 20:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692842; cv=none; b=CChNjaE412T8Z2ZzrE7JFcyS+9LUraX56pm2yfR8aHpEpIWcwye2iAEUiGL1Dwj/kBUqprK6xoicB2ZBR8Ut0ceJdQM2fU3cBeq+h3xBK6Vf04Gz5znv8eEvX1b1CSeLd8IZ7NjnGZRVi94qIudIJV9/NcWeAOcVhIzEb68oN5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692842; c=relaxed/simple; bh=JPGg+ZlqNk//a2GulWytBxkzfd4Br7410I6/OYnAg4s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UuSknLx/KGT5tFCgIBHjo82OrfVpuscw9XaWu1mQ5AIxcm2aCe3gZhpBdC2h96qPFc160eK+dFPhLWRBt8YUE5snawbya6vn2BMAuinaMmmsYRGnHRV6hyMcrQYCe2Ky0GLAXUcon545nDsFYdd8umGzYzhZA+M/L427blYW6aI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=14FFCqNg; arc=none smtp.client-ip=209.85.166.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="14FFCqNg" Received: by mail-io1-f73.google.com with SMTP id ca18e2360f4ac-82cd682f1d2so31306239f.3 for ; Wed, 18 Sep 2024 13:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692840; x=1727297640; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=J2FbusX2TPbhEhWZxjbHNZM35iEkPfYNW6xaREjlVQ0=; b=14FFCqNgqTnCkGZglX6mNKtBQP7o9Rj8pzQCC6EDRe8kqZCS4Aoe7PLGJRSb5DA7Ju zG5UgsBxoTX9qP0exYO40pYLHG3xz/Ef90J9qEsS/ZgQlG3d6ZbKU4fccLUa8EfrntaR mQ4lNdqd90+AGDM5UiFUtPwXUge4boAp9B/zA2sZNKvE/Wta3C4lgC2F4PlF8ZPAkiKR aP2ea/r2qGjREBwOKKYvn42g37xuJNkluCXZGodspzbQXUxhou55qABw0GpViapLsNa6 QsMY3ZqaE9NRQY0w2DLbSUv2HmdefYl/d6BWApsx320FDAyR6TKgMfW/PKl8AaX8J773 rCrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692840; x=1727297640; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=J2FbusX2TPbhEhWZxjbHNZM35iEkPfYNW6xaREjlVQ0=; b=Tub2mDCGtozK6ZjsqhY2sPAgf/xfsT5qVc3ok+5bmQjAowsczgfLMwCHXgms1yRakx oQRA2Of3HbodtIiou99YBqzy9kOGiBaG5OPqFIh0CnBWq0bLGw72eS6MWvNLrhUaGjIt byEdIIh0O+gRKKkIaHROjcISMo7bIjMdyZH6wghxkrQc2GDN7E0eSYFvtDKrAPg11XNm 8CADgLR/3CRfTeWitbydOfCi+j2AfavWsSBgHqDs2yioulBs18fZSOdglqwZQGNv1l3f H2bzS4B5H6epgcZ789HVKDzT4KPMTeLxEofslokOMKoQaTEzpJX7oBNis0gogt4ze+S9 ftKQ== X-Forwarded-Encrypted: i=1; AJvYcCU65hUbulJOhXEp3B0gOT2vo+9SMHlAMr6bxzFECmb4EgxsZcKqwhIMz0T9HZ9n9qJz4vyzb1h+X06reVM=@vger.kernel.org X-Gm-Message-State: AOJu0YxQgO3VMQlerPgL/uCXiAOyIDaMDrD/nIHhxV1/0pCoPWWVYIUf 3lHVXpz11uF6kPwGqMFYtbDYUC4eQlSnvDqGDh6XDFeDn2cHRezADhorqcDCoP5V1EmaFQw2rU3 KozVZ3+9CFgtRER+22cjxng== X-Google-Smtp-Source: AGHT+IEvUPVfFuL/BWdy23uUJAus9euW9RtBbSMsXFnhdcw15adjkZURp2tQfRtwVR8mu7U0IOUcvqwQaEDvYgdK9w== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:6638:3722:b0:4c0:a8a5:81f5 with SMTP id 8926c6da1cb9f-4d361346b3amr476142173.4.1726692839979; Wed, 18 Sep 2024 13:53:59 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:15 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-3-coltonlewis@google.com> Subject: [PATCH v2 2/6] KVM: x86: selftests: Define AMD PMU CPUID leaves From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This defined the CPUID calls to determine what extensions and properties are available. AMD reference manual names listed below. * PerfCtrExtCore (six core counters instead of four) * PerfCtrExtNB (four counters for northbridge events) * PerfCtrExtL2I (four counters for L2 cache events) * PerfMonV2 (support for registers to control multiple counters with a single register write) * LbrAndPmcFreeze (support for freezing last branch recorded stack on performance counter overflow) * NumPerfCtrCore (number of core counters) * NumPerfCtrNB (number of northbridge counters) Signed-off-by: Colton Lewis --- tools/testing/selftests/kvm/include/x86_64/processor.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools= /testing/selftests/kvm/include/x86_64/processor.h index a0c1440017bb..44ddfc4c1673 100644 --- a/tools/testing/selftests/kvm/include/x86_64/processor.h +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h @@ -183,6 +183,9 @@ struct kvm_x86_cpu_feature { #define X86_FEATURE_GBPAGES KVM_X86_CPU_FEATURE(0x80000001, 0, EDX, 26) #define X86_FEATURE_RDTSCP KVM_X86_CPU_FEATURE(0x80000001, 0, EDX, 27) #define X86_FEATURE_LM KVM_X86_CPU_FEATURE(0x80000001, 0, EDX, 29) +#define X86_FEATURE_PERF_CTR_EXT_CORE KVM_X86_CPU_FEATURE(0x80000001, 0, E= CX, 23) +#define X86_FEATURE_PERF_CTR_EXT_NB KVM_X86_CPU_FEATURE(0x80000001, 0, ECX= , 24) +#define X86_FEATURE_PERF_CTR_EXT_L2I KVM_X86_CPU_FEATURE(0x80000001, 0, EC= X, 28) #define X86_FEATURE_INVTSC KVM_X86_CPU_FEATURE(0x80000007, 0, EDX, 8) #define X86_FEATURE_RDPRU KVM_X86_CPU_FEATURE(0x80000008, 0, EBX, 4) #define X86_FEATURE_AMD_IBPB KVM_X86_CPU_FEATURE(0x80000008, 0, EBX, 12) @@ -195,6 +198,8 @@ struct kvm_x86_cpu_feature { #define X86_FEATURE_VGIF KVM_X86_CPU_FEATURE(0x8000000A, 0, EDX, 16) #define X86_FEATURE_SEV KVM_X86_CPU_FEATURE(0x8000001F, 0, EAX, 1) #define X86_FEATURE_SEV_ES KVM_X86_CPU_FEATURE(0x8000001F, 0, EAX, 3) +#define X86_FEATURE_PERFMON_V2 KVM_X86_CPU_FEATURE(0x80000022, 0, EAX, 0) +#define X86_FEATURE_PERF_LBR_PMC_FREEZE KVM_X86_CPU_FEATURE(0x80000022, 0,= EAX, 2) =20 /* * KVM defined paravirt features. @@ -281,6 +286,8 @@ struct kvm_x86_cpu_property { #define X86_PROPERTY_GUEST_MAX_PHY_ADDR KVM_X86_CPU_PROPERTY(0x80000008, = 0, EAX, 16, 23) #define X86_PROPERTY_SEV_C_BIT KVM_X86_CPU_PROPERTY(0x8000001F, 0, EBX, = 0, 5) #define X86_PROPERTY_PHYS_ADDR_REDUCTION KVM_X86_CPU_PROPERTY(0x8000001F, = 0, EBX, 6, 11) +#define X86_PROPERTY_NUM_PERF_CTR_CORE KVM_X86_CPU_PROPERTY(0x80000022, 0= , EBX, 0, 3) +#define X86_PROPERTY_NUM_PERF_CTR_NB KVM_X86_CPU_PROPERTY(0x80000022, 0, = EBX, 10, 15) =20 #define X86_PROPERTY_MAX_CENTAUR_LEAF KVM_X86_CPU_PROPERTY(0xC0000000, 0,= EAX, 0, 31) =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Fri Nov 29 14:50:00 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F19FF1CB336 for ; Wed, 18 Sep 2024 20:54:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692843; cv=none; b=Ouoin+zO1FN5p+2TlXQxx3bipGt+eZlmWXeP6XfS400kyY5+JFzc9iOXu3IKRkitckIuQz6hbzPTPyMb9xyl0X3iI635qGPBBjl0aOicFSsx2qI67QvF/G8BZrXI9pa7tClsXkWmEVYD0EThwCjbdaojZiLF+l5aS9fDKMYJPqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692843; c=relaxed/simple; bh=p6MzaJUynW/JjkmeZKB5mW65nL3/Igk6OCMaHic7+aw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EGES8E+bN96GkGj29b2dE/E9bGdcHnTSMGoKBpd8+YV45WemG0lS2yO/P61L+/8R4GXQYftVO7nV1mBLHkSBVQHoYzUU2TrvGm5xUUbfyh1cy5aXzflHWDelWw2IxBDjRluBO90fPkCJ+th2W4YcTeZMyt9w6eIWs3LhF8+2l9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SxvwbFWt; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SxvwbFWt" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ddcf7599ddso2271667b3.1 for ; Wed, 18 Sep 2024 13:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692841; x=1727297641; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YwPgtOW129JrsQoACWdjEIl4s6WZlvFOhv3Du6OF+8U=; b=SxvwbFWtq/Snn8Opm0acT0QfMfIdgN1dq0W8sk1O7KOrYEPCwyEkmuiW1kTIvWw/Jp IMRiq8DB8T6ptwGLcouwfxB7Pm1aAMVjXQ4bR6RUOt355LAGotp0yGzwhpg0vup8qAa+ gglnsrl+GV7uDLG3i6+pq0MB1HZJt5DueTbO1QL9oW9EX4v/f8TTd3wR0efUPv2je4H+ ioinA2e/al6rHbRaVJ+A2HW3zD0JUCLioD/CD6B+ngTJeQLJaEBakg8Dpg/aBVPK5INy /tpcIfym8tvprxLN9qXEld4aQPprCAf38yxdCp69+C3878R0NSsAEnqQfmIMjShKV3eu 7RQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692841; x=1727297641; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YwPgtOW129JrsQoACWdjEIl4s6WZlvFOhv3Du6OF+8U=; b=OYxwi4wIHdRPzUBzxcP3q8XCtaN7qd44iwC4u16FSb3fJwZo3nRJUmiKwYfbV5kjCf 2V/++IOE4WyNUgjE3JOpMAkJX1SYSQ65VSKhffDgAzV0TeQE07WWYfsADSTGaEtSENO2 hqGijLzGCeVZ2/KHlm5U9vjujmXpp+5Cx5bVjMDQE1dthxzd5GrZllzl0eaZruJ9ks4d WK6efRk9WLYUwIS4HfrAP/ynIlddDv9Dc3AxWb9WIz3JnD9VjD5kkft6vPrhSQPpQ0aP l1miNBnylNswT7i66AXaK1n80GB/Ecgw1aLD9pVnlUQb1N0ko3GcylGAKMhMfqKGsjth c8tA== X-Forwarded-Encrypted: i=1; AJvYcCUijC/BKST/kvIJ7IQwoHcAYNwIVmEIeCwARhQfrvBRGclRJSaiZYWWk755XP0IXinjByYWOsoTCZsO72o=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6rqatbbA3P/ASp41VDdLZF14hCid3KIVcPF0iohTePuReS9gz TEY4M9LOtSs0R+055LB8o7CNqUkzJrqIPpcji0ROvWjOHEVSyJFMf9xD/1G0xBVbIIz+jp3UvLV cbhmFtckZ7wU7iVK9uDcVAA== X-Google-Smtp-Source: AGHT+IGRPIBH0lJ/zYqTw1ktDVZvUIdvA2LFZQYoQbGDgG/n34gqx1ZHStAZ7pNzlmKV4Cl93mXbQJCAfZuocHz/Dw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a81:cb07:0:b0:6db:e107:74cb with SMTP id 00721157ae682-6dbe1077640mr6957727b3.3.1726692840998; Wed, 18 Sep 2024 13:54:00 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:16 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-4-coltonlewis@google.com> Subject: [PATCH v2 3/6] KVM: x86: selftests: Set up AMD VM in pmu_counters_test From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Branch in main() depending on if the CPU is Intel or AMD. They are subject to vastly different requirements because the AMD PMU lacks many properties defined by the Intel PMU including the entire CPUID 0xa function where Intel stores all the PMU properties. AMD lacks this as well as any consistent notion of PMU versions as Intel does. Every feature is a separate flag and they aren't the same features as Intel. Set up a VM for testing core AMD counters and ensure proper CPUID features are set. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 104 ++++++++++++++---- 1 file changed, 83 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools= /testing/selftests/kvm/x86_64/pmu_counters_test.c index 0e305e43a93b..5b240585edc5 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c @@ -30,10 +30,21 @@ #define NUM_INSNS_RETIRED (NUM_LOOPS * NUM_INSNS_PER_LOOP + NUM_EXTRA_INS= NS) =20 =20 +/* + * Limit testing to MSRs that are actually defined by Intel (in the SDM). = MSRs + * that aren't defined counter MSRs *probably* don't exist, but there's no + * guarantee that currently undefined MSR indices won't be used for someth= ing + * other than PMCs in the future. + */ +#define MAX_NR_GP_COUNTERS 8 +#define MAX_NR_FIXED_COUNTERS 3 +#define AMD_NR_CORE_COUNTERS 4 +#define AMD_NR_CORE_EXT_COUNTERS 6 + static uint8_t kvm_pmu_version; static bool kvm_has_perf_caps; =20 -static struct kvm_vm *pmu_vm_create_with_one_vcpu(struct kvm_vcpu **vcpu, +static struct kvm_vm *intel_pmu_vm_create(struct kvm_vcpu **vcpu, void *guest_code, uint8_t pmu_version, uint64_t perf_capabilities) @@ -303,7 +314,7 @@ static void test_arch_events(uint8_t pmu_version, uint6= 4_t perf_capabilities, if (!pmu_version) return; =20 - vm =3D pmu_vm_create_with_one_vcpu(&vcpu, guest_test_arch_events, + vm =3D intel_pmu_vm_create(&vcpu, guest_test_arch_events, pmu_version, perf_capabilities); =20 vcpu_set_cpuid_property(vcpu, X86_PROPERTY_PMU_EBX_BIT_VECTOR_LENGTH, @@ -316,15 +327,6 @@ static void test_arch_events(uint8_t pmu_version, uint= 64_t perf_capabilities, kvm_vm_free(vm); } =20 -/* - * Limit testing to MSRs that are actually defined by Intel (in the SDM). = MSRs - * that aren't defined counter MSRs *probably* don't exist, but there's no - * guarantee that currently undefined MSR indices won't be used for someth= ing - * other than PMCs in the future. - */ -#define MAX_NR_GP_COUNTERS 8 -#define MAX_NR_FIXED_COUNTERS 3 - #define GUEST_ASSERT_PMC_MSR_ACCESS(insn, msr, expect_gp, vector) \ __GUEST_ASSERT(expect_gp ? vector =3D=3D GP_VECTOR : !vector, \ "Expected %s on " #insn "(0x%x), got vector %u", \ @@ -463,7 +465,7 @@ static void test_gp_counters(uint8_t pmu_version, uint6= 4_t perf_capabilities, struct kvm_vcpu *vcpu; struct kvm_vm *vm; =20 - vm =3D pmu_vm_create_with_one_vcpu(&vcpu, guest_test_gp_counters, + vm =3D intel_pmu_vm_create(&vcpu, guest_test_gp_counters, pmu_version, perf_capabilities); =20 vcpu_set_cpuid_property(vcpu, X86_PROPERTY_PMU_NR_GP_COUNTERS, @@ -530,7 +532,7 @@ static void test_fixed_counters(uint8_t pmu_version, ui= nt64_t perf_capabilities, struct kvm_vcpu *vcpu; struct kvm_vm *vm; =20 - vm =3D pmu_vm_create_with_one_vcpu(&vcpu, guest_test_fixed_counters, + vm =3D intel_pmu_vm_create(&vcpu, guest_test_fixed_counters, pmu_version, perf_capabilities); =20 vcpu_set_cpuid_property(vcpu, X86_PROPERTY_PMU_FIXED_COUNTERS_BITMASK, @@ -627,18 +629,78 @@ static void test_intel_counters(void) } } =20 -int main(int argc, char *argv[]) +static uint8_t nr_core_counters(void) { - TEST_REQUIRE(kvm_is_pmu_enabled()); + uint8_t nr_counters =3D kvm_cpu_property(X86_PROPERTY_NUM_PERF_CTR_CORE); + bool core_ext =3D kvm_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + + if (nr_counters !=3D 0) + return nr_counters; + + if (core_ext) + return AMD_NR_CORE_EXT_COUNTERS; =20 - TEST_REQUIRE(host_cpu_is_intel); - TEST_REQUIRE(kvm_cpu_has_p(X86_PROPERTY_PMU_VERSION)); - TEST_REQUIRE(kvm_cpu_property(X86_PROPERTY_PMU_VERSION) > 0); + return AMD_NR_CORE_COUNTERS; =20 - kvm_pmu_version =3D kvm_cpu_property(X86_PROPERTY_PMU_VERSION); - kvm_has_perf_caps =3D kvm_cpu_has(X86_FEATURE_PDCM); +} + +static void guest_test_core_counters(void) +{ + GUEST_DONE(); +} + +static void test_core_counters(void) +{ + uint8_t nr_counters =3D nr_core_counters(); + bool core_ext =3D kvm_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + bool perfmon_v2 =3D kvm_cpu_has(X86_FEATURE_PERFMON_V2); + struct kvm_vcpu *vcpu; + struct kvm_vm *vm; + + for (uint8_t ce =3D 0; ce <=3D core_ext; ce++) { + for (uint8_t pm =3D 0; pm <=3D perfmon_v2; pm++) { + for (uint8_t nc =3D 0; nc <=3D nr_counters; nc++) { + vm =3D vm_create_with_one_vcpu(&vcpu, guest_test_core_counters); + + if (nc) + vcpu_set_cpuid_property( + vcpu, X86_PROPERTY_NUM_PERF_CTR_CORE, nc); + if (ce) + vcpu_set_cpuid_feature( + vcpu, X86_FEATURE_PERF_CTR_EXT_CORE); + if (pm) + vcpu_set_cpuid_feature( + vcpu, X86_FEATURE_PERFMON_V2); + + pr_info("Testing core counters: CoreExt =3D %u, PerfMonV2 =3D %u, NumC= ounters =3D %u\n", + ce, pm, nc); + run_vcpu(vcpu); + + kvm_vm_free(vm); + } + } + } +} + +static void test_amd_counters(void) +{ + test_core_counters(); +} =20 - test_intel_counters(); +int main(int argc, char *argv[]) +{ + TEST_REQUIRE(kvm_is_pmu_enabled()); + + if (host_cpu_is_intel) { + TEST_REQUIRE(kvm_cpu_has_p(X86_PROPERTY_PMU_VERSION)); + TEST_REQUIRE(kvm_cpu_property(X86_PROPERTY_PMU_VERSION) > 0); + kvm_pmu_version =3D kvm_cpu_property(X86_PROPERTY_PMU_VERSION); + kvm_has_perf_caps =3D kvm_cpu_has(X86_FEATURE_PDCM); + test_intel_counters(); + } else if (host_cpu_is_amd) { + /* AMD CPUs don't have the same properties to look at. */ + test_amd_counters(); + } =20 return 0; } --=20 2.46.0.662.g92d0881bb0-goog From nobody Fri Nov 29 14:50:00 2024 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17B881CB52A for ; Wed, 18 Sep 2024 20:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692844; cv=none; b=G4F28MiKgphK0VrjG1pJK2O2Xlz6VE1VqY6k4Y+EHNPKzTOz1xciGvOvVtd3NgRrmU709m66zjJ1ZiBLDj5ekCwet/JFN72PcJFAmD6pZaQW/qLdx8hYzDvT5jBepvrY1YylUuNts74ZGMd3sRHUc0HvCEtN+gwWchAww1C3hU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692844; c=relaxed/simple; bh=aSdFYlUtz6P5Eo1j6ju7Ac/ao+lpyvnXe6lnLzmL3WA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Gxc9nvbrs9VLzDt/qDhmZPR2we0hBYIM4n4eEkv/JD5ZFPgAQqTwkhgpaEqeHLKjAj/oiEZQUhSfaOlWF5QI4VIEKJwJyHS38Lc5y3YBzPVPTSJwfq4k6uHH9QR82h40GlaRCYzzZ/nmu7OirbzDrFYDxBjqX16g1396wL9/sbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cfbogPtS; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cfbogPtS" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e1dc0585fbfso291998276.3 for ; Wed, 18 Sep 2024 13:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692842; x=1727297642; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OkrE8WmvzpBAiiKTV2LkBvEEkr6B/d2pJWlGO3Ml/wo=; b=cfbogPtSj8ie6NDwzOBjkw9KUvVueBVQFtgEXEPTJ+ZK3iic5Mlg8KrD8udtheKggD OOpHHBYUPzlUD3pyA68SwubY74nrvzHj4eWW4ywCKRHNax4ACrRs4GTtlVenEgx3pbVP 1D9YLCV1w6wk7FpnI+5G9++9cXC4wPp06Ih880t2hPJiuG8dOmErdchgWtsQ5z7jGaGs fYXPhcoV8UxMeYORpNdcxMrcGXd+3olnZWNMJ5HQa1e6ArbT1Rs1rOGy5vWcaHWc8n4C Yf+Tgon+Qbncf/MpxDUQrnx0eekfRSZ0YDf05kaLWhcTb8EZPpejr0RyjW6g9YhuSyyv 72Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692842; x=1727297642; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OkrE8WmvzpBAiiKTV2LkBvEEkr6B/d2pJWlGO3Ml/wo=; b=WdAIwYBRIcwaHQ0la4MSvR6KmOyQcgKucztW0ljUNZ7iipdA8/CL7UKOt/Jn0mZteb nbi8McSS4DK9NPTj7clLkaFqP0WCC3Xe7fscjoSvyvOH76cr51deJorYOCAWRwm9qwWQ wbk8+aOmtvJjrkZnpmpHLOJirTeQSddHpxWeLNKc4I1RWAtwOM6EyI9GU9XY2ea1cvA1 Jn/59YGlFaVfIE9alKQXBiO+m4jMx1cL5ou+/66NHcJV9/NyO91MkIrfMqpaZ2uQIx8q qRQ7XJtyvqKQRAm7M0lz61GDZSOH+60cpBHpYaAMNadICsyo3RoHKB2WXiNfCqirQPRk ShPg== X-Forwarded-Encrypted: i=1; AJvYcCUW/NZDk0zjh+O+gI21bIpuyD89rKBHKzY+3x0ddtLLpabCvmEuRjwNHOlmQNInAMlCCMzzadm0uZNHCCc=@vger.kernel.org X-Gm-Message-State: AOJu0YzOe+zkax3Uv0z3IWbp3i2AbeaDf8OQjEz9adHHhHzmvE+mz/kF knUCYhTDVZ6vHmRGrCAXdLIhoknP/yQ8SIXMe/XglwKq4trSQyG/GSe5qtSbLwEx5eeoHOU4gSt iPsxrWzPO/opO3KlpgDU3XA== X-Google-Smtp-Source: AGHT+IGglH1MwiuQb6nf3SblZvhLMFNMZKCm/U6KRL3GGVpCYBWH8kXimB5ATPz5Ij0DZlhI64+AMN+To08XeyX1Gw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a25:a1a3:0:b0:e1a:6bf9:aa83 with SMTP id 3f1490d57ef6-e1d9db9e12fmr70673276.3.1726692842109; Wed, 18 Sep 2024 13:54:02 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:17 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-5-coltonlewis@google.com> Subject: [PATCH v2 4/6] KVM: x86: selftests: Test read/write core counters From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Run a basic test to ensure we can write an arbitrary value to the core counters and read it back. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools= /testing/selftests/kvm/x86_64/pmu_counters_test.c index 5b240585edc5..79ca7d608e00 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c @@ -641,11 +641,65 @@ static uint8_t nr_core_counters(void) return AMD_NR_CORE_EXT_COUNTERS; =20 return AMD_NR_CORE_COUNTERS; +} + +static uint8_t guest_nr_core_counters(void) +{ + uint8_t nr_counters =3D this_cpu_property(X86_PROPERTY_NUM_PERF_CTR_CORE); + bool core_ext =3D this_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + + if (nr_counters !=3D 0) + return nr_counters; + + if (core_ext) + return AMD_NR_CORE_EXT_COUNTERS; + + return AMD_NR_CORE_COUNTERS; + +} =20 +static void guest_test_rdwr_core_counters(void) +{ + bool core_ext =3D this_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + uint8_t nr_counters =3D guest_nr_core_counters(); + uint8_t i; + uint32_t esel_msr_base =3D core_ext ? MSR_F15H_PERF_CTL : MSR_K7_EVNTSEL0; + uint32_t cnt_msr_base =3D core_ext ? MSR_F15H_PERF_CTR : MSR_K7_PERFCTR0; + uint32_t msr_step =3D core_ext ? 2 : 1; + + for (i =3D 0; i < AMD_NR_CORE_EXT_COUNTERS; i++) { + uint64_t test_val =3D 0xffff; + uint32_t esel_msr =3D esel_msr_base + msr_step * i; + uint32_t cnt_msr =3D cnt_msr_base + msr_step * i; + bool expect_gp =3D !(i < nr_counters); + uint8_t vector; + uint64_t val; + + /* Test event selection register. */ + vector =3D wrmsr_safe(esel_msr, test_val); + GUEST_ASSERT_PMC_MSR_ACCESS(WRMSR, esel_msr, expect_gp, vector); + + vector =3D rdmsr_safe(esel_msr, &val); + GUEST_ASSERT_PMC_MSR_ACCESS(RDMSR, esel_msr, expect_gp, vector); + + if (!expect_gp) + GUEST_ASSERT_PMC_VALUE(RDMSR, esel_msr, val, test_val); + + /* Test counter register. */ + vector =3D wrmsr_safe(cnt_msr, test_val); + GUEST_ASSERT_PMC_MSR_ACCESS(WRMSR, cnt_msr, expect_gp, vector); + + vector =3D rdmsr_safe(cnt_msr, &val); + GUEST_ASSERT_PMC_MSR_ACCESS(RDMSR, cnt_msr, expect_gp, vector); + + if (!expect_gp) + GUEST_ASSERT_PMC_VALUE(RDMSR, cnt_msr, val, test_val); + } } =20 static void guest_test_core_counters(void) { + guest_test_rdwr_core_counters(); GUEST_DONE(); } =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Fri Nov 29 14:50:00 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D6351CBE9C for ; Wed, 18 Sep 2024 20:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692846; cv=none; b=MvzgUju5zbwqe/7pOyIi4OGWBPh+n997aYkbFUSClfziOPLDpsF2eA06c9imd1lDIbAJwInFTmBSzsKnHNp51tiRP3jBmIeCklAjBppNPGmgJbtCbpxPQc8vDRzSi93H3Aa+ISRTkD/BTcK4KLa32+fBQ6+pDPjibBddkGBtsbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692846; c=relaxed/simple; bh=EhE7fT+kvYR1Q8z0VYUdV57MUeryDUN91qCH81aB3uA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Vy+D72Qt2TFyZJXiymHYWPN1ihDYBRCdEgjPigDJ5jgrJiuL80Y1l/pfo/K9Zp8SQaYv4+6ipoGnANfTOKKQpShbg1fm7rlqYANJ7M/nmR2vwTY3Ne/Bl9NxokKZNd6Wz4JjNm59N7NOmREYKZLarALIknmXPVad1X7czRndxlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xUY/Koia; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xUY/Koia" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e1aa529e30eso334560276.1 for ; Wed, 18 Sep 2024 13:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692843; x=1727297643; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5LjPPMrNjWPhkrbIBVeS2QTzariP8KiUDD2AXY1srT0=; b=xUY/KoiaYu1WcZptKlHhPCDe7aKzCN5E3fMjLVG5KMSw5yU0uyrfnd1r6+7mPKSRUd cHIj7jYWihdLEOg2kifSO7zYS5jfaYWXAIEx/oLEJ2I0xDcqRUaOHkA2NvSdNy4dw7Kd 6Kd35x+uyfDNtGWA0/G+E3NCx+qbxFJGxjtt9LAqShBsPdyAKhYkS/tyJcO4+hQFtqQl h6F37R+fnMn/hZYP45RyHFEqPwZh4cky3hGtcheJZLTvtH6JJjGKPp4SfN5J3GyUU758 5QztmkgSiLCDX8gpSaRDiJDC6clfYnaQmNVxmNhKTSvQzaPqT5Tx2EFMzfdQ364n72Mt 0MkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692843; x=1727297643; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5LjPPMrNjWPhkrbIBVeS2QTzariP8KiUDD2AXY1srT0=; b=FbykHOFtBXnLYjmDqApa+K2yEtrnfgUVsP/fF+BFGwIpOVxjHYdLa9i+qXY1TuPWzq frDp4ZYtjxGZkNIAbkzMvyzzVn6jmy73aje70FYC4O7qoua+MKmS5/haj0h9VCylS6gI xoADHmyjKREf+Q2OGn5NJQUW5v9wl3UWuwcN1yicESkuIdfmwzF5Rggc4F2WmsOHbFSl oODo/0S0wUceta6kQffOITtkkxQnBbJXGCQXIEsJjKzR6aRNfqhbGqXbkjhYiEtKfpQp z1hiOdSNMQ46tWaGyZzJfsYa6pnOqv/4SVR7g5/TUWxbTaJlv3SkIhSp3e/lew5H+TnL HYGQ== X-Forwarded-Encrypted: i=1; AJvYcCUFyuoCOewEkRpsnyRwsulIgXqflzhl78bGJgISR1PBszdJ7kjUzH9HHLu1Yvw+RVXybXhsWixKSEoCkK0=@vger.kernel.org X-Gm-Message-State: AOJu0YxNHvQbQDJlVs9uWWR9xbva1fNnXjdch/dEXrvOI6USGqK8OjnE 7qiroBn4M2NeLTmjDXyaQ95CSETrGqSUsjOCQInEMC4C1daKUc9rfDeSj89xRQsSQycxA7lefyB K3wYJ6lEHj7Kru20kXfXrkQ== X-Google-Smtp-Source: AGHT+IFsuKcr5FzVL+z7aQg1GQc1dsi2r2Svsejd/GzBtLLxOhu7F6DPwsXM3Vd9fngcGMgwH7awUkawVaVTnLnOpw== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a25:3602:0:b0:e1d:2043:da46 with SMTP id 3f1490d57ef6-e1daff6d90bmr44632276.3.1726692843155; Wed, 18 Sep 2024 13:54:03 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:18 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-6-coltonlewis@google.com> Subject: [PATCH v2 5/6] KVM: x86: selftests: Test core events From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Test events on core counters by iterating through every combination of events in amd_pmu_zen_events with every core counter. For each combination, calculate the appropriate register addresses for the event selection/control register and the counter register. The base addresses and layout schemes change depending on whether we have the CoreExt feature. To do the testing, reuse GUEST_TEST_EVENT to run a standard known workload. Decouple it from guest_assert_event_count (now guest_assert_intel_event_count) to generalize to AMD. Then assert the most specific detail that can be reasonably known about the counter result. Exact count is defined and known for some events and for other events merely asserted to be nonzero. Note on exact counts: AMD counts one more branch than Intel for the same workload. Though I can't confirm a reason, the only thing it could be is the boundary of the loop instruction being counted differently. Presumably, when the counter reaches 0 and execution continues to the next instruction, AMD counts this as a branch and Intel doesn't. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 87 ++++++++++++++++--- 1 file changed, 77 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools= /testing/selftests/kvm/x86_64/pmu_counters_test.c index 79ca7d608e00..cf2941cc7c4c 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c @@ -29,6 +29,9 @@ /* Total number of instructions retired within the measured section. */ #define NUM_INSNS_RETIRED (NUM_LOOPS * NUM_INSNS_PER_LOOP + NUM_EXTRA_INS= NS) =20 +/* AMD counting one extra branch. Probably at loop boundary condition. */ +#define NUM_BRANCH_INSNS_RETIRED_AMD (NUM_LOOPS+1) +#define NUM_INSNS_RETIRED_AMD (NUM_INSNS_RETIRED+1) =20 /* * Limit testing to MSRs that are actually defined by Intel (in the SDM). = MSRs @@ -109,7 +112,7 @@ static uint8_t guest_get_pmu_version(void) * Sanity check that in all cases, the event doesn't count when it's disab= led, * and that KVM correctly emulates the write of an arbitrary value. */ -static void guest_assert_event_count(uint8_t idx, +static void guest_assert_intel_event_count(uint8_t idx, struct kvm_x86_pmu_feature event, uint32_t pmc, uint32_t pmc_msr) { @@ -151,6 +154,33 @@ static void guest_assert_event_count(uint8_t idx, GUEST_ASSERT_EQ(_rdpmc(pmc), 0xdead); } =20 +static void guest_assert_amd_event_count(uint8_t evt_idx, uint8_t cnt_idx,= uint32_t pmc_msr) +{ + uint64_t count; + uint64_t count_pmc; + + count =3D rdmsr(pmc_msr); + count_pmc =3D _rdpmc(cnt_idx); + GUEST_ASSERT_EQ(count, count_pmc); + + switch (evt_idx) { + case AMD_ZEN_CORE_CYCLES_INDEX: + GUEST_ASSERT_NE(count, 0); + break; + case AMD_ZEN_INSTRUCTIONS_INDEX: + GUEST_ASSERT_EQ(count, NUM_INSNS_RETIRED_AMD); + break; + case AMD_ZEN_BRANCHES_INDEX: + GUEST_ASSERT_EQ(count, NUM_BRANCH_INSNS_RETIRED_AMD); + break; + case AMD_ZEN_BRANCH_MISSES_INDEX: + GUEST_ASSERT_NE(count, 0); + break; + default: + break; + } + +} /* * Enable and disable the PMC in a monolithic asm blob to ensure that the * compiler can't insert _any_ code into the measured sequence. Note, ECX @@ -183,28 +213,29 @@ do { \ ); \ } while (0) =20 -#define GUEST_TEST_EVENT(_idx, _event, _pmc, _pmc_msr, _ctrl_msr, _value, = FEP) \ +#define GUEST_TEST_EVENT(_pmc_msr, _ctrl_msr, _ctrl_value, FEP) \ do { \ wrmsr(_pmc_msr, 0); \ \ if (this_cpu_has(X86_FEATURE_CLFLUSHOPT)) \ - GUEST_MEASURE_EVENT(_ctrl_msr, _value, "clflushopt .", FEP); \ + GUEST_MEASURE_EVENT(_ctrl_msr, _ctrl_value, "clflushopt .", FEP); \ else if (this_cpu_has(X86_FEATURE_CLFLUSH)) \ - GUEST_MEASURE_EVENT(_ctrl_msr, _value, "clflush .", FEP); \ + GUEST_MEASURE_EVENT(_ctrl_msr, _ctrl_value, "clflush .", FEP); \ else \ - GUEST_MEASURE_EVENT(_ctrl_msr, _value, "nop", FEP); \ - \ - guest_assert_event_count(_idx, _event, _pmc, _pmc_msr); \ + GUEST_MEASURE_EVENT(_ctrl_msr, _ctrl_value, "nop", FEP); \ } while (0) =20 static void __guest_test_arch_event(uint8_t idx, struct kvm_x86_pmu_featur= e event, uint32_t pmc, uint32_t pmc_msr, uint32_t ctrl_msr, uint64_t ctrl_msr_value) { - GUEST_TEST_EVENT(idx, event, pmc, pmc_msr, ctrl_msr, ctrl_msr_value, ""); + GUEST_TEST_EVENT(pmc_msr, ctrl_msr, ctrl_msr_value, ""); + guest_assert_intel_event_count(idx, event, pmc, pmc_msr); =20 - if (is_forced_emulation_enabled) - GUEST_TEST_EVENT(idx, event, pmc, pmc_msr, ctrl_msr, ctrl_msr_value, KVM= _FEP); + if (is_forced_emulation_enabled) { + GUEST_TEST_EVENT(pmc_msr, ctrl_msr, ctrl_msr_value, KVM_FEP); + guest_assert_intel_event_count(idx, event, pmc, pmc_msr); + } } =20 #define X86_PMU_FEATURE_NULL \ @@ -697,9 +728,45 @@ static void guest_test_rdwr_core_counters(void) } } =20 +static void __guest_test_core_event(uint8_t event_idx, uint8_t counter_idx) +{ + /* One fortunate area of actual compatibility! This register + * layout is the same for both AMD and Intel. + */ + uint64_t eventsel =3D ARCH_PERFMON_EVENTSEL_OS | + ARCH_PERFMON_EVENTSEL_ENABLE | + amd_pmu_zen_events[event_idx]; + bool core_ext =3D this_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + uint64_t esel_msr_base =3D core_ext ? MSR_F15H_PERF_CTL : MSR_K7_EVNTSEL0; + uint64_t cnt_msr_base =3D core_ext ? MSR_F15H_PERF_CTR : MSR_K7_PERFCTR0; + uint64_t msr_step =3D core_ext ? 2 : 1; + uint64_t esel_msr =3D esel_msr_base + msr_step * counter_idx; + uint64_t cnt_msr =3D cnt_msr_base + msr_step * counter_idx; + + GUEST_TEST_EVENT(cnt_msr, esel_msr, eventsel, ""); + guest_assert_amd_event_count(event_idx, counter_idx, cnt_msr); + + if (is_forced_emulation_enabled) { + GUEST_TEST_EVENT(cnt_msr, esel_msr, eventsel, KVM_FEP); + guest_assert_amd_event_count(event_idx, counter_idx, cnt_msr); + } + +} + +static void guest_test_core_events(void) +{ + uint8_t nr_counters =3D guest_nr_core_counters(); + + for (uint8_t i =3D 0; i < NR_AMD_ZEN_EVENTS; i++) { + for (uint8_t j =3D 0; j < nr_counters; j++) + __guest_test_core_event(i, j); + } +} + static void guest_test_core_counters(void) { guest_test_rdwr_core_counters(); + guest_test_core_events(); GUEST_DONE(); } =20 --=20 2.46.0.662.g92d0881bb0-goog From nobody Fri Nov 29 14:50:00 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 375211CBEBE for ; Wed, 18 Sep 2024 20:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692847; cv=none; b=qOHMvcrhF3kj+qm8ER1DwgEI1DbOsvr4RnVTR4FO/IadonopIX6bgXRbKn3BuO0WIRrbqwKcp4d0icMVGLXoUeGAUKOBJH1HdMtmniLVLdfw5QFxHzn8GWMyUp+PgmUqTfy9F6H6P4BllPuqn7hnZXvxMII7vnLqpgVVEXO4EYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726692847; c=relaxed/simple; bh=7lftzIKbcSxucYuctQDN98Dpt0HaKLFwYLG6pvMyEYc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Pu2NVPiLBis1DdwHc1tZOc1xp66u6vSfOOoytW7V342xkGPjknswb3x+bmr0xY4TD27Gi+1bsaTcoJ66FUhm5EwVqlKUhIYGhpaJxob525XR8DhgXwk3i19jnFIAQdt56+3AzYebfFP3gK1wjuUTXlpuu+W8TQh5hIX3wJKMH6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Vmb96NJW; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Vmb96NJW" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6d4bd76f5a8so2706397b3.0 for ; Wed, 18 Sep 2024 13:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726692844; x=1727297644; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xwbRHlJWsXfETUkB7lf/JUuYpXn+WfUYF/WjjWZw/9E=; b=Vmb96NJW5wZdL9uMiXA/Cb2yRpQB8RJCheTLsaNwk1ZC5zpnPax5BnGTjKuEvBO4rU Vu7p2R2jYuLJMYAsa6w75a1wozyW4EYkTtp8wpzgMzaONqA2sQMkY21ILINc4clk1rZK UrqU8pKo6poNv8VZTg7d42ocaXgO/2icDV486FuzgJQpD023K/JOZ4ngVE6pOkjaR9dL kGshk7IoZU6J9iw5qF8CSkWmRZbz3Nq7seSYW6jUm4CS86oldsaJZdxtnVpArWR+1aC4 Tq+aizud0H67xRYF5+ztgAb9tBuKaxkWMRCj4mDxiFLLpNwftileGdEsOixNXsva/H/o V6Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726692844; x=1727297644; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xwbRHlJWsXfETUkB7lf/JUuYpXn+WfUYF/WjjWZw/9E=; b=dsNFq/p66PetpSr/ImMZHBkfmfwDI7Y2T/fcSj0MuXoQzshFACcG4Xd56sxYvlf/0B kpQLBms0AJIrNhI8YM0nkDvGn5MJ8I59S2U3TjKaAsAvO3ZzAxLUSFHuc47xCEnpk19Y i66duT7sMfrJvUIuOk19FL1rvckHX55keLeC5V7owbj1PvOI3aEfG7t2BLgZ69L0jEq6 lHOBdSfytN2/0lpkYMUjbni7beaAuyzttq6AOVys+wZoyxcyyytCT5DszpQ1xOIBgcU2 WRF9pDdLM+dq2fXd3XtWFbYMPh2mfLZ8mOwTvbTzNYE6/CUOpKVesY0abpesl25PTEd9 aGdA== X-Forwarded-Encrypted: i=1; AJvYcCUMsGojZffUGEOIZjmoEQHOKpdTnfzan5ZeLIHm569NcFuJ85oDFjOrnzHs5LDBfhU7MmRaGlJ5cF+jUuA=@vger.kernel.org X-Gm-Message-State: AOJu0YwRo3gBde/mYudbi/ImlKlhLAzyvtY+lf0dQ/4n+n7XI6s9Q6Lz aMqznrlfxXTRY/zvZMoAjOCMxZgiGpXaHKP1rQKhOEdHE6kjFKnwDqXKRC5qW5iOBm6YwgJ56OE LOZDCMkBFmdVSJMZtP7vdVA== X-Google-Smtp-Source: AGHT+IGX71Bs4ynlMO6RpldIhTDezO4HT10BKhTJLPvF7++iCSxwIHxzTRlwd8WiZLUT1Ztu62GuXvgr+RyuJZjJbA== X-Received: from coltonlewis-kvm.c.googlers.com ([fda3:e722:ac3:cc00:11b:3898:ac11:fa18]) (user=coltonlewis job=sendgmr) by 2002:a05:690c:46c9:b0:6db:c6ac:62a0 with SMTP id 00721157ae682-6dbc6ac6618mr13380607b3.5.1726692844213; Wed, 18 Sep 2024 13:54:04 -0700 (PDT) Date: Wed, 18 Sep 2024 20:53:19 +0000 In-Reply-To: <20240918205319.3517569-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240918205319.3517569-1-coltonlewis@google.com> X-Mailer: git-send-email 2.46.0.662.g92d0881bb0-goog Message-ID: <20240918205319.3517569-7-coltonlewis@google.com> Subject: [PATCH v2 6/6] KVM: x86: selftests: Test PerfMonV2 From: Colton Lewis To: kvm@vger.kernel.org Cc: Mingwei Zhang , Jinrong Liang , Jim Mattson , Aaron Lewis , Sean Christopherson , Paolo Bonzini , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Colton Lewis Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Test PerfMonV2, which defines global registers to enable multiple performance counters with a single MSR write, in its own function. If the feature is available, ensure the global control register has the ability to start and stop the performance counters and the global status register correctly flags an overflow by the associated counter. Signed-off-by: Colton Lewis --- .../selftests/kvm/x86_64/pmu_counters_test.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c b/tools= /testing/selftests/kvm/x86_64/pmu_counters_test.c index cf2941cc7c4c..a90df8b67a19 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_counters_test.c @@ -763,10 +763,63 @@ static void guest_test_core_events(void) } } =20 +static void guest_test_perfmon_v2(void) +{ + uint64_t i; + uint64_t eventsel =3D ARCH_PERFMON_EVENTSEL_OS | + ARCH_PERFMON_EVENTSEL_ENABLE | + AMD_ZEN_CORE_CYCLES; + bool core_ext =3D this_cpu_has(X86_FEATURE_PERF_CTR_EXT_CORE); + uint64_t sel_msr_base =3D core_ext ? MSR_F15H_PERF_CTL : MSR_K7_EVNTSEL0; + uint64_t cnt_msr_base =3D core_ext ? MSR_F15H_PERF_CTR : MSR_K7_PERFCTR0; + uint64_t msr_step =3D core_ext ? 2 : 1; + uint8_t nr_counters =3D guest_nr_core_counters(); + bool perfmon_v2 =3D this_cpu_has(X86_FEATURE_PERFMON_V2); + uint64_t sel_msr; + uint64_t cnt_msr; + + if (!perfmon_v2) + return; + + for (i =3D 0; i < nr_counters; i++) { + sel_msr =3D sel_msr_base + msr_step * i; + cnt_msr =3D cnt_msr_base + msr_step * i; + + /* Ensure count stays 0 when global register disables counter. */ + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, 0); + wrmsr(sel_msr, eventsel); + wrmsr(cnt_msr, 0); + __asm__ __volatile__("loop ." : "+c"((int){NUM_LOOPS})); + GUEST_ASSERT(!_rdpmc(i)); + + /* Ensure counter is >0 when global register enables counter. */ + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, BIT_ULL(i)); + __asm__ __volatile__("loop ." : "+c"((int){NUM_LOOPS})); + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, 0); + GUEST_ASSERT(_rdpmc(i)); + + /* Ensure global status register flags a counter overflow. */ + wrmsr(cnt_msr, -1); + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR, 0xff); + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, BIT_ULL(i)); + __asm__ __volatile__("loop ." : "+c"((int){NUM_LOOPS})); + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, 0); + GUEST_ASSERT(rdmsr(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS) & + BIT_ULL(i)); + + /* Ensure global status register flag is cleared correctly. */ + wrmsr(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR, BIT_ULL(i)); + GUEST_ASSERT(!(rdmsr(MSR_AMD64_PERF_CNTR_GLOBAL_STATUS) & + BIT_ULL(i))); + } +} + + static void guest_test_core_counters(void) { guest_test_rdwr_core_counters(); guest_test_core_events(); + guest_test_perfmon_v2(); GUEST_DONE(); } =20 --=20 2.46.0.662.g92d0881bb0-goog