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:
"Bugfixes, a pvspinlock optimization, and documentation moving"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: X86: Boost queue head vCPU to mitigate lock waiter preemption
Documentation: move Documentation/virtual to Documentation/virt
KVM: nVMX: Set cached_vmcs12 and cached_shadow_vmcs12 NULL after free
KVM: X86: Dynamically allocate user_fpu
KVM: X86: Fix fpu state crash in kvm guest
Revert "kvm: x86: Use task structs fpu field for user"
KVM: nVMX: Clear pending KVM_REQ_GET_VMCS12_PAGES when leaving nested

+61 -30
+1 -1
Documentation/admin-guide/kernel-parameters.txt
··· 2545 2545 mem_encrypt=on: Activate SME 2546 2546 mem_encrypt=off: Do not activate SME 2547 2547 2548 - Refer to Documentation/virtual/kvm/amd-memory-encryption.rst 2548 + Refer to Documentation/virt/kvm/amd-memory-encryption.rst 2549 2549 for details on when memory encryption can be activated. 2550 2550 2551 2551 mem_sleep_default= [SUSPEND] Default system suspend mode:
Documentation/virtual/index.rst Documentation/virt/index.rst
Documentation/virtual/kvm/amd-memory-encryption.rst Documentation/virt/kvm/amd-memory-encryption.rst
+1 -1
Documentation/virtual/kvm/api.txt Documentation/virt/kvm/api.txt
··· 3781 3781 3782 3782 Currently, this ioctl is used for issuing Secure Encrypted Virtualization 3783 3783 (SEV) commands on AMD Processors. The SEV commands are defined in 3784 - Documentation/virtual/kvm/amd-memory-encryption.rst. 3784 + Documentation/virt/kvm/amd-memory-encryption.rst. 3785 3785 3786 3786 4.111 KVM_MEMORY_ENCRYPT_REG_REGION 3787 3787
Documentation/virtual/kvm/arm/hyp-abi.txt Documentation/virt/kvm/arm/hyp-abi.txt
Documentation/virtual/kvm/arm/psci.txt Documentation/virt/kvm/arm/psci.txt
Documentation/virtual/kvm/cpuid.rst Documentation/virt/kvm/cpuid.rst
Documentation/virtual/kvm/devices/README Documentation/virt/kvm/devices/README
Documentation/virtual/kvm/devices/arm-vgic-its.txt Documentation/virt/kvm/devices/arm-vgic-its.txt
Documentation/virtual/kvm/devices/arm-vgic-v3.txt Documentation/virt/kvm/devices/arm-vgic-v3.txt
Documentation/virtual/kvm/devices/arm-vgic.txt Documentation/virt/kvm/devices/arm-vgic.txt
Documentation/virtual/kvm/devices/mpic.txt Documentation/virt/kvm/devices/mpic.txt
Documentation/virtual/kvm/devices/s390_flic.txt Documentation/virt/kvm/devices/s390_flic.txt
Documentation/virtual/kvm/devices/vcpu.txt Documentation/virt/kvm/devices/vcpu.txt
Documentation/virtual/kvm/devices/vfio.txt Documentation/virt/kvm/devices/vfio.txt
Documentation/virtual/kvm/devices/vm.txt Documentation/virt/kvm/devices/vm.txt
Documentation/virtual/kvm/devices/xics.txt Documentation/virt/kvm/devices/xics.txt
Documentation/virtual/kvm/devices/xive.txt Documentation/virt/kvm/devices/xive.txt
Documentation/virtual/kvm/halt-polling.txt Documentation/virt/kvm/halt-polling.txt
+2 -2
Documentation/virtual/kvm/hypercalls.txt Documentation/virt/kvm/hypercalls.txt
··· 18 18 number in R1. 19 19 20 20 For further information on the S390 diagnose call as supported by KVM, 21 - refer to Documentation/virtual/kvm/s390-diag.txt. 21 + refer to Documentation/virt/kvm/s390-diag.txt. 22 22 23 23 PowerPC: 24 24 It uses R3-R10 and hypercall number in R11. R4-R11 are used as output registers. ··· 26 26 27 27 KVM hypercalls uses 4 byte opcode, that are patched with 'hypercall-instructions' 28 28 property inside the device tree's /hypervisor node. 29 - For more information refer to Documentation/virtual/kvm/ppc-pv.txt 29 + For more information refer to Documentation/virt/kvm/ppc-pv.txt 30 30 31 31 MIPS: 32 32 KVM hypercalls use the HYPCALL instruction with code 0 and the hypercall
Documentation/virtual/kvm/index.rst Documentation/virt/kvm/index.rst
Documentation/virtual/kvm/locking.txt Documentation/virt/kvm/locking.txt
+1 -1
Documentation/virtual/kvm/mmu.txt Documentation/virt/kvm/mmu.txt
··· 298 298 vcpu->arch.mmio_gfn, and call the emulator 299 299 - If both P bit and R/W bit of error code are set, this could possibly 300 300 be handled as a "fast page fault" (fixed without taking the MMU lock). See 301 - the description in Documentation/virtual/kvm/locking.txt. 301 + the description in Documentation/virt/kvm/locking.txt. 302 302 - if needed, walk the guest page tables to determine the guest translation 303 303 (gva->gpa or ngpa->gpa) 304 304 - if permissions are insufficient, reflect the fault back to the guest
Documentation/virtual/kvm/msr.txt Documentation/virt/kvm/msr.txt
Documentation/virtual/kvm/nested-vmx.txt Documentation/virt/kvm/nested-vmx.txt
Documentation/virtual/kvm/ppc-pv.txt Documentation/virt/kvm/ppc-pv.txt
+1 -1
Documentation/virtual/kvm/review-checklist.txt Documentation/virt/kvm/review-checklist.txt
··· 7 7 2. Patches should be against kvm.git master branch. 8 8 9 9 3. If the patch introduces or modifies a new userspace API: 10 - - the API must be documented in Documentation/virtual/kvm/api.txt 10 + - the API must be documented in Documentation/virt/kvm/api.txt 11 11 - the API must be discoverable using KVM_CHECK_EXTENSION 12 12 13 13 4. New state must include support for save/restore.
Documentation/virtual/kvm/s390-diag.txt Documentation/virt/kvm/s390-diag.txt
Documentation/virtual/kvm/timekeeping.txt Documentation/virt/kvm/timekeeping.txt
Documentation/virtual/kvm/vcpu-requests.rst Documentation/virt/kvm/vcpu-requests.rst
Documentation/virtual/paravirt_ops.rst Documentation/virt/paravirt_ops.rst
Documentation/virtual/uml/UserModeLinux-HOWTO.txt Documentation/virt/uml/UserModeLinux-HOWTO.txt
+3 -3
MAINTAINERS
··· 8808 8808 W: http://www.linux-kvm.org 8809 8809 T: git git://git.kernel.org/pub/scm/virt/kvm/kvm.git 8810 8810 S: Supported 8811 - F: Documentation/virtual/kvm/ 8811 + F: Documentation/virt/kvm/ 8812 8812 F: include/trace/events/kvm.h 8813 8813 F: include/uapi/asm-generic/kvm* 8814 8814 F: include/uapi/linux/kvm* ··· 12137 12137 M: "VMware, Inc." <pv-drivers@vmware.com> 12138 12138 L: virtualization@lists.linux-foundation.org 12139 12139 S: Supported 12140 - F: Documentation/virtual/paravirt_ops.txt 12140 + F: Documentation/virt/paravirt_ops.txt 12141 12141 F: arch/*/kernel/paravirt* 12142 12142 F: arch/*/include/asm/paravirt*.h 12143 12143 F: include/linux/hypervisor.h ··· 16854 16854 Q: https://patchwork.ozlabs.org/project/linux-um/list/ 16855 16855 T: git git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git 16856 16856 S: Maintained 16857 - F: Documentation/virtual/uml/ 16857 + F: Documentation/virt/uml/ 16858 16858 F: arch/um/ 16859 16859 F: arch/x86/um/ 16860 16860 F: fs/hostfs/
+1 -1
arch/powerpc/include/uapi/asm/kvm_para.h
··· 31 31 * Struct fields are always 32 or 64 bit aligned, depending on them being 32 32 32 * or 64 bit wide respectively. 33 33 * 34 - * See Documentation/virtual/kvm/ppc-pv.txt 34 + * See Documentation/virt/kvm/ppc-pv.txt 35 35 */ 36 36 struct kvm_vcpu_arch_shared { 37 37 __u64 scratch1;
+4 -3
arch/x86/include/asm/kvm_host.h
··· 607 607 608 608 /* 609 609 * QEMU userspace and the guest each have their own FPU state. 610 - * In vcpu_run, we switch between the user, maintained in the 611 - * task_struct struct, and guest FPU contexts. While running a VCPU, 612 - * the VCPU thread will have the guest FPU context. 610 + * In vcpu_run, we switch between the user and guest FPU contexts. 611 + * While running a VCPU, the VCPU thread will have the guest FPU 612 + * context. 613 613 * 614 614 * Note that while the PKRU state lives inside the fpu registers, 615 615 * it is switched out separately at VMENTER and VMEXIT time. The 616 616 * "guest_fpu" state here contains the guest FPU context, with the 617 617 * host PRKU bits. 618 618 */ 619 + struct fpu *user_fpu; 619 620 struct fpu *guest_fpu; 620 621 621 622 u64 xcr0;
+1 -1
arch/x86/kvm/mmu.c
··· 3466 3466 /* 3467 3467 * Currently, fast page fault only works for direct mapping 3468 3468 * since the gfn is not stable for indirect shadow page. See 3469 - * Documentation/virtual/kvm/locking.txt to get more detail. 3469 + * Documentation/virt/kvm/locking.txt to get more detail. 3470 3470 */ 3471 3471 fault_handled = fast_pf_fix_direct_spte(vcpu, sp, 3472 3472 iterator.sptep, spte,
+12 -1
arch/x86/kvm/svm.c
··· 2143 2143 goto out; 2144 2144 } 2145 2145 2146 + svm->vcpu.arch.user_fpu = kmem_cache_zalloc(x86_fpu_cache, 2147 + GFP_KERNEL_ACCOUNT); 2148 + if (!svm->vcpu.arch.user_fpu) { 2149 + printk(KERN_ERR "kvm: failed to allocate kvm userspace's fpu\n"); 2150 + err = -ENOMEM; 2151 + goto free_partial_svm; 2152 + } 2153 + 2146 2154 svm->vcpu.arch.guest_fpu = kmem_cache_zalloc(x86_fpu_cache, 2147 2155 GFP_KERNEL_ACCOUNT); 2148 2156 if (!svm->vcpu.arch.guest_fpu) { 2149 2157 printk(KERN_ERR "kvm: failed to allocate vcpu's fpu\n"); 2150 2158 err = -ENOMEM; 2151 - goto free_partial_svm; 2159 + goto free_user_fpu; 2152 2160 } 2153 2161 2154 2162 err = kvm_vcpu_init(&svm->vcpu, kvm, id); ··· 2219 2211 kvm_vcpu_uninit(&svm->vcpu); 2220 2212 free_svm: 2221 2213 kmem_cache_free(x86_fpu_cache, svm->vcpu.arch.guest_fpu); 2214 + free_user_fpu: 2215 + kmem_cache_free(x86_fpu_cache, svm->vcpu.arch.user_fpu); 2222 2216 free_partial_svm: 2223 2217 kmem_cache_free(kvm_vcpu_cache, svm); 2224 2218 out: ··· 2251 2241 __free_page(virt_to_page(svm->nested.hsave)); 2252 2242 __free_pages(virt_to_page(svm->nested.msrpm), MSRPM_ALLOC_ORDER); 2253 2243 kvm_vcpu_uninit(vcpu); 2244 + kmem_cache_free(x86_fpu_cache, svm->vcpu.arch.user_fpu); 2254 2245 kmem_cache_free(x86_fpu_cache, svm->vcpu.arch.guest_fpu); 2255 2246 kmem_cache_free(kvm_vcpu_cache, svm); 2256 2247 }
+4
arch/x86/kvm/vmx/nested.c
··· 220 220 if (!vmx->nested.vmxon && !vmx->nested.smm.vmxon) 221 221 return; 222 222 223 + kvm_clear_request(KVM_REQ_GET_VMCS12_PAGES, vcpu); 224 + 223 225 vmx->nested.vmxon = false; 224 226 vmx->nested.smm.vmxon = false; 225 227 free_vpid(vmx->nested.vpid02); ··· 234 232 vmx->vmcs01.shadow_vmcs = NULL; 235 233 } 236 234 kfree(vmx->nested.cached_vmcs12); 235 + vmx->nested.cached_vmcs12 = NULL; 237 236 kfree(vmx->nested.cached_shadow_vmcs12); 237 + vmx->nested.cached_shadow_vmcs12 = NULL; 238 238 /* Unpin physical memory we referred to in the vmcs02 */ 239 239 if (vmx->nested.apic_access_page) { 240 240 kvm_release_page_dirty(vmx->nested.apic_access_page);
+12 -1
arch/x86/kvm/vmx/vmx.c
··· 6598 6598 free_loaded_vmcs(vmx->loaded_vmcs); 6599 6599 kfree(vmx->guest_msrs); 6600 6600 kvm_vcpu_uninit(vcpu); 6601 + kmem_cache_free(x86_fpu_cache, vmx->vcpu.arch.user_fpu); 6601 6602 kmem_cache_free(x86_fpu_cache, vmx->vcpu.arch.guest_fpu); 6602 6603 kmem_cache_free(kvm_vcpu_cache, vmx); 6603 6604 } ··· 6614 6613 if (!vmx) 6615 6614 return ERR_PTR(-ENOMEM); 6616 6615 6616 + vmx->vcpu.arch.user_fpu = kmem_cache_zalloc(x86_fpu_cache, 6617 + GFP_KERNEL_ACCOUNT); 6618 + if (!vmx->vcpu.arch.user_fpu) { 6619 + printk(KERN_ERR "kvm: failed to allocate kvm userspace's fpu\n"); 6620 + err = -ENOMEM; 6621 + goto free_partial_vcpu; 6622 + } 6623 + 6617 6624 vmx->vcpu.arch.guest_fpu = kmem_cache_zalloc(x86_fpu_cache, 6618 6625 GFP_KERNEL_ACCOUNT); 6619 6626 if (!vmx->vcpu.arch.guest_fpu) { 6620 6627 printk(KERN_ERR "kvm: failed to allocate vcpu's fpu\n"); 6621 6628 err = -ENOMEM; 6622 - goto free_partial_vcpu; 6629 + goto free_user_fpu; 6623 6630 } 6624 6631 6625 6632 vmx->vpid = allocate_vpid(); ··· 6730 6721 free_vcpu: 6731 6722 free_vpid(vmx->vpid); 6732 6723 kmem_cache_free(x86_fpu_cache, vmx->vcpu.arch.guest_fpu); 6724 + free_user_fpu: 6725 + kmem_cache_free(x86_fpu_cache, vmx->vcpu.arch.user_fpu); 6733 6726 free_partial_vcpu: 6734 6727 kmem_cache_free(kvm_vcpu_cache, vmx); 6735 6728 return ERR_PTR(err);
+10 -6
arch/x86/kvm/x86.c
··· 3306 3306 3307 3307 kvm_x86_ops->vcpu_load(vcpu, cpu); 3308 3308 3309 + fpregs_assert_state_consistent(); 3310 + if (test_thread_flag(TIF_NEED_FPU_LOAD)) 3311 + switch_fpu_return(); 3312 + 3309 3313 /* Apply any externally detected TSC adjustments (due to suspend) */ 3310 3314 if (unlikely(vcpu->arch.tsc_offset_adjustment)) { 3311 3315 adjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment); ··· 7206 7202 7207 7203 rcu_read_unlock(); 7208 7204 7209 - if (target) 7205 + if (target && READ_ONCE(target->ready)) 7210 7206 kvm_vcpu_yield_to(target); 7211 7207 } 7212 7208 ··· 7246 7242 break; 7247 7243 case KVM_HC_KICK_CPU: 7248 7244 kvm_pv_kick_cpu_op(vcpu->kvm, a0, a1); 7245 + kvm_sched_yield(vcpu->kvm, a1); 7249 7246 ret = 0; 7250 7247 break; 7251 7248 #ifdef CONFIG_X86_64 ··· 7995 7990 trace_kvm_entry(vcpu->vcpu_id); 7996 7991 guest_enter_irqoff(); 7997 7992 7998 - fpregs_assert_state_consistent(); 7999 - if (test_thread_flag(TIF_NEED_FPU_LOAD)) 8000 - switch_fpu_return(); 7993 + /* The preempt notifier should have taken care of the FPU already. */ 7994 + WARN_ON_ONCE(test_thread_flag(TIF_NEED_FPU_LOAD)); 8001 7995 8002 7996 if (unlikely(vcpu->arch.switch_db_regs)) { 8003 7997 set_debugreg(0, 7); ··· 8274 8270 { 8275 8271 fpregs_lock(); 8276 8272 8277 - copy_fpregs_to_fpstate(&current->thread.fpu); 8273 + copy_fpregs_to_fpstate(vcpu->arch.user_fpu); 8278 8274 /* PKRU is separately restored in kvm_x86_ops->run. */ 8279 8275 __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu->state, 8280 8276 ~XFEATURE_MASK_PKRU); ··· 8291 8287 fpregs_lock(); 8292 8288 8293 8289 copy_fpregs_to_fpstate(vcpu->arch.guest_fpu); 8294 - copy_kernel_to_fpregs(&current->thread.fpu.state); 8290 + copy_kernel_to_fpregs(&vcpu->arch.user_fpu->state); 8295 8291 8296 8292 fpregs_mark_activate(); 8297 8293 fpregs_unlock();
+2 -2
include/uapi/linux/kvm.h
··· 116 116 * ACPI gsi notion of irq. 117 117 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 118 118 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 119 - * For ARM: See Documentation/virtual/kvm/api.txt 119 + * For ARM: See Documentation/virt/kvm/api.txt 120 120 */ 121 121 union { 122 122 __u32 irq; ··· 1086 1086 * 1087 1087 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1088 1088 * the irqfd to operate in resampling mode for level triggered interrupt 1089 - * emulation. See Documentation/virtual/kvm/api.txt. 1089 + * emulation. See Documentation/virt/kvm/api.txt. 1090 1090 */ 1091 1091 #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 1092 1092
+2 -2
tools/include/uapi/linux/kvm.h
··· 116 116 * ACPI gsi notion of irq. 117 117 * For IA-64 (APIC model) IOAPIC0: irq 0-23; IOAPIC1: irq 24-47.. 118 118 * For X86 (standard AT mode) PIC0/1: irq 0-15. IOAPIC0: 0-23.. 119 - * For ARM: See Documentation/virtual/kvm/api.txt 119 + * For ARM: See Documentation/virt/kvm/api.txt 120 120 */ 121 121 union { 122 122 __u32 irq; ··· 1085 1085 * 1086 1086 * KVM_IRQFD_FLAG_RESAMPLE indicates resamplefd is valid and specifies 1087 1087 * the irqfd to operate in resampling mode for level triggered interrupt 1088 - * emulation. See Documentation/virtual/kvm/api.txt. 1088 + * emulation. See Documentation/virt/kvm/api.txt. 1089 1089 */ 1090 1090 #define KVM_IRQFD_FLAG_RESAMPLE (1 << 1) 1091 1091
+1 -1
virt/kvm/arm/arm.c
··· 727 727 * Ensure we set mode to IN_GUEST_MODE after we disable 728 728 * interrupts and before the final VCPU requests check. 729 729 * See the comment in kvm_vcpu_exiting_guest_mode() and 730 - * Documentation/virtual/kvm/vcpu-requests.rst 730 + * Documentation/virt/kvm/vcpu-requests.rst 731 731 */ 732 732 smp_store_mb(vcpu->mode, IN_GUEST_MODE); 733 733
+1 -1
virt/kvm/arm/vgic/vgic-mmio-v3.c
··· 250 250 * pending state of interrupt is latched in pending_latch variable. 251 251 * Userspace will save and restore pending state and line_level 252 252 * separately. 253 - * Refer to Documentation/virtual/kvm/devices/arm-vgic-v3.txt 253 + * Refer to Documentation/virt/kvm/devices/arm-vgic-v3.txt 254 254 * for handling of ISPENDR and ICPENDR. 255 255 */ 256 256 for (i = 0; i < len * 8; i++) {
+2 -2
virt/kvm/arm/vgic/vgic.h
··· 42 42 VGIC_AFFINITY_LEVEL(val, 3)) 43 43 44 44 /* 45 - * As per Documentation/virtual/kvm/devices/arm-vgic-v3.txt, 45 + * As per Documentation/virt/kvm/devices/arm-vgic-v3.txt, 46 46 * below macros are defined for CPUREG encoding. 47 47 */ 48 48 #define KVM_REG_ARM_VGIC_SYSREG_OP0_MASK 0x000000000000c000 ··· 63 63 KVM_REG_ARM_VGIC_SYSREG_OP2_MASK) 64 64 65 65 /* 66 - * As per Documentation/virtual/kvm/devices/arm-vgic-its.txt, 66 + * As per Documentation/virt/kvm/devices/arm-vgic-its.txt, 67 67 * below macros are defined for ITS table entry encoding. 68 68 */ 69 69 #define KVM_ITS_CTE_VALID_SHIFT 63