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

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

Pull kvm fixes from Paolo Bonzini:
"Small fixes for x86, slightly larger fixes for PPC, and a forgotten
s390 patch. The PPC fixes are important because they fix breakage
that is new in 3.15"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: s390: announce irqfd capability
KVM: x86: disable master clock if TSC is reset during suspend
KVM: vmx: disable APIC virtualization in nested guests
KVM guest: Make pv trampoline code executable
KVM: PPC: Book3S: ifdef on CONFIG_KVM_BOOK3S_32_HANDLER for 32bit
KVM: PPC: Book3S HV: Add missing code for transaction reclaim on guest exit
KVM: PPC: Book3S: HV: make _PAGE_NUMA take effect

+139 -12
+1 -1
Documentation/virtual/kvm/api.txt
··· 2126 2126 4.75 KVM_IRQFD 2127 2127 2128 2128 Capability: KVM_CAP_IRQFD 2129 - Architectures: x86 2129 + Architectures: x86 s390 2130 2130 Type: vm ioctl 2131 2131 Parameters: struct kvm_irqfd (in) 2132 2132 Returns: 0 on success, -1 on error
+11
arch/powerpc/include/asm/sections.h
··· 39 39 (unsigned long)_stext < end; 40 40 } 41 41 42 + static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end) 43 + { 44 + #ifdef CONFIG_KVM_GUEST 45 + extern char kvm_tmp[]; 46 + return start < (unsigned long)kvm_tmp && 47 + (unsigned long)&kvm_tmp[1024 * 1024] < end; 48 + #else 49 + return 0; 50 + #endif 51 + } 52 + 42 53 #undef dereference_function_descriptor 43 54 static inline void *dereference_function_descriptor(void *ptr) 44 55 {
+1 -1
arch/powerpc/kernel/kvm.c
··· 74 74 #define KVM_INST_MTSRIN 0x7c0001e4 75 75 76 76 static bool kvm_patching_worked = true; 77 - static char kvm_tmp[1024 * 1024]; 77 + char kvm_tmp[1024 * 1024]; 78 78 static int kvm_tmp_index; 79 79 80 80 static inline void kvm_patch_ins(u32 *inst, u32 new_inst)
+3 -3
arch/powerpc/kvm/book3s.c
··· 886 886 r = kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE); 887 887 if (r) 888 888 return r; 889 - #ifdef CONFIG_KVM_BOOK3S_32 889 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 890 890 r = kvmppc_book3s_init_pr(); 891 891 #endif 892 892 return r; ··· 895 895 896 896 static void kvmppc_book3s_exit(void) 897 897 { 898 - #ifdef CONFIG_KVM_BOOK3S_32 898 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 899 899 kvmppc_book3s_exit_pr(); 900 900 #endif 901 901 kvm_exit(); ··· 905 905 module_exit(kvmppc_book3s_exit); 906 906 907 907 /* On 32bit this is our one and only kernel module */ 908 - #ifdef CONFIG_KVM_BOOK3S_32 908 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 909 909 MODULE_ALIAS_MISCDEV(KVM_MINOR); 910 910 MODULE_ALIAS("devname:kvm"); 911 911 #endif
+1 -1
arch/powerpc/kvm/book3s_hv_rm_mmu.c
··· 234 234 pte_size = psize; 235 235 pte = lookup_linux_pte_and_update(pgdir, hva, writing, 236 236 &pte_size); 237 - if (pte_present(pte)) { 237 + if (pte_present(pte) && !pte_numa(pte)) { 238 238 if (writing && !pte_write(pte)) 239 239 /* make the actual HPTE be read-only */ 240 240 ptel = hpte_make_readonly(ptel);
+104
arch/powerpc/kvm/book3s_hv_rmhandlers.S
··· 1323 1323 mr r3, r9 1324 1324 bl kvmppc_save_fp 1325 1325 1326 + #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1327 + BEGIN_FTR_SECTION 1328 + b 2f 1329 + END_FTR_SECTION_IFCLR(CPU_FTR_TM) 1330 + /* Turn on TM. */ 1331 + mfmsr r8 1332 + li r0, 1 1333 + rldimi r8, r0, MSR_TM_LG, 63-MSR_TM_LG 1334 + mtmsrd r8 1335 + 1336 + ld r5, VCPU_MSR(r9) 1337 + rldicl. r5, r5, 64 - MSR_TS_S_LG, 62 1338 + beq 1f /* TM not active in guest. */ 1339 + 1340 + li r3, TM_CAUSE_KVM_RESCHED 1341 + 1342 + /* Clear the MSR RI since r1, r13 are all going to be foobar. */ 1343 + li r5, 0 1344 + mtmsrd r5, 1 1345 + 1346 + /* All GPRs are volatile at this point. */ 1347 + TRECLAIM(R3) 1348 + 1349 + /* Temporarily store r13 and r9 so we have some regs to play with */ 1350 + SET_SCRATCH0(r13) 1351 + GET_PACA(r13) 1352 + std r9, PACATMSCRATCH(r13) 1353 + ld r9, HSTATE_KVM_VCPU(r13) 1354 + 1355 + /* Get a few more GPRs free. */ 1356 + std r29, VCPU_GPRS_TM(29)(r9) 1357 + std r30, VCPU_GPRS_TM(30)(r9) 1358 + std r31, VCPU_GPRS_TM(31)(r9) 1359 + 1360 + /* Save away PPR and DSCR soon so don't run with user values. */ 1361 + mfspr r31, SPRN_PPR 1362 + HMT_MEDIUM 1363 + mfspr r30, SPRN_DSCR 1364 + ld r29, HSTATE_DSCR(r13) 1365 + mtspr SPRN_DSCR, r29 1366 + 1367 + /* Save all but r9, r13 & r29-r31 */ 1368 + reg = 0 1369 + .rept 29 1370 + .if (reg != 9) && (reg != 13) 1371 + std reg, VCPU_GPRS_TM(reg)(r9) 1372 + .endif 1373 + reg = reg + 1 1374 + .endr 1375 + /* ... now save r13 */ 1376 + GET_SCRATCH0(r4) 1377 + std r4, VCPU_GPRS_TM(13)(r9) 1378 + /* ... and save r9 */ 1379 + ld r4, PACATMSCRATCH(r13) 1380 + std r4, VCPU_GPRS_TM(9)(r9) 1381 + 1382 + /* Reload stack pointer and TOC. */ 1383 + ld r1, HSTATE_HOST_R1(r13) 1384 + ld r2, PACATOC(r13) 1385 + 1386 + /* Set MSR RI now we have r1 and r13 back. */ 1387 + li r5, MSR_RI 1388 + mtmsrd r5, 1 1389 + 1390 + /* Save away checkpinted SPRs. */ 1391 + std r31, VCPU_PPR_TM(r9) 1392 + std r30, VCPU_DSCR_TM(r9) 1393 + mflr r5 1394 + mfcr r6 1395 + mfctr r7 1396 + mfspr r8, SPRN_AMR 1397 + mfspr r10, SPRN_TAR 1398 + std r5, VCPU_LR_TM(r9) 1399 + stw r6, VCPU_CR_TM(r9) 1400 + std r7, VCPU_CTR_TM(r9) 1401 + std r8, VCPU_AMR_TM(r9) 1402 + std r10, VCPU_TAR_TM(r9) 1403 + 1404 + /* Restore r12 as trap number. */ 1405 + lwz r12, VCPU_TRAP(r9) 1406 + 1407 + /* Save FP/VSX. */ 1408 + addi r3, r9, VCPU_FPRS_TM 1409 + bl .store_fp_state 1410 + addi r3, r9, VCPU_VRS_TM 1411 + bl .store_vr_state 1412 + mfspr r6, SPRN_VRSAVE 1413 + stw r6, VCPU_VRSAVE_TM(r9) 1414 + 1: 1415 + /* 1416 + * We need to save these SPRs after the treclaim so that the software 1417 + * error code is recorded correctly in the TEXASR. Also the user may 1418 + * change these outside of a transaction, so they must always be 1419 + * context switched. 1420 + */ 1421 + mfspr r5, SPRN_TFHAR 1422 + mfspr r6, SPRN_TFIAR 1423 + mfspr r7, SPRN_TEXASR 1424 + std r5, VCPU_TFHAR(r9) 1425 + std r6, VCPU_TFIAR(r9) 1426 + std r7, VCPU_TEXASR(r9) 1427 + 2: 1428 + #endif 1429 + 1326 1430 /* Increment yield count if they have a VPA */ 1327 1431 ld r8, VCPU_VPA(r9) /* do they have a VPA? */ 1328 1432 cmpdi r8, 0
+3 -3
arch/powerpc/kvm/book3s_pr.c
··· 1153 1153 goto free_vcpu; 1154 1154 vcpu->arch.book3s = vcpu_book3s; 1155 1155 1156 - #ifdef CONFIG_KVM_BOOK3S_32 1156 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 1157 1157 vcpu->arch.shadow_vcpu = 1158 1158 kzalloc(sizeof(*vcpu->arch.shadow_vcpu), GFP_KERNEL); 1159 1159 if (!vcpu->arch.shadow_vcpu) ··· 1198 1198 uninit_vcpu: 1199 1199 kvm_vcpu_uninit(vcpu); 1200 1200 free_shadow_vcpu: 1201 - #ifdef CONFIG_KVM_BOOK3S_32 1201 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 1202 1202 kfree(vcpu->arch.shadow_vcpu); 1203 1203 free_vcpu3s: 1204 1204 #endif ··· 1215 1215 1216 1216 free_page((unsigned long)vcpu->arch.shared & PAGE_MASK); 1217 1217 kvm_vcpu_uninit(vcpu); 1218 - #ifdef CONFIG_KVM_BOOK3S_32 1218 + #ifdef CONFIG_KVM_BOOK3S_32_HANDLER 1219 1219 kfree(vcpu->arch.shadow_vcpu); 1220 1220 #endif 1221 1221 vfree(vcpu_book3s);
+4
arch/powerpc/mm/hash_utils_64.c
··· 207 207 if (overlaps_kernel_text(vaddr, vaddr + step)) 208 208 tprot &= ~HPTE_R_N; 209 209 210 + /* Make kvm guest trampolines executable */ 211 + if (overlaps_kvm_tmp(vaddr, vaddr + step)) 212 + tprot &= ~HPTE_R_N; 213 + 210 214 /* 211 215 * If relocatable, check if it overlaps interrupt vectors that 212 216 * are copied down to real 0. For relocatable kernel
+1
arch/s390/kvm/kvm-s390.c
··· 158 158 case KVM_CAP_ONE_REG: 159 159 case KVM_CAP_ENABLE_CAP: 160 160 case KVM_CAP_S390_CSS_SUPPORT: 161 + case KVM_CAP_IRQFD: 161 162 case KVM_CAP_IOEVENTFD: 162 163 case KVM_CAP_DEVICE_CTRL: 163 164 case KVM_CAP_ENABLE_CAP_VM:
+5 -2
arch/x86/kvm/vmx.c
··· 7778 7778 7779 7779 exec_control = vmcs12->pin_based_vm_exec_control; 7780 7780 exec_control |= vmcs_config.pin_based_exec_ctrl; 7781 - exec_control &= ~PIN_BASED_VMX_PREEMPTION_TIMER; 7781 + exec_control &= ~(PIN_BASED_VMX_PREEMPTION_TIMER | 7782 + PIN_BASED_POSTED_INTR); 7782 7783 vmcs_write32(PIN_BASED_VM_EXEC_CONTROL, exec_control); 7783 7784 7784 7785 vmx->nested.preemption_timer_expired = false; ··· 7816 7815 if (!vmx->rdtscp_enabled) 7817 7816 exec_control &= ~SECONDARY_EXEC_RDTSCP; 7818 7817 /* Take the following fields only from vmcs12 */ 7819 - exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES; 7818 + exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | 7819 + SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | 7820 + SECONDARY_EXEC_APIC_REGISTER_VIRT); 7820 7821 if (nested_cpu_has(vmcs12, 7821 7822 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)) 7822 7823 exec_control |= vmcs12->secondary_vm_exec_control;
+5 -1
arch/x86/kvm/x86.c
··· 106 106 static u32 tsc_tolerance_ppm = 250; 107 107 module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR); 108 108 109 + static bool backwards_tsc_observed = false; 110 + 109 111 #define KVM_NR_SHARED_MSRS 16 110 112 111 113 struct kvm_shared_msrs_global { ··· 1488 1486 &ka->master_kernel_ns, 1489 1487 &ka->master_cycle_now); 1490 1488 1491 - ka->use_master_clock = host_tsc_clocksource & vcpus_matched; 1489 + ka->use_master_clock = host_tsc_clocksource && vcpus_matched 1490 + && !backwards_tsc_observed; 1492 1491 1493 1492 if (ka->use_master_clock) 1494 1493 atomic_set(&kvm_guest_has_master_clock, 1); ··· 6948 6945 */ 6949 6946 if (backwards_tsc) { 6950 6947 u64 delta_cyc = max_tsc - local_tsc; 6948 + backwards_tsc_observed = true; 6951 6949 list_for_each_entry(kvm, &vm_list, vm_list) { 6952 6950 kvm_for_each_vcpu(i, vcpu, kvm) { 6953 6951 vcpu->arch.tsc_offset_adjustment += delta_cyc;