Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: VMX: Intercept RDPMC

Intercept RDPMC and forward it to the PMU emulation code.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>

+14 -1
+14 -1
arch/x86/kvm/vmx.c
··· 1956 1956 #endif 1957 1957 CPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING | 1958 1958 CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_EXITING | 1959 + CPU_BASED_RDPMC_EXITING | 1959 1960 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; 1960 1961 /* 1961 1962 * We can allow some features even when not supported by the ··· 2411 2410 CPU_BASED_USE_TSC_OFFSETING | 2412 2411 CPU_BASED_MWAIT_EXITING | 2413 2412 CPU_BASED_MONITOR_EXITING | 2414 - CPU_BASED_INVLPG_EXITING; 2413 + CPU_BASED_INVLPG_EXITING | 2414 + CPU_BASED_RDPMC_EXITING; 2415 2415 2416 2416 if (yield_on_hlt) 2417 2417 min |= CPU_BASED_HLT_EXITING; ··· 4615 4613 return 1; 4616 4614 } 4617 4615 4616 + static int handle_rdpmc(struct kvm_vcpu *vcpu) 4617 + { 4618 + int err; 4619 + 4620 + err = kvm_rdpmc(vcpu); 4621 + kvm_complete_insn_gp(vcpu, err); 4622 + 4623 + return 1; 4624 + } 4625 + 4618 4626 static int handle_wbinvd(struct kvm_vcpu *vcpu) 4619 4627 { 4620 4628 skip_emulated_instruction(vcpu); ··· 5575 5563 [EXIT_REASON_HLT] = handle_halt, 5576 5564 [EXIT_REASON_INVD] = handle_invd, 5577 5565 [EXIT_REASON_INVLPG] = handle_invlpg, 5566 + [EXIT_REASON_RDPMC] = handle_rdpmc, 5578 5567 [EXIT_REASON_VMCALL] = handle_vmcall, 5579 5568 [EXIT_REASON_VMCLEAR] = handle_vmclear, 5580 5569 [EXIT_REASON_VMLAUNCH] = handle_vmlaunch,