[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260121225438.3908422-1-jmattson@google.com>
Date: Wed, 21 Jan 2026 14:53:58 -0800
From: Jim Mattson <jmattson@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Peter Zijlstra <peterz@...radead.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
James Clark <james.clark@...aro.org>, Shuah Khan <shuah@...nel.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
linux-kselftest@...r.kernel.org
Cc: Jim Mattson <jmattson@...gle.com>
Subject: [PATCH 0/6] KVM: x86/pmu: Add support for AMD HG_ONLY bits
This series adds support for AMD's Host-Only (bit 41) and Guest-Only (bit
40) performance counter eventsel bits in KVM's mediated PMU passthrough
implementation.
These bits allow an nSVM-enabled guest to configure performance counters
that count only during L1 execution (Host-Only) or only during L2 execution
(Guest-Only).
KVM tracks which PMCs have Host-Only xor Guest-Only bits set, and updates
the hardware event selector ENABLE bit at the following state transitions:
- EFER.SVME changes: Enable/disable Guest-Only counters
- VMRUN: Disable Host-Only, enable Guest-Only counters
- VMEXIT: Enable Host-Only, disable Guest-Only counters
Jim Mattson (6):
KVM: x86/pmu: Introduce amd_pmu_set_eventsel_hw()
KVM: x86/pmu: Disable HG_ONLY events as appropriate for current vCPU
state
KVM: x86/pmu: Track enabled AMD PMCs with Host-Only xor Guest-Only
bits set
KVM: x86/pmu: [De]activate HG_ONLY PMCs at SVME changes and nested
transitions
KVM: x86/pmu: Allow HG_ONLY bits with nSVM and mediated PMU
KVM: selftests: x86: Add svm_pmu_hg_test for HG_ONLY bits
arch/x86/include/asm/kvm-x86-pmu-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 4 +
arch/x86/include/asm/perf_event.h | 2 +
arch/x86/kvm/pmu.c | 9 +
arch/x86/kvm/pmu.h | 4 +
arch/x86/kvm/svm/nested.c | 10 +
arch/x86/kvm/svm/pmu.c | 84 ++++-
arch/x86/kvm/svm/svm.c | 3 +
tools/testing/selftests/kvm/Makefile.kvm | 1 +
.../selftests/kvm/x86/svm_pmu_hg_test.c | 297 ++++++++++++++++++
10 files changed, 412 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86/svm_pmu_hg_test.c
--
2.52.0.457.g6b5491de43-goog
Powered by blists - more mailing lists