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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull KVM fixes from Paolo Bonzini:
"ARM and x86 fixes"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: nVMX: VMX instructions: fix segment checks when L1 is in long mode.
KVM: LAPIC: cap __delay at lapic_timer_advance_ns
KVM: x86: move nsec_to_cycles from x86.c to x86.h
pvclock: Get rid of __pvclock_read_cycles in function pvclock_read_flags
pvclock: Cleanup to remove function pvclock_get_nsec_offset
pvclock: Add CPU barriers to get correct version value
KVM: arm/arm64: Stop leaking vcpu pid references
arm64: KVM: fix build with CONFIG_ARM_PMU disabled

+41 -39
+1
arch/arm/kvm/arm.c
··· 263 263 kvm_timer_vcpu_terminate(vcpu); 264 264 kvm_vgic_vcpu_destroy(vcpu); 265 265 kvm_pmu_vcpu_destroy(vcpu); 266 + kvm_vcpu_uninit(vcpu); 266 267 kmem_cache_free(kvm_vcpu_cache, vcpu); 267 268 } 268 269
+9 -16
arch/x86/include/asm/pvclock.h
··· 69 69 } 70 70 71 71 static __always_inline 72 - u64 pvclock_get_nsec_offset(const struct pvclock_vcpu_time_info *src) 73 - { 74 - u64 delta = rdtsc_ordered() - src->tsc_timestamp; 75 - return pvclock_scale_delta(delta, src->tsc_to_system_mul, 76 - src->tsc_shift); 77 - } 78 - 79 - static __always_inline 80 72 unsigned __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, 81 73 cycle_t *cycles, u8 *flags) 82 74 { 83 75 unsigned version; 84 - cycle_t ret, offset; 85 - u8 ret_flags; 76 + cycle_t offset; 77 + u64 delta; 86 78 87 79 version = src->version; 80 + /* Make the latest version visible */ 81 + smp_rmb(); 88 82 89 - offset = pvclock_get_nsec_offset(src); 90 - ret = src->system_time + offset; 91 - ret_flags = src->flags; 92 - 93 - *cycles = ret; 94 - *flags = ret_flags; 83 + delta = rdtsc_ordered() - src->tsc_timestamp; 84 + offset = pvclock_scale_delta(delta, src->tsc_to_system_mul, 85 + src->tsc_shift); 86 + *cycles = src->system_time + offset; 87 + *flags = src->flags; 95 88 return version; 96 89 } 97 90
+9 -2
arch/x86/kernel/pvclock.c
··· 61 61 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src) 62 62 { 63 63 unsigned version; 64 - cycle_t ret; 65 64 u8 flags; 66 65 67 66 do { 68 - version = __pvclock_read_cycles(src, &ret, &flags); 67 + version = src->version; 68 + /* Make the latest version visible */ 69 + smp_rmb(); 70 + 71 + flags = src->flags; 72 + /* Make sure that the version double-check is last. */ 73 + smp_rmb(); 69 74 } while ((src->version & 1) || version != src->version); 70 75 71 76 return flags & valid_flags; ··· 85 80 86 81 do { 87 82 version = __pvclock_read_cycles(src, &ret, &flags); 83 + /* Make sure that the version double-check is last. */ 84 + smp_rmb(); 88 85 } while ((src->version & 1) || version != src->version); 89 86 90 87 if (unlikely((flags & PVCLOCK_GUEST_STOPPED) != 0)) {
+2 -1
arch/x86/kvm/lapic.c
··· 1310 1310 1311 1311 /* __delay is delay_tsc whenever the hardware has TSC, thus always. */ 1312 1312 if (guest_tsc < tsc_deadline) 1313 - __delay(tsc_deadline - guest_tsc); 1313 + __delay(min(tsc_deadline - guest_tsc, 1314 + nsec_to_cycles(vcpu, lapic_timer_advance_ns))); 1314 1315 } 1315 1316 1316 1317 static void start_apic_timer(struct kvm_lapic *apic)
+11 -12
arch/x86/kvm/vmx.c
··· 6671 6671 6672 6672 /* Checks for #GP/#SS exceptions. */ 6673 6673 exn = false; 6674 - if (is_protmode(vcpu)) { 6674 + if (is_long_mode(vcpu)) { 6675 + /* Long mode: #GP(0)/#SS(0) if the memory address is in a 6676 + * non-canonical form. This is the only check on the memory 6677 + * destination for long mode! 6678 + */ 6679 + exn = is_noncanonical_address(*ret); 6680 + } else if (is_protmode(vcpu)) { 6675 6681 /* Protected mode: apply checks for segment validity in the 6676 6682 * following order: 6677 6683 * - segment type check (#GP(0) may be thrown) ··· 6694 6688 * execute-only code segment 6695 6689 */ 6696 6690 exn = ((s.type & 0xa) == 8); 6697 - } 6698 - if (exn) { 6699 - kvm_queue_exception_e(vcpu, GP_VECTOR, 0); 6700 - return 1; 6701 - } 6702 - if (is_long_mode(vcpu)) { 6703 - /* Long mode: #GP(0)/#SS(0) if the memory address is in a 6704 - * non-canonical form. This is an only check for long mode. 6705 - */ 6706 - exn = is_noncanonical_address(*ret); 6707 - } else if (is_protmode(vcpu)) { 6691 + if (exn) { 6692 + kvm_queue_exception_e(vcpu, GP_VECTOR, 0); 6693 + return 1; 6694 + } 6708 6695 /* Protected mode: #GP(0)/#SS(0) if the segment is unusable. 6709 6696 */ 6710 6697 exn = (s.unusable != 0);
-6
arch/x86/kvm/x86.c
··· 1244 1244 static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz); 1245 1245 static unsigned long max_tsc_khz; 1246 1246 1247 - static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec) 1248 - { 1249 - return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult, 1250 - vcpu->arch.virtual_tsc_shift); 1251 - } 1252 - 1253 1247 static u32 adjust_tsc_khz(u32 khz, s32 ppm) 1254 1248 { 1255 1249 u64 v = (u64)khz * (1000000 + ppm);
+7
arch/x86/kvm/x86.h
··· 2 2 #define ARCH_X86_KVM_X86_H 3 3 4 4 #include <linux/kvm_host.h> 5 + #include <asm/pvclock.h> 5 6 #include "kvm_cache_regs.h" 6 7 7 8 #define MSR_IA32_CR_PAT_DEFAULT 0x0007040600070406ULL ··· 195 194 extern unsigned int lapic_timer_advance_ns; 196 195 197 196 extern struct static_key kvm_no_apic_vcpu; 197 + 198 + static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec) 199 + { 200 + return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult, 201 + vcpu->arch.virtual_tsc_shift); 202 + } 198 203 199 204 /* Same "calling convention" as do_div: 200 205 * - divide (n << 32) by base
+2 -2
include/kvm/arm_pmu.h
··· 18 18 #ifndef __ASM_ARM_KVM_PMU_H 19 19 #define __ASM_ARM_KVM_PMU_H 20 20 21 - #ifdef CONFIG_KVM_ARM_PMU 22 - 23 21 #include <linux/perf_event.h> 24 22 #include <asm/perf_event.h> 25 23 26 24 #define ARMV8_PMU_CYCLE_IDX (ARMV8_PMU_MAX_COUNTERS - 1) 25 + 26 + #ifdef CONFIG_KVM_ARM_PMU 27 27 28 28 struct kvm_pmc { 29 29 u8 idx; /* index into the pmu->pmc array */