aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-09-22 14:50:00 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2016-09-22 17:25:59 +0200
commit73e1b8f2f9b8a90361f9c1af306ee17bfcfd592d (patch)
tree8f46c5d6eab7430c9ca2868d3b7af34b0090017f /target-i386
parenta008535b9fa396226ff9cf78b8ac5f3584bda58e (diff)
downloadqemu-73e1b8f2f9b8a90361f9c1af306ee17bfcfd592d.zip
qemu-73e1b8f2f9b8a90361f9c1af306ee17bfcfd592d.tar.gz
qemu-73e1b8f2f9b8a90361f9c1af306ee17bfcfd592d.tar.bz2
target-i386: introduce kvm_put_one_msr
Avoid further code duplication in the next patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/kvm.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f1ad805..c57b01b 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1532,6 +1532,14 @@ static void kvm_msr_entry_add(X86CPU *cpu, uint32_t index, uint64_t value)
msrs->nmsrs++;
}
+static int kvm_put_one_msr(X86CPU *cpu, int index, uint64_t value)
+{
+ kvm_msr_buf_reset(cpu);
+ kvm_msr_entry_add(cpu, index, value);
+
+ return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
+}
+
static int kvm_put_tscdeadline_msr(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
@@ -1541,10 +1549,7 @@ static int kvm_put_tscdeadline_msr(X86CPU *cpu)
return 0;
}
- kvm_msr_buf_reset(cpu);
- kvm_msr_entry_add(cpu, MSR_IA32_TSCDEADLINE, env->tsc_deadline);
-
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
+ ret = kvm_put_one_msr(cpu, MSR_IA32_TSCDEADLINE, env->tsc_deadline);
if (ret < 0) {
return ret;
}
@@ -1567,11 +1572,8 @@ static int kvm_put_msr_feature_control(X86CPU *cpu)
return 0;
}
- kvm_msr_buf_reset(cpu);
- kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL,
- cpu->env.msr_ia32_feature_control);
-
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
+ ret = kvm_put_one_msr(cpu, MSR_IA32_FEATURE_CONTROL,
+ cpu->env.msr_ia32_feature_control);
if (ret < 0) {
return ret;
}