Skip to content

Commit 3b36160

Browse files
committed
KVM: nSVM: Disable PMU MSR interception as appropriate while running L2
Add MSRs that might be passed through to L1 when running with a mediated PMU to the nested SVM's set of to-be-merged MSR indices, i.e. disable interception of PMU MSRs when running L2 if both KVM (L0) and L1 disable interception. There is no need for KVM to interpose on such MSR accesses, e.g. if L1 exposes a mediated PMU (or equivalent) to L2. Tested-by: Xudong Hao <xudong.hao@intel.com> Tested-by: Manali Shukla <manali.shukla@amd.com> Link: https://patch.msgid.link/20251206001720.468579-33-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 88ebc2a commit 3b36160

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

arch/x86/kvm/svm/nested.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void recalc_intercepts(struct vcpu_svm *svm)
194194
* Hardcode the capacity of the array based on the maximum number of _offsets_.
195195
* MSRs are batched together, so there are fewer offsets than MSRs.
196196
*/
197-
static int nested_svm_msrpm_merge_offsets[7] __ro_after_init;
197+
static int nested_svm_msrpm_merge_offsets[10] __ro_after_init;
198198
static int nested_svm_nr_msrpm_merge_offsets __ro_after_init;
199199
typedef unsigned long nsvm_msrpm_merge_t;
200200

@@ -222,6 +222,22 @@ int __init nested_svm_init_msrpm_merge_offsets(void)
222222
MSR_IA32_LASTBRANCHTOIP,
223223
MSR_IA32_LASTINTFROMIP,
224224
MSR_IA32_LASTINTTOIP,
225+
226+
MSR_K7_PERFCTR0,
227+
MSR_K7_PERFCTR1,
228+
MSR_K7_PERFCTR2,
229+
MSR_K7_PERFCTR3,
230+
MSR_F15H_PERF_CTR0,
231+
MSR_F15H_PERF_CTR1,
232+
MSR_F15H_PERF_CTR2,
233+
MSR_F15H_PERF_CTR3,
234+
MSR_F15H_PERF_CTR4,
235+
MSR_F15H_PERF_CTR5,
236+
237+
MSR_AMD64_PERF_CNTR_GLOBAL_CTL,
238+
MSR_AMD64_PERF_CNTR_GLOBAL_STATUS,
239+
MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR,
240+
MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_SET,
225241
};
226242
int i, j;
227243

0 commit comments

Comments
 (0)