Commit d647eb63 authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: svm: add nrips module parameter

Allow testing code for old processors that lack the next RIP save
feature, by disabling usage of the next_rip field.

Nested hypervisors however get the feature unconditionally.
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent c550505b
...@@ -367,6 +367,10 @@ static int avic; ...@@ -367,6 +367,10 @@ static int avic;
module_param(avic, int, S_IRUGO); module_param(avic, int, S_IRUGO);
#endif #endif
/* enable/disable Next RIP Save */
static int nrips = true;
module_param(nrips, int, 0444);
/* enable/disable Virtual VMLOAD VMSAVE */ /* enable/disable Virtual VMLOAD VMSAVE */
static int vls = true; static int vls = true;
module_param(vls, int, 0444); module_param(vls, int, 0444);
...@@ -773,7 +777,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu) ...@@ -773,7 +777,7 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
{ {
struct vcpu_svm *svm = to_svm(vcpu); struct vcpu_svm *svm = to_svm(vcpu);
if (svm->vmcb->control.next_rip != 0) { if (nrips && svm->vmcb->control.next_rip != 0) {
WARN_ON_ONCE(!static_cpu_has(X86_FEATURE_NRIPS)); WARN_ON_ONCE(!static_cpu_has(X86_FEATURE_NRIPS));
svm->next_rip = svm->vmcb->control.next_rip; svm->next_rip = svm->vmcb->control.next_rip;
} }
...@@ -810,7 +814,7 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu) ...@@ -810,7 +814,7 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu)
kvm_deliver_exception_payload(&svm->vcpu); kvm_deliver_exception_payload(&svm->vcpu);
if (nr == BP_VECTOR && !static_cpu_has(X86_FEATURE_NRIPS)) { if (nr == BP_VECTOR && !nrips) {
unsigned long rip, old_rip = kvm_rip_read(&svm->vcpu); unsigned long rip, old_rip = kvm_rip_read(&svm->vcpu);
/* /*
...@@ -1367,6 +1371,11 @@ static __init int svm_hardware_setup(void) ...@@ -1367,6 +1371,11 @@ static __init int svm_hardware_setup(void)
} else } else
kvm_disable_tdp(); kvm_disable_tdp();
if (nrips) {
if (!boot_cpu_has(X86_FEATURE_NRIPS))
nrips = false;
}
if (avic) { if (avic) {
if (!npt_enabled || if (!npt_enabled ||
!boot_cpu_has(X86_FEATURE_AVIC) || !boot_cpu_has(X86_FEATURE_AVIC) ||
...@@ -3938,7 +3947,7 @@ static int rdpmc_interception(struct vcpu_svm *svm) ...@@ -3938,7 +3947,7 @@ static int rdpmc_interception(struct vcpu_svm *svm)
{ {
int err; int err;
if (!static_cpu_has(X86_FEATURE_NRIPS)) if (!nrips)
return emulate_on_interception(svm); return emulate_on_interception(svm);
err = kvm_rdpmc(&svm->vcpu); err = kvm_rdpmc(&svm->vcpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment