Skip to content

Commit c2687cf

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini: - ARM/MIPS: Fixes for ioctls when copy_from_user returns nonzero - x86: Small fix for Skylake TSC scaling - x86: Improved fix for last week's missed hardware breakpoint bug * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: kvm: x86: Update tsc multiplier on change. mips/kvm: fix ioctl error handling arm/arm64: KVM: Fix ioctl error handling KVM: x86: fix root cause for missed hardware breakpoints
2 parents 4237b2e + 2680d6d commit c2687cf

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

arch/arm/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
161161
u64 val;
162162

163163
val = kvm_arm_timer_get_reg(vcpu, reg->id);
164-
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
164+
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
165165
}
166166

167167
static unsigned long num_core_regs(void)

arch/arm64/kvm/guest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
194194
u64 val;
195195

196196
val = kvm_arm_timer_get_reg(vcpu, reg->id);
197-
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
197+
return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
198198
}
199199

200200
/**

arch/mips/kvm/mips.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
702702
} else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
703703
void __user *uaddr = (void __user *)(long)reg->addr;
704704

705-
return copy_to_user(uaddr, vs, 16);
705+
return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0;
706706
} else {
707707
return -EINVAL;
708708
}
@@ -732,7 +732,7 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
732732
} else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
733733
void __user *uaddr = (void __user *)(long)reg->addr;
734734

735-
return copy_from_user(vs, uaddr, 16);
735+
return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0;
736736
} else {
737737
return -EINVAL;
738738
}

arch/x86/kvm/vmx.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ struct vcpu_vmx {
596596
/* Support for PML */
597597
#define PML_ENTITY_NUM 512
598598
struct page *pml_pg;
599+
600+
u64 current_tsc_ratio;
599601
};
600602

601603
enum segment_cache_field {
@@ -2127,14 +2129,16 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
21272129
rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
21282130
vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
21292131

2130-
/* Setup TSC multiplier */
2131-
if (cpu_has_vmx_tsc_scaling())
2132-
vmcs_write64(TSC_MULTIPLIER,
2133-
vcpu->arch.tsc_scaling_ratio);
2134-
21352132
vmx->loaded_vmcs->cpu = cpu;
21362133
}
21372134

2135+
/* Setup TSC multiplier */
2136+
if (kvm_has_tsc_control &&
2137+
vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) {
2138+
vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio;
2139+
vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio);
2140+
}
2141+
21382142
vmx_vcpu_pi_load(vcpu, cpu);
21392143
}
21402144

arch/x86/kvm/x86.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27522752
}
27532753

27542754
kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
2755-
vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD;
27562755
}
27572756

27582757
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
@@ -6619,12 +6618,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
66196618
* KVM_DEBUGREG_WONT_EXIT again.
66206619
*/
66216620
if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
6622-
int i;
6623-
66246621
WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
66256622
kvm_x86_ops->sync_dirty_debug_regs(vcpu);
6626-
for (i = 0; i < KVM_NR_DB_REGS; i++)
6627-
vcpu->arch.eff_db[i] = vcpu->arch.db[i];
6623+
kvm_update_dr0123(vcpu);
6624+
kvm_update_dr6(vcpu);
6625+
kvm_update_dr7(vcpu);
6626+
vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
66286627
}
66296628

66306629
/*

0 commit comments

Comments
 (0)