aboutsummaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2015-12-16 17:06:45 -0200
committerEduardo Habkost <ehabkost@redhat.com>2016-05-23 19:47:37 -0300
commite25ffda7bd9e8b10d4d08f944ad87c7523096de5 (patch)
treef4a00a02763bad798ed0fafe0148eb92b5252a54 /target-i386
parent9c600a84544dfedff238f6e0cfac0d88c58654c0 (diff)
downloadqemu-e25ffda7bd9e8b10d4d08f944ad87c7523096de5.zip
qemu-e25ffda7bd9e8b10d4d08f944ad87c7523096de5.tar.gz
qemu-e25ffda7bd9e8b10d4d08f944ad87c7523096de5.tar.bz2
target-i386: kvm: Simplify MSR setting functions
Simplify kvm_put_tscdeadline_msr() and kvm_put_msr_feature_control() using kvm_msr_buf and the kvm_msr_entry_add() helper. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/kvm.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index dbe0f90..0b56b38 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1487,24 +1487,16 @@ static void kvm_msr_entry_add(X86CPU *cpu, uint32_t index, uint64_t value)
static int kvm_put_tscdeadline_msr(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
- struct {
- struct kvm_msrs info;
- struct kvm_msr_entry entries[1];
- } msr_data;
- struct kvm_msr_entry *msrs = msr_data.entries;
int ret;
if (!has_msr_tsc_deadline) {
return 0;
}
- kvm_msr_entry_set(&msrs[0], MSR_IA32_TSCDEADLINE, env->tsc_deadline);
-
- msr_data.info = (struct kvm_msrs) {
- .nmsrs = 1,
- };
+ 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, &msr_data);
+ ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
if (ret < 0) {
return ret;
}
@@ -1521,24 +1513,17 @@ static int kvm_put_tscdeadline_msr(X86CPU *cpu)
*/
static int kvm_put_msr_feature_control(X86CPU *cpu)
{
- struct {
- struct kvm_msrs info;
- struct kvm_msr_entry entry;
- } msr_data;
int ret;
if (!has_msr_feature_control) {
return 0;
}
- kvm_msr_entry_set(&msr_data.entry, MSR_IA32_FEATURE_CONTROL,
+ kvm_msr_buf_reset(cpu);
+ kvm_msr_entry_add(cpu, MSR_IA32_FEATURE_CONTROL,
cpu->env.msr_ia32_feature_control);
- msr_data.info = (struct kvm_msrs) {
- .nmsrs = 1,
- };
-
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data);
+ ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, cpu->kvm_msr_buf);
if (ret < 0) {
return ret;
}