Commit d374b89
committed
KVM: VMX: Add mediated PMU support for CPUs without "save perf global ctrl"
Extend mediated PMU support for Intel CPUs without support for saving
PERF_GLOBAL_CONTROL into the guest VMCS field on VM-Exit, e.g. for Skylake
and its derivatives, as well as Icelake. While supporting CPUs without
VM_EXIT_SAVE_IA32_PERF_GLOBAL_CTRL isn't completely trivial, it's not that
complex either. And not supporting such CPUs would mean not supporting 7+
years of Intel CPUs released in the past 10 years.
On VM-Exit, immediately propagate the saved PERF_GLOBAL_CTRL to the VMCS
as well as KVM's software cache so that KVM doesn't need to add full EXREG
tracking of PERF_GLOBAL_CTRL. In practice, the vast majority of VM-Exits
won't trigger software writes to guest PERF_GLOBAL_CTRL, so deferring the
VMWRITE to the next VM-Enter would only delay the inevitable without
batching/avoiding VMWRITEs.
Note! Take care to refresh VM_EXIT_MSR_STORE_COUNT on nested VM-Exit, as
it's unfortunately possible that KVM could recalculate MSR intercepts
while L2 is active, e.g. if userspace loads nested state and _then_ sets
PERF_CAPABILITIES. Eating the VMWRITE on every nested VM-Exit is
unfortunate, but that's a pre-existing problem and can/should be solved
separately, e.g. modifying the number of auto-load entries while L2 is
active is also uncommon on modern CPUs.
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Tested-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Tested-by: Manali Shukla <manali.shukla@amd.com>
Link: https://patch.msgid.link/20251206001720.468579-45-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 9757a5a commit d374b89
3 files changed
+52
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5142 | 5142 | | |
5143 | 5143 | | |
5144 | 5144 | | |
5145 | | - | |
| 5145 | + | |
| 5146 | + | |
| 5147 | + | |
| 5148 | + | |
| 5149 | + | |
5146 | 5150 | | |
5147 | 5151 | | |
5148 | 5152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
777 | 777 | | |
778 | 778 | | |
779 | 779 | | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | 780 | | |
788 | 781 | | |
789 | 782 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
1207 | 1218 | | |
1208 | 1219 | | |
1209 | 1220 | | |
| |||
4225 | 4236 | | |
4226 | 4237 | | |
4227 | 4238 | | |
| 4239 | + | |
| 4240 | + | |
4228 | 4241 | | |
4229 | 4242 | | |
4230 | 4243 | | |
| |||
4234 | 4247 | | |
4235 | 4248 | | |
4236 | 4249 | | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
4237 | 4259 | | |
4238 | 4260 | | |
4239 | 4261 | | |
4240 | | - | |
4241 | | - | |
4242 | | - | |
| 4262 | + | |
4243 | 4263 | | |
4244 | 4264 | | |
4245 | 4265 | | |
| |||
7346 | 7366 | | |
7347 | 7367 | | |
7348 | 7368 | | |
| 7369 | + | |
| 7370 | + | |
| 7371 | + | |
| 7372 | + | |
| 7373 | + | |
| 7374 | + | |
| 7375 | + | |
| 7376 | + | |
| 7377 | + | |
| 7378 | + | |
| 7379 | + | |
| 7380 | + | |
| 7381 | + | |
| 7382 | + | |
| 7383 | + | |
| 7384 | + | |
| 7385 | + | |
| 7386 | + | |
| 7387 | + | |
| 7388 | + | |
| 7389 | + | |
| 7390 | + | |
| 7391 | + | |
7349 | 7392 | | |
7350 | 7393 | | |
7351 | 7394 | | |
| |||
7631 | 7674 | | |
7632 | 7675 | | |
7633 | 7676 | | |
7634 | | - | |
7635 | | - | |
| 7677 | + | |
7636 | 7678 | | |
7637 | 7679 | | |
7638 | 7680 | | |
| |||
0 commit comments