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:
"Except for the preempt notifiers fix, these are all small bugfixes
that could have been waited for -rc2. Sending them now since I was
taking care of Peter's patch anyway"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
kvm: add hyper-v crash msrs values
KVM: x86: remove data variable from kvm_get_msr_common
KVM: s390: virtio-ccw: don't overwrite config space values
KVM: x86: keep track of LVT0 changes under APICv
KVM: x86: properly restore LVT0
KVM: x86: make vapics_in_nmi_mode atomic
sched, preempt_notifier: separate notifier registration from static_key inc/dec

+54 -16
+1 -1
arch/x86/include/asm/kvm_host.h
··· 607 607 struct kvm_pic *vpic; 608 608 struct kvm_ioapic *vioapic; 609 609 struct kvm_pit *vpit; 610 - int vapics_in_nmi_mode; 610 + atomic_t vapics_in_nmi_mode; 611 611 struct mutex apic_map_lock; 612 612 struct kvm_apic_map *apic_map; 613 613
+11
arch/x86/include/uapi/asm/hyperv.h
··· 199 199 #define HV_X64_MSR_STIMER3_CONFIG 0x400000B6 200 200 #define HV_X64_MSR_STIMER3_COUNT 0x400000B7 201 201 202 + /* Hyper-V guest crash notification MSR's */ 203 + #define HV_X64_MSR_CRASH_P0 0x40000100 204 + #define HV_X64_MSR_CRASH_P1 0x40000101 205 + #define HV_X64_MSR_CRASH_P2 0x40000102 206 + #define HV_X64_MSR_CRASH_P3 0x40000103 207 + #define HV_X64_MSR_CRASH_P4 0x40000104 208 + #define HV_X64_MSR_CRASH_CTL 0x40000105 209 + #define HV_X64_MSR_CRASH_CTL_NOTIFY (1ULL << 63) 210 + #define HV_X64_MSR_CRASH_PARAMS \ 211 + (1 + (HV_X64_MSR_CRASH_P4 - HV_X64_MSR_CRASH_P0)) 212 + 202 213 #define HV_X64_MSR_HYPERCALL_ENABLE 0x00000001 203 214 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT 12 204 215 #define HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_MASK \
+1 -1
arch/x86/kvm/i8254.c
··· 305 305 * LVT0 to NMI delivery. Other PIC interrupts are just sent to 306 306 * VCPU0, and only if its LVT0 is in EXTINT mode. 307 307 */ 308 - if (kvm->arch.vapics_in_nmi_mode > 0) 308 + if (atomic_read(&kvm->arch.vapics_in_nmi_mode) > 0) 309 309 kvm_for_each_vcpu(i, vcpu, kvm) 310 310 kvm_apic_nmi_wd_deliver(vcpu); 311 311 }
+10 -7
arch/x86/kvm/lapic.c
··· 1257 1257 1258 1258 static void apic_manage_nmi_watchdog(struct kvm_lapic *apic, u32 lvt0_val) 1259 1259 { 1260 - int nmi_wd_enabled = apic_lvt_nmi_mode(kvm_apic_get_reg(apic, APIC_LVT0)); 1260 + bool lvt0_in_nmi_mode = apic_lvt_nmi_mode(lvt0_val); 1261 1261 1262 - if (apic_lvt_nmi_mode(lvt0_val)) { 1263 - if (!nmi_wd_enabled) { 1262 + if (apic->lvt0_in_nmi_mode != lvt0_in_nmi_mode) { 1263 + apic->lvt0_in_nmi_mode = lvt0_in_nmi_mode; 1264 + if (lvt0_in_nmi_mode) { 1264 1265 apic_debug("Receive NMI setting on APIC_LVT0 " 1265 1266 "for cpu %d\n", apic->vcpu->vcpu_id); 1266 - apic->vcpu->kvm->arch.vapics_in_nmi_mode++; 1267 - } 1268 - } else if (nmi_wd_enabled) 1269 - apic->vcpu->kvm->arch.vapics_in_nmi_mode--; 1267 + atomic_inc(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); 1268 + } else 1269 + atomic_dec(&apic->vcpu->kvm->arch.vapics_in_nmi_mode); 1270 + } 1270 1271 } 1271 1272 1272 1273 static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) ··· 1598 1597 if (!(vcpu->kvm->arch.disabled_quirks & KVM_QUIRK_LINT0_REENABLED)) 1599 1598 apic_set_reg(apic, APIC_LVT0, 1600 1599 SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT)); 1600 + apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0)); 1601 1601 1602 1602 apic_set_reg(apic, APIC_DFR, 0xffffffffU); 1603 1603 apic_set_spiv(apic, 0xff); ··· 1824 1822 apic_update_ppr(apic); 1825 1823 hrtimer_cancel(&apic->lapic_timer.timer); 1826 1824 apic_update_lvtt(apic); 1825 + apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0)); 1827 1826 update_divide_count(apic); 1828 1827 start_apic_timer(apic); 1829 1828 apic->irr_pending = true;
+1
arch/x86/kvm/lapic.h
··· 26 26 struct kvm_vcpu *vcpu; 27 27 bool sw_enabled; 28 28 bool irr_pending; 29 + bool lvt0_in_nmi_mode; 29 30 /* Number of bits set in ISR. */ 30 31 s16 isr_count; 31 32 /* The highest vector set in ISR; if -1 - invalid, must scan ISR. */
+1 -3
arch/x86/kvm/x86.c
··· 2379 2379 2380 2380 int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) 2381 2381 { 2382 - u64 data; 2383 - 2384 2382 switch (msr_info->index) { 2385 2383 case MSR_IA32_PLATFORM_ID: 2386 2384 case MSR_IA32_EBL_CR_POWERON: ··· 2451 2453 /* TSC increment by tick */ 2452 2454 msr_info->data = 1000ULL; 2453 2455 /* CPU multiplier */ 2454 - data |= (((uint64_t)4ULL) << 40); 2456 + msr_info->data |= (((uint64_t)4ULL) << 40); 2455 2457 break; 2456 2458 case MSR_EFER: 2457 2459 msr_info->data = vcpu->arch.efer;
+9 -2
drivers/s390/kvm/virtio_ccw.c
··· 65 65 bool is_thinint; 66 66 bool going_away; 67 67 bool device_lost; 68 + unsigned int config_ready; 68 69 void *airq_info; 69 70 }; 70 71 ··· 834 833 if (ret) 835 834 goto out_free; 836 835 837 - memcpy(vcdev->config, config_area, sizeof(vcdev->config)); 838 - memcpy(buf, &vcdev->config[offset], len); 836 + memcpy(vcdev->config, config_area, offset + len); 837 + if (buf) 838 + memcpy(buf, &vcdev->config[offset], len); 839 + if (vcdev->config_ready < offset + len) 840 + vcdev->config_ready = offset + len; 839 841 840 842 out_free: 841 843 kfree(config_area); ··· 861 857 if (!config_area) 862 858 goto out_free; 863 859 860 + /* Make sure we don't overwrite fields. */ 861 + if (vcdev->config_ready < offset) 862 + virtio_ccw_get_config(vdev, 0, NULL, offset); 864 863 memcpy(&vcdev->config[offset], buf, len); 865 864 /* Write the config area to the host. */ 866 865 memcpy(config_area, vcdev->config, sizeof(vcdev->config));
+2
include/linux/preempt.h
··· 293 293 struct preempt_ops *ops; 294 294 }; 295 295 296 + void preempt_notifier_inc(void); 297 + void preempt_notifier_dec(void); 296 298 void preempt_notifier_register(struct preempt_notifier *notifier); 297 299 void preempt_notifier_unregister(struct preempt_notifier *notifier); 298 300
+15 -2
kernel/sched/core.c
··· 2320 2320 2321 2321 static struct static_key preempt_notifier_key = STATIC_KEY_INIT_FALSE; 2322 2322 2323 + void preempt_notifier_inc(void) 2324 + { 2325 + static_key_slow_inc(&preempt_notifier_key); 2326 + } 2327 + EXPORT_SYMBOL_GPL(preempt_notifier_inc); 2328 + 2329 + void preempt_notifier_dec(void) 2330 + { 2331 + static_key_slow_dec(&preempt_notifier_key); 2332 + } 2333 + EXPORT_SYMBOL_GPL(preempt_notifier_dec); 2334 + 2323 2335 /** 2324 2336 * preempt_notifier_register - tell me when current is being preempted & rescheduled 2325 2337 * @notifier: notifier struct to register 2326 2338 */ 2327 2339 void preempt_notifier_register(struct preempt_notifier *notifier) 2328 2340 { 2329 - static_key_slow_inc(&preempt_notifier_key); 2341 + if (!static_key_false(&preempt_notifier_key)) 2342 + WARN(1, "registering preempt_notifier while notifiers disabled\n"); 2343 + 2330 2344 hlist_add_head(&notifier->link, &current->preempt_notifiers); 2331 2345 } 2332 2346 EXPORT_SYMBOL_GPL(preempt_notifier_register); ··· 2354 2340 void preempt_notifier_unregister(struct preempt_notifier *notifier) 2355 2341 { 2356 2342 hlist_del(&notifier->link); 2357 - static_key_slow_dec(&preempt_notifier_key); 2358 2343 } 2359 2344 EXPORT_SYMBOL_GPL(preempt_notifier_unregister); 2360 2345
+3
virt/kvm/kvm_main.c
··· 553 553 list_add(&kvm->vm_list, &vm_list); 554 554 spin_unlock(&kvm_lock); 555 555 556 + preempt_notifier_inc(); 557 + 556 558 return kvm; 557 559 558 560 out_err: ··· 622 620 cleanup_srcu_struct(&kvm->irq_srcu); 623 621 cleanup_srcu_struct(&kvm->srcu); 624 622 kvm_arch_free_vm(kvm); 623 + preempt_notifier_dec(); 625 624 hardware_disable_all(); 626 625 mmdrop(mm); 627 626 }