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:

- miscellaneous fixes for MIPS and s390

- one new kvm_stat for s390

- correctly disable VT-d posted interrupts with the rest of posted
interrupts

- "make randconfig" fix for x86 AMD

- off-by-one in irq route check (the "good" kind that errors out a bit
too early!)

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
kvm: vmx: check apicv is active before using VT-d posted interrupt
kvm: Fix irq route entries exceeding KVM_MAX_IRQ_ROUTES
kvm: svm: Do not support AVIC if not CONFIG_X86_LOCAL_APIC
kvm: svm: Fix implicit declaration for __default_cpu_present_to_apicid()
MIPS: KVM: Fix CACHE triggered exception emulation
MIPS: KVM: Don't unwind PC when emulating CACHE
MIPS: KVM: Include bit 31 in segment matches
MIPS: KVM: Fix modular KVM under QEMU
KVM: s390: Add stats for PEI events
KVM: s390: ignore IBC if zero

+67 -23
+2 -1
arch/mips/include/asm/kvm_host.h
··· 74 74 #define KVM_GUEST_KUSEG 0x00000000UL 75 75 #define KVM_GUEST_KSEG0 0x40000000UL 76 76 #define KVM_GUEST_KSEG23 0x60000000UL 77 - #define KVM_GUEST_KSEGX(a) ((_ACAST32_(a)) & 0x60000000) 77 + #define KVM_GUEST_KSEGX(a) ((_ACAST32_(a)) & 0xe0000000) 78 78 #define KVM_GUEST_CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff) 79 79 80 80 #define KVM_GUEST_CKSEG0ADDR(a) (KVM_GUEST_CPHYSADDR(a) | KVM_GUEST_KSEG0) ··· 338 338 #define KVM_MIPS_GUEST_TLB_SIZE 64 339 339 struct kvm_vcpu_arch { 340 340 void *host_ebase, *guest_ebase; 341 + int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu); 341 342 unsigned long host_stack; 342 343 unsigned long host_gp; 343 344
+13 -6
arch/mips/kvm/emulate.c
··· 1636 1636 if (index < 0) { 1637 1637 vcpu->arch.host_cp0_entryhi = (va & VPN2_MASK); 1638 1638 vcpu->arch.host_cp0_badvaddr = va; 1639 + vcpu->arch.pc = curr_pc; 1639 1640 er = kvm_mips_emulate_tlbmiss_ld(cause, NULL, run, 1640 1641 vcpu); 1641 1642 preempt_enable(); ··· 1648 1647 * invalid exception to the guest 1649 1648 */ 1650 1649 if (!TLB_IS_VALID(*tlb, va)) { 1650 + vcpu->arch.host_cp0_badvaddr = va; 1651 + vcpu->arch.pc = curr_pc; 1651 1652 er = kvm_mips_emulate_tlbinv_ld(cause, NULL, 1652 1653 run, vcpu); 1653 1654 preempt_enable(); ··· 1669 1666 cache, op, base, arch->gprs[base], offset); 1670 1667 er = EMULATE_FAIL; 1671 1668 preempt_enable(); 1672 - goto dont_update_pc; 1669 + goto done; 1673 1670 1674 1671 } 1675 1672 ··· 1697 1694 kvm_err("NO-OP CACHE (cache: %#x, op: %#x, base[%d]: %#lx, offset: %#x\n", 1698 1695 cache, op, base, arch->gprs[base], offset); 1699 1696 er = EMULATE_FAIL; 1700 - preempt_enable(); 1701 - goto dont_update_pc; 1702 1697 } 1703 1698 1704 1699 preempt_enable(); 1700 + done: 1701 + /* Rollback PC only if emulation was unsuccessful */ 1702 + if (er == EMULATE_FAIL) 1703 + vcpu->arch.pc = curr_pc; 1705 1704 1706 1705 dont_update_pc: 1707 - /* Rollback PC */ 1708 - vcpu->arch.pc = curr_pc; 1709 - done: 1706 + /* 1707 + * This is for exceptions whose emulation updates the PC, so do not 1708 + * overwrite the PC under any circumstances 1709 + */ 1710 + 1710 1711 return er; 1711 1712 } 1712 1713
+1
arch/mips/kvm/interrupt.h
··· 28 28 #define MIPS_EXC_MAX 12 29 29 /* XXXSL More to follow */ 30 30 31 + extern char __kvm_mips_vcpu_run_end[]; 31 32 extern char mips32_exception[], mips32_exceptionEnd[]; 32 33 extern char mips32_GuestException[], mips32_GuestExceptionEnd[]; 33 34
+1
arch/mips/kvm/locore.S
··· 202 202 203 203 /* Jump to guest */ 204 204 eret 205 + EXPORT(__kvm_mips_vcpu_run_end) 205 206 206 207 VECTOR(MIPSX(exception), unknown) 207 208 /* Find out what mode we came from and jump to the proper handler. */
+10 -1
arch/mips/kvm/mips.c
··· 315 315 memcpy(gebase + offset, mips32_GuestException, 316 316 mips32_GuestExceptionEnd - mips32_GuestException); 317 317 318 + #ifdef MODULE 319 + offset += mips32_GuestExceptionEnd - mips32_GuestException; 320 + memcpy(gebase + offset, (char *)__kvm_mips_vcpu_run, 321 + __kvm_mips_vcpu_run_end - (char *)__kvm_mips_vcpu_run); 322 + vcpu->arch.vcpu_run = gebase + offset; 323 + #else 324 + vcpu->arch.vcpu_run = __kvm_mips_vcpu_run; 325 + #endif 326 + 318 327 /* Invalidate the icache for these ranges */ 319 328 local_flush_icache_range((unsigned long)gebase, 320 329 (unsigned long)gebase + ALIGN(size, PAGE_SIZE)); ··· 413 404 /* Disable hardware page table walking while in guest */ 414 405 htw_stop(); 415 406 416 - r = __kvm_mips_vcpu_run(run, vcpu); 407 + r = vcpu->arch.vcpu_run(run, vcpu); 417 408 418 409 /* Re-enable HTW before enabling interrupts */ 419 410 htw_start();
+1
arch/s390/include/asm/kvm_host.h
··· 245 245 u32 exit_stop_request; 246 246 u32 exit_validity; 247 247 u32 exit_instruction; 248 + u32 exit_pei; 248 249 u32 halt_successful_poll; 249 250 u32 halt_attempted_poll; 250 251 u32 halt_poll_invalid;
+2
arch/s390/kvm/intercept.c
··· 341 341 342 342 static int handle_partial_execution(struct kvm_vcpu *vcpu) 343 343 { 344 + vcpu->stat.exit_pei++; 345 + 344 346 if (vcpu->arch.sie_block->ipa == 0xb254) /* MVPG */ 345 347 return handle_mvpg_pei(vcpu); 346 348 if (vcpu->arch.sie_block->ipa >> 8 == 0xae) /* SIGP */
+2 -1
arch/s390/kvm/kvm-s390.c
··· 61 61 { "exit_external_request", VCPU_STAT(exit_external_request) }, 62 62 { "exit_external_interrupt", VCPU_STAT(exit_external_interrupt) }, 63 63 { "exit_instruction", VCPU_STAT(exit_instruction) }, 64 + { "exit_pei", VCPU_STAT(exit_pei) }, 64 65 { "exit_program_interruption", VCPU_STAT(exit_program_interruption) }, 65 66 { "exit_instr_and_program_int", VCPU_STAT(exit_instr_and_program) }, 66 67 { "halt_successful_poll", VCPU_STAT(halt_successful_poll) }, ··· 658 657 kvm->arch.model.cpuid = proc->cpuid; 659 658 lowest_ibc = sclp.ibc >> 16 & 0xfff; 660 659 unblocked_ibc = sclp.ibc & 0xfff; 661 - if (lowest_ibc) { 660 + if (lowest_ibc && proc->ibc) { 662 661 if (proc->ibc > unblocked_ibc) 663 662 kvm->arch.model.ibc = unblocked_ibc; 664 663 else if (proc->ibc < lowest_ibc)
+11
arch/x86/include/asm/kvm_host.h
··· 27 27 #include <linux/irqbypass.h> 28 28 #include <linux/hyperv.h> 29 29 30 + #include <asm/apic.h> 30 31 #include <asm/pvclock-abi.h> 31 32 #include <asm/desc.h> 32 33 #include <asm/mtrr.h> ··· 1368 1367 } 1369 1368 1370 1369 static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {} 1370 + 1371 + static inline int kvm_cpu_get_apicid(int mps_cpu) 1372 + { 1373 + #ifdef CONFIG_X86_LOCAL_APIC 1374 + return __default_cpu_present_to_apicid(mps_cpu); 1375 + #else 1376 + WARN_ON_ONCE(1); 1377 + return BAD_APICID; 1378 + #endif 1379 + } 1371 1380 1372 1381 #endif /* _ASM_X86_KVM_HOST_H */
+13 -8
arch/x86/kvm/svm.c
··· 238 238 239 239 /* enable / disable AVIC */ 240 240 static int avic; 241 + #ifdef CONFIG_X86_LOCAL_APIC 241 242 module_param(avic, int, S_IRUGO); 243 + #endif 242 244 243 245 static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); 244 246 static void svm_flush_tlb(struct kvm_vcpu *vcpu); ··· 983 981 } else 984 982 kvm_disable_tdp(); 985 983 986 - if (avic && (!npt_enabled || !boot_cpu_has(X86_FEATURE_AVIC))) 987 - avic = false; 988 - 989 - if (avic) 990 - pr_info("AVIC enabled\n"); 984 + if (avic) { 985 + if (!npt_enabled || 986 + !boot_cpu_has(X86_FEATURE_AVIC) || 987 + !IS_ENABLED(CONFIG_X86_LOCAL_APIC)) 988 + avic = false; 989 + else 990 + pr_info("AVIC enabled\n"); 991 + } 991 992 992 993 return 0; 993 994 ··· 1329 1324 static void avic_set_running(struct kvm_vcpu *vcpu, bool is_run) 1330 1325 { 1331 1326 u64 entry; 1332 - int h_physical_id = __default_cpu_present_to_apicid(vcpu->cpu); 1327 + int h_physical_id = kvm_cpu_get_apicid(vcpu->cpu); 1333 1328 struct vcpu_svm *svm = to_svm(vcpu); 1334 1329 1335 1330 if (!kvm_vcpu_apicv_active(vcpu)) ··· 1354 1349 { 1355 1350 u64 entry; 1356 1351 /* ID = 0xff (broadcast), ID > 0xff (reserved) */ 1357 - int h_physical_id = __default_cpu_present_to_apicid(cpu); 1352 + int h_physical_id = kvm_cpu_get_apicid(cpu); 1358 1353 struct vcpu_svm *svm = to_svm(vcpu); 1359 1354 1360 1355 if (!kvm_vcpu_apicv_active(vcpu)) ··· 4241 4236 4242 4237 if (avic_vcpu_is_running(vcpu)) 4243 4238 wrmsrl(SVM_AVIC_DOORBELL, 4244 - __default_cpu_present_to_apicid(vcpu->cpu)); 4239 + kvm_cpu_get_apicid(vcpu->cpu)); 4245 4240 else 4246 4241 kvm_vcpu_wake_up(vcpu); 4247 4242 }
+10 -5
arch/x86/kvm/vmx.c
··· 2072 2072 unsigned int dest; 2073 2073 2074 2074 if (!kvm_arch_has_assigned_device(vcpu->kvm) || 2075 - !irq_remapping_cap(IRQ_POSTING_CAP)) 2075 + !irq_remapping_cap(IRQ_POSTING_CAP) || 2076 + !kvm_vcpu_apicv_active(vcpu)) 2076 2077 return; 2077 2078 2078 2079 do { ··· 2181 2180 struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); 2182 2181 2183 2182 if (!kvm_arch_has_assigned_device(vcpu->kvm) || 2184 - !irq_remapping_cap(IRQ_POSTING_CAP)) 2183 + !irq_remapping_cap(IRQ_POSTING_CAP) || 2184 + !kvm_vcpu_apicv_active(vcpu)) 2185 2185 return; 2186 2186 2187 2187 /* Set SN when the vCPU is preempted */ ··· 10716 10714 struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); 10717 10715 10718 10716 if (!kvm_arch_has_assigned_device(vcpu->kvm) || 10719 - !irq_remapping_cap(IRQ_POSTING_CAP)) 10717 + !irq_remapping_cap(IRQ_POSTING_CAP) || 10718 + !kvm_vcpu_apicv_active(vcpu)) 10720 10719 return 0; 10721 10720 10722 10721 vcpu->pre_pcpu = vcpu->cpu; ··· 10783 10780 unsigned long flags; 10784 10781 10785 10782 if (!kvm_arch_has_assigned_device(vcpu->kvm) || 10786 - !irq_remapping_cap(IRQ_POSTING_CAP)) 10783 + !irq_remapping_cap(IRQ_POSTING_CAP) || 10784 + !kvm_vcpu_apicv_active(vcpu)) 10787 10785 return; 10788 10786 10789 10787 do { ··· 10837 10833 int idx, ret = -EINVAL; 10838 10834 10839 10835 if (!kvm_arch_has_assigned_device(kvm) || 10840 - !irq_remapping_cap(IRQ_POSTING_CAP)) 10836 + !irq_remapping_cap(IRQ_POSTING_CAP) || 10837 + !kvm_vcpu_apicv_active(kvm->vcpus[0])) 10841 10838 return 0; 10842 10839 10843 10840 idx = srcu_read_lock(&kvm->irq_srcu);
+1 -1
virt/kvm/kvm_main.c
··· 2941 2941 if (copy_from_user(&routing, argp, sizeof(routing))) 2942 2942 goto out; 2943 2943 r = -EINVAL; 2944 - if (routing.nr >= KVM_MAX_IRQ_ROUTES) 2944 + if (routing.nr > KVM_MAX_IRQ_ROUTES) 2945 2945 goto out; 2946 2946 if (routing.flags) 2947 2947 goto out;