aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-27 12:21:00 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-27 12:21:00 -0500
commit1fc7f56db7a7c467e46a5d2e2a009d2f337e0338 (patch)
treed534b5627a7b9317f08bec84c1e8a0dfa0848cd8
parentc180f1b04be01d025aa1e6e53e1a8b6626bd90c4 (diff)
parentb2869f28e1476cd705bb28c58fd01b0bd661bb99 (diff)
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini: "Quite a few fixes for x86: nested virtualization save/restore, AMD nested virtualization and virtual APIC, 32-bit fixes, an important fix to restore operation on older processors, and a bunch of hyper-v bugfixes. Several are marked stable. There are also fixes for GCC warnings and for a GCC/objtool interaction" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: Mark expected switch fall-throughs KVM: x86: fix TRACE_INCLUDE_PATH and remove -I. header search paths KVM: selftests: check returned evmcs version range x86/kvm/hyper-v: nested_enable_evmcs() sets vmcs_version incorrectly KVM: VMX: Move vmx_vcpu_run()'s VM-Enter asm blob to a helper function kvm: selftests: Fix region overlap check in kvm_util kvm: vmx: fix some -Wmissing-prototypes warnings KVM: nSVM: clear events pending from svm_complete_interrupts() when exiting to L1 svm: Fix AVIC incomplete IPI emulation svm: Add warning message for AVIC IPI invalid target KVM: x86: WARN_ONCE if sending a PV IPI returns a fatal error KVM: x86: Fix PV IPIs for 32-bit KVM host x86/kvm/hyper-v: recommend using eVMCS only when it is enabled x86/kvm/hyper-v: don't recommend doing reset via synthetic MSR kvm: x86/vmx: Use kzalloc for cached_vmcs12 KVM: VMX: Use the correct field var when clearing VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL KVM: x86: Fix single-step debugging x86/kvm/hyper-v: don't announce GUEST IDLE MSR support
-rw-r--r--arch/x86/kernel/kvm.c7
-rw-r--r--arch/x86/kvm/Makefile4
-rw-r--r--arch/x86/kvm/hyperv.c7
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/kvm/mmu.c1
-rw-r--r--arch/x86/kvm/svm.c31
-rw-r--r--arch/x86/kvm/trace.h2
-rw-r--r--arch/x86/kvm/vmx/evmcs.c7
-rw-r--r--arch/x86/kvm/vmx/nested.c14
-rw-r--r--arch/x86/kvm/vmx/vmx.c147
-rw-r--r--arch/x86/kvm/x86.c8
-rw-r--r--tools/testing/selftests/kvm/lib/kvm_util.c9
-rw-r--r--tools/testing/selftests/kvm/x86_64/evmcs_test.c6
13 files changed, 130 insertions, 115 deletions
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index ba4bfb7f6a36..5c93a65ee1e5 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -457,6 +457,7 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
457#else 457#else
458 u64 ipi_bitmap = 0; 458 u64 ipi_bitmap = 0;
459#endif 459#endif
460 long ret;
460 461
461 if (cpumask_empty(mask)) 462 if (cpumask_empty(mask))
462 return; 463 return;
@@ -482,8 +483,9 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
482 } else if (apic_id < min + KVM_IPI_CLUSTER_SIZE) { 483 } else if (apic_id < min + KVM_IPI_CLUSTER_SIZE) {
483 max = apic_id < max ? max : apic_id; 484 max = apic_id < max ? max : apic_id;
484 } else { 485 } else {
485 kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap, 486 ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
486 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr); 487 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr);
488 WARN_ONCE(ret < 0, "KVM: failed to send PV IPI: %ld", ret);
487 min = max = apic_id; 489 min = max = apic_id;
488 ipi_bitmap = 0; 490 ipi_bitmap = 0;
489 } 491 }
@@ -491,8 +493,9 @@ static void __send_ipi_mask(const struct cpumask *mask, int vector)
491 } 493 }
492 494
493 if (ipi_bitmap) { 495 if (ipi_bitmap) {
494 kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap, 496 ret = kvm_hypercall4(KVM_HC_SEND_IPI, (unsigned long)ipi_bitmap,
495 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr); 497 (unsigned long)(ipi_bitmap >> BITS_PER_LONG), min, icr);
498 WARN_ONCE(ret < 0, "KVM: failed to send PV IPI: %ld", ret);
496 } 499 }
497 500
498 local_irq_restore(flags); 501 local_irq_restore(flags);
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile
index 69b3a7c30013..31ecf7a76d5a 100644
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -2,10 +2,6 @@
2 2
3ccflags-y += -Iarch/x86/kvm 3ccflags-y += -Iarch/x86/kvm
4 4
5CFLAGS_x86.o := -I.
6CFLAGS_svm.o := -I.
7CFLAGS_vmx.o := -I.
8
9KVM := ../../../virt/kvm 5KVM := ../../../virt/kvm
10 6
11kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \ 7kvm-y += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o \
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c90a5352d158..89d20ed1d2e8 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -1636,7 +1636,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
1636 ret = kvm_hvcall_signal_event(vcpu, fast, ingpa); 1636 ret = kvm_hvcall_signal_event(vcpu, fast, ingpa);
1637 if (ret != HV_STATUS_INVALID_PORT_ID) 1637 if (ret != HV_STATUS_INVALID_PORT_ID)
1638 break; 1638 break;
1639 /* maybe userspace knows this conn_id: fall through */ 1639 /* fall through - maybe userspace knows this conn_id. */
1640 case HVCALL_POST_MESSAGE: 1640 case HVCALL_POST_MESSAGE:
1641 /* don't bother userspace if it has no way to handle it */ 1641 /* don't bother userspace if it has no way to handle it */
1642 if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) { 1642 if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) {
@@ -1832,7 +1832,6 @@ int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
1832 ent->eax |= HV_X64_MSR_VP_INDEX_AVAILABLE; 1832 ent->eax |= HV_X64_MSR_VP_INDEX_AVAILABLE;
1833 ent->eax |= HV_X64_MSR_RESET_AVAILABLE; 1833 ent->eax |= HV_X64_MSR_RESET_AVAILABLE;
1834 ent->eax |= HV_MSR_REFERENCE_TSC_AVAILABLE; 1834 ent->eax |= HV_MSR_REFERENCE_TSC_AVAILABLE;
1835 ent->eax |= HV_X64_MSR_GUEST_IDLE_AVAILABLE;
1836 ent->eax |= HV_X64_ACCESS_FREQUENCY_MSRS; 1835 ent->eax |= HV_X64_ACCESS_FREQUENCY_MSRS;
1837 ent->eax |= HV_X64_ACCESS_REENLIGHTENMENT; 1836 ent->eax |= HV_X64_ACCESS_REENLIGHTENMENT;
1838 1837
@@ -1848,11 +1847,11 @@ int kvm_vcpu_ioctl_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid2 *cpuid,
1848 case HYPERV_CPUID_ENLIGHTMENT_INFO: 1847 case HYPERV_CPUID_ENLIGHTMENT_INFO:
1849 ent->eax |= HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED; 1848 ent->eax |= HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED;
1850 ent->eax |= HV_X64_APIC_ACCESS_RECOMMENDED; 1849 ent->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
1851 ent->eax |= HV_X64_SYSTEM_RESET_RECOMMENDED;
1852 ent->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED; 1850 ent->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
1853 ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED; 1851 ent->eax |= HV_X64_CLUSTER_IPI_RECOMMENDED;
1854 ent->eax |= HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED; 1852 ent->eax |= HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED;
1855 ent->eax |= HV_X64_ENLIGHTENED_VMCS_RECOMMENDED; 1853 if (evmcs_ver)
1854 ent->eax |= HV_X64_ENLIGHTENED_VMCS_RECOMMENDED;
1856 1855
1857 /* 1856 /*
1858 * Default number of spinlock retry attempts, matches 1857 * Default number of spinlock retry attempts, matches
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 9f089e2e09d0..4b6c2da7265c 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1035,6 +1035,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
1035 switch (delivery_mode) { 1035 switch (delivery_mode) {
1036 case APIC_DM_LOWEST: 1036 case APIC_DM_LOWEST:
1037 vcpu->arch.apic_arb_prio++; 1037 vcpu->arch.apic_arb_prio++;
1038 /* fall through */
1038 case APIC_DM_FIXED: 1039 case APIC_DM_FIXED:
1039 if (unlikely(trig_mode && !level)) 1040 if (unlikely(trig_mode && !level))
1040 break; 1041 break;
@@ -1874,6 +1875,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
1874 1875
1875 case APIC_LVT0: 1876 case APIC_LVT0:
1876 apic_manage_nmi_watchdog(apic, val); 1877 apic_manage_nmi_watchdog(apic, val);
1878 /* fall through */
1877 case APIC_LVTTHMR: 1879 case APIC_LVTTHMR:
1878 case APIC_LVTPC: 1880 case APIC_LVTPC:
1879 case APIC_LVT1: 1881 case APIC_LVT1:
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ce770b446238..da9c42349b1f 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -4371,6 +4371,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
4371 rsvd_bits(maxphyaddr, 51); 4371 rsvd_bits(maxphyaddr, 51);
4372 rsvd_check->rsvd_bits_mask[1][4] = 4372 rsvd_check->rsvd_bits_mask[1][4] =
4373 rsvd_check->rsvd_bits_mask[0][4]; 4373 rsvd_check->rsvd_bits_mask[0][4];
4374 /* fall through */
4374 case PT64_ROOT_4LEVEL: 4375 case PT64_ROOT_4LEVEL:
4375 rsvd_check->rsvd_bits_mask[0][3] = exb_bit_rsvd | 4376 rsvd_check->rsvd_bits_mask[0][3] = exb_bit_rsvd |
4376 nonleaf_bit8_rsvd | rsvd_bits(7, 7) | 4377 nonleaf_bit8_rsvd | rsvd_bits(7, 7) |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a157ca5b6869..f13a3a24d360 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3414,6 +3414,14 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
3414 kvm_mmu_reset_context(&svm->vcpu); 3414 kvm_mmu_reset_context(&svm->vcpu);
3415 kvm_mmu_load(&svm->vcpu); 3415 kvm_mmu_load(&svm->vcpu);
3416 3416
3417 /*
3418 * Drop what we picked up for L2 via svm_complete_interrupts() so it
3419 * doesn't end up in L1.
3420 */
3421 svm->vcpu.arch.nmi_injected = false;
3422 kvm_clear_exception_queue(&svm->vcpu);
3423 kvm_clear_interrupt_queue(&svm->vcpu);
3424
3417 return 0; 3425 return 0;
3418} 3426}
3419 3427
@@ -4395,7 +4403,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
4395 case MSR_IA32_APICBASE: 4403 case MSR_IA32_APICBASE:
4396 if (kvm_vcpu_apicv_active(vcpu)) 4404 if (kvm_vcpu_apicv_active(vcpu))
4397 avic_update_vapic_bar(to_svm(vcpu), data); 4405 avic_update_vapic_bar(to_svm(vcpu), data);
4398 /* Follow through */ 4406 /* Fall through */
4399 default: 4407 default:
4400 return kvm_set_msr_common(vcpu, msr); 4408 return kvm_set_msr_common(vcpu, msr);
4401 } 4409 }
@@ -4504,28 +4512,19 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm)
4504 kvm_lapic_reg_write(apic, APIC_ICR, icrl); 4512 kvm_lapic_reg_write(apic, APIC_ICR, icrl);
4505 break; 4513 break;
4506 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: { 4514 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: {
4507 int i;
4508 struct kvm_vcpu *vcpu;
4509 struct kvm *kvm = svm->vcpu.kvm;
4510 struct kvm_lapic *apic = svm->vcpu.arch.apic; 4515 struct kvm_lapic *apic = svm->vcpu.arch.apic;
4511 4516
4512 /* 4517 /*
4513 * At this point, we expect that the AVIC HW has already 4518 * Update ICR high and low, then emulate sending IPI,
4514 * set the appropriate IRR bits on the valid target 4519 * which is handled when writing APIC_ICR.