diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-05 19:16:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-05 19:16:00 -0400 |
commit | 541d8f4d59d79f5d37c8c726f723d42ff307db57 (patch) | |
tree | 94c0273fd120338be5942e03da3d529b19bd35f2 | |
parent | 5003bc6cc60ef700692da9bf4d3953aa0770d300 (diff) | |
parent | 95272c29378ee7dc15f43fa2758cb28a5913a06d (diff) |
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini:
"Miscellaneous bugfixes.
The ARM and s390 fixes are for new regressions from the merge window,
others are usual stable material"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
compiler-gcc: disable -ftracer for __noclone functions
kvm: x86: make lapic hrtimer pinned
s390/mm/kvm: fix mis-merge in gmap handling
kvm: set page dirty only if page has been writable
KVM: x86: reduce default value of halt_poll_ns parameter
KVM: Hyper-V: do not do hypercall userspace exits if SynIC is disabled
KVM: x86: Inject pending interrupt even if pending nmi exist
arm64: KVM: Register CPU notifiers when the kernel runs at HYP
arm64: kvm: 4.6-rc1: Fix VTCR_EL2 VS setting
-rw-r--r-- | arch/arm/kvm/arm.c | 52 | ||||
-rw-r--r-- | arch/arm64/include/asm/kvm_arm.h | 4 | ||||
-rw-r--r-- | arch/arm64/include/asm/sysreg.h | 3 | ||||
-rw-r--r-- | arch/arm64/kvm/hyp/s2-setup.c | 6 | ||||
-rw-r--r-- | arch/s390/mm/gmap.c | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 2 | ||||
-rw-r--r-- | arch/x86/kvm/hyperv.c | 5 | ||||
-rw-r--r-- | arch/x86/kvm/lapic.c | 8 | ||||
-rw-r--r-- | arch/x86/kvm/mmu.c | 12 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 20 | ||||
-rw-r--r-- | include/linux/compiler-gcc.h | 2 |
11 files changed, 76 insertions, 42 deletions
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 6accd66d26f0..b5384311dec4 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -1061,15 +1061,27 @@ static void cpu_init_hyp_mode(void *dummy) | |||
1061 | kvm_arm_init_debug(); | 1061 | kvm_arm_init_debug(); |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | static void cpu_hyp_reinit(void) | ||
1065 | { | ||
1066 | if (is_kernel_in_hyp_mode()) { | ||
1067 | /* | ||
1068 | * cpu_init_stage2() is safe to call even if the PM | ||
1069 | * event was cancelled before the CPU was reset. | ||
1070 | */ | ||
1071 | cpu_init_stage2(NULL); | ||
1072 | } else { | ||
1073 | if (__hyp_get_vectors() == hyp_default_vectors) | ||
1074 | cpu_init_hyp_mode(NULL); | ||
1075 | } | ||
1076 | } | ||
1077 | |||
1064 | static int hyp_init_cpu_notify(struct notifier_block *self, | 1078 | static int hyp_init_cpu_notify(struct notifier_block *self, |
1065 | unsigned long action, void *cpu) | 1079 | unsigned long action, void *cpu) |
1066 | { | 1080 | { |
1067 | switch (action) { | 1081 | switch (action) { |
1068 | case CPU_STARTING: | 1082 | case CPU_STARTING: |
1069 | case CPU_STARTING_FROZEN: | 1083 | case CPU_STARTING_FROZEN: |
1070 | if (__hyp_get_vectors() == hyp_default_vectors) | 1084 | cpu_hyp_reinit(); |
1071 | cpu_init_hyp_mode(NULL); | ||
1072 | break; | ||
1073 | } | 1085 | } |
1074 | 1086 | ||
1075 | return NOTIFY_OK; | 1087 | return NOTIFY_OK; |
@@ -1084,9 +1096,8 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self, | |||
1084 | unsigned long cmd, | 1096 | unsigned long cmd, |
1085 | void *v) | 1097 | void *v) |
1086 | { | 1098 | { |
1087 | if (cmd == CPU_PM_EXIT && | 1099 | if (cmd == CPU_PM_EXIT) { |
1088 | __hyp_get_vectors() == hyp_default_vectors) { | 1100 | cpu_hyp_reinit(); |
1089 | cpu_init_hyp_mode(NULL); | ||
1090 | return NOTIFY_OK; | 1101 | return NOTIFY_OK; |
1091 | } | 1102 | } |
1092 | 1103 | ||
@@ -1128,6 +1139,22 @@ static int init_subsystems(void) | |||
1128 | int err; | 1139 | int err; |
1129 | 1140 | ||
1130 | /* | 1141 | /* |
1142 | * Register CPU Hotplug notifier | ||
1143 | */ | ||
1144 | cpu_notifier_register_begin(); | ||
1145 | err = __register_cpu_notifier(&hyp_init_cpu_nb); | ||
1146 | cpu_notifier_register_done(); | ||
1147 | if (err) { | ||
1148 | kvm_err("Cannot register KVM init CPU notifier (%d)\n", err); | ||
1149 | return err; | ||
1150 | } | ||
1151 | |||
1152 | /* | ||
1153 | * Register CPU lower-power notifier | ||
1154 | */ | ||
1155 | hyp_cpu_pm_init(); | ||
1156 | |||
1157 | /* | ||
1131 | * Init HYP view of VGIC | 1158 | * Init HYP view of VGIC |
1132 | */ | 1159 | */ |
1133 | err = kvm_vgic_hyp_init(); | 1160 | err = kvm_vgic_hyp_init(); |
@@ -1270,19 +1297,6 @@ static int init_hyp_mode(void) | |||
1270 | free_boot_hyp_pgd(); | 1297 | free_boot_hyp_pgd(); |
1271 | #endif | 1298 | #endif |
1272 | 1299 | ||
1273 | cpu_notifier_register_begin(); | ||
1274 | |||
1275 | err = __register_cpu_notifier(&hyp_init_cpu_nb); | ||
1276 | |||
1277 | cpu_notifier_register_done(); | ||
1278 | |||
1279 | if (err) { | ||
1280 | kvm_err("Cannot register HYP init CPU notifier (%d)\n", err); | ||
1281 | goto out_err; | ||
1282 | } | ||
1283 | |||
1284 | hyp_cpu_pm_init(); | ||
1285 | |||
1286 | /* set size of VMID supported by CPU */ | 1300 | /* set size of VMID supported by CPU */ |
1287 | kvm_vmid_bits = kvm_get_vmid_bits(); | 1301 | kvm_vmid_bits = kvm_get_vmid_bits(); |
1288 | kvm_info("%d-bit VMID\n", kvm_vmid_bits); | 1302 | kvm_info("%d-bit VMID\n", kvm_vmid_bits); |
diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 0e391dbfc420..4150fd8bae01 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h | |||
@@ -124,7 +124,9 @@ | |||
124 | #define VTCR_EL2_SL0_LVL1 (1 << 6) | 124 | #define VTCR_EL2_SL0_LVL1 (1 << 6) |
125 | #define VTCR_EL2_T0SZ_MASK 0x3f | 125 | #define VTCR_EL2_T0SZ_MASK 0x3f |
126 | #define VTCR_EL2_T0SZ_40B 24 | 126 | #define VTCR_EL2_T0SZ_40B 24 |
127 | #define VTCR_EL2_VS 19 | 127 | #define VTCR_EL2_VS_SHIFT 19 |
128 | #define VTCR_EL2_VS_8BIT (0 << VTCR_EL2_VS_SHIFT) | ||
129 | #define VTCR_EL2_VS_16BIT (1 << VTCR_EL2_VS_SHIFT) | ||
128 | 130 | ||
129 | /* | 131 | /* |
130 | * We configure the Stage-2 page tables to always restrict the IPA space to be | 132 | * We configure the Stage-2 page tables to always restrict the IPA space to be |
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 1a78d6e2a78b..12874164b0ae 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h | |||
@@ -141,6 +141,9 @@ | |||
141 | #define ID_AA64MMFR1_VMIDBITS_SHIFT 4 | 141 | #define ID_AA64MMFR1_VMIDBITS_SHIFT 4 |
142 | #define ID_AA64MMFR1_HADBS_SHIFT 0 | 142 | #define ID_AA64MMFR1_HADBS_SHIFT 0 |
143 | 143 | ||
144 | #define ID_AA64MMFR1_VMIDBITS_8 0 | ||
145 | #define ID_AA64MMFR1_VMIDBITS_16 2 | ||
146 | |||
144 | /* id_aa64mmfr2 */ | 147 | /* id_aa64mmfr2 */ |
145 | #define ID_AA64MMFR2_UAO_SHIFT 4 | 148 | #define ID_AA64MMFR2_UAO_SHIFT 4 |
146 | 149 | ||
diff --git a/arch/arm64/kvm/hyp/s2-setup.c b/arch/arm64/kvm/hyp/s2-setup.c index bfc54fd82797..5a9f3bf542b0 100644 --- a/arch/arm64/kvm/hyp/s2-setup.c +++ b/arch/arm64/kvm/hyp/s2-setup.c | |||
@@ -36,8 +36,10 @@ void __hyp_text __init_stage2_translation(void) | |||
36 | * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS | 36 | * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS |
37 | * bit in VTCR_EL2. | 37 | * bit in VTCR_EL2. |
38 | */ | 38 | */ |
39 | tmp = (read_sysreg(id_aa64mmfr1_el1) >> 4) & 0xf; | 39 | tmp = (read_sysreg(id_aa64mmfr1_el1) >> ID_AA64MMFR1_VMIDBITS_SHIFT) & 0xf; |
40 | val |= (tmp == 2) ? VTCR_EL2_VS : 0; | 40 | val |= (tmp == ID_AA64MMFR1_VMIDBITS_16) ? |
41 | VTCR_EL2_VS_16BIT : | ||
42 | VTCR_EL2_VS_8BIT; | ||
41 | 43 | ||
42 | write_sysreg(val, vtcr_el2); | 44 | write_sysreg(val, vtcr_el2); |
43 | } | 45 | } |
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c index 69247b4dcc43..cace818d86eb 100644 --- a/arch/s390/mm/gmap.c +++ b/arch/s390/mm/gmap.c | |||
@@ -23,7 +23,7 @@ | |||
23 | /** | 23 | /** |
24 | * gmap_alloc - allocate a guest address space | 24 | * gmap_alloc - allocate a guest address space |
25 | * @mm: pointer to the parent mm_struct | 25 | * @mm: pointer to the parent mm_struct |
26 | * @limit: maximum size of the gmap address space | 26 | * @limit: maximum address of the gmap address space |
27 | * | 27 | * |
28 | * Returns a guest address space structure. | 28 | * Returns a guest address space structure. |
29 | */ | 29 | */ |
@@ -292,7 +292,7 @@ int gmap_map_segment(struct gmap *gmap, unsigned long from, | |||
292 | if ((from | to | len) & (PMD_SIZE - 1)) | 292 | if ((from | to | len) & (PMD_SIZE - 1)) |
293 | return -EINVAL; | 293 | return -EINVAL; |
294 | if (len == 0 || from + len < from || to + len < to || | 294 | if (len == 0 || from + len < from || to + len < to || |
295 | from + len > TASK_MAX_SIZE || to + len > gmap->asce_end) | 295 | from + len - 1 > TASK_MAX_SIZE || to + len - 1 > gmap->asce_end) |
296 | return -EINVAL; | 296 | return -EINVAL; |
297 | 297 | ||
298 | flush = 0; | 298 | flush = 0; |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index f62a9f37f79f..b7e394485a5f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | #define KVM_PIO_PAGE_OFFSET 1 | 44 | #define KVM_PIO_PAGE_OFFSET 1 |
45 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 | 45 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 |
46 | #define KVM_HALT_POLL_NS_DEFAULT 500000 | 46 | #define KVM_HALT_POLL_NS_DEFAULT 400000 |
47 | 47 | ||
48 | #define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS | 48 | #define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS |
49 | 49 | ||
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 5ff3485acb60..01bd7b7a6866 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c | |||
@@ -1116,6 +1116,11 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) | |||
1116 | break; | 1116 | break; |
1117 | case HVCALL_POST_MESSAGE: | 1117 | case HVCALL_POST_MESSAGE: |
1118 | case HVCALL_SIGNAL_EVENT: | 1118 | case HVCALL_SIGNAL_EVENT: |
1119 | /* don't bother userspace if it has no way to handle it */ | ||
1120 | if (!vcpu_to_synic(vcpu)->active) { | ||
1121 | res = HV_STATUS_INVALID_HYPERCALL_CODE; | ||
1122 | break; | ||
1123 | } | ||
1119 | vcpu->run->exit_reason = KVM_EXIT_HYPERV; | 1124 | vcpu->run->exit_reason = KVM_EXIT_HYPERV; |
1120 | vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; | 1125 | vcpu->run->hyperv.type = KVM_EXIT_HYPERV_HCALL; |
1121 | vcpu->run->hyperv.u.hcall.input = param; | 1126 | vcpu->run->hyperv.u.hcall.input = param; |
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 443d2a57ad3d..1a2da0e5a373 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
@@ -1369,7 +1369,7 @@ static void start_apic_timer(struct kvm_lapic *apic) | |||
1369 | 1369 | ||
1370 | hrtimer_start(&apic->lapic_timer.timer, | 1370 | hrtimer_start(&apic->lapic_timer.timer, |
1371 | ktime_add_ns(now, apic->lapic_timer.period), | 1371 | ktime_add_ns(now, apic->lapic_timer.period), |
1372 | HRTIMER_MODE_ABS); | 1372 | HRTIMER_MODE_ABS_PINNED); |
1373 | 1373 | ||
1374 | apic_debug("%s: bus cycle is %" PRId64 "ns, now 0x%016" | 1374 | apic_debug("%s: bus cycle is %" PRId64 "ns, now 0x%016" |
1375 | PRIx64 ", " | 1375 | PRIx64 ", " |
@@ -1402,7 +1402,7 @@ static void start_apic_timer(struct kvm_lapic *apic) | |||
1402 | expire = ktime_add_ns(now, ns); | 1402 | expire = ktime_add_ns(now, ns); |
1403 | expire = ktime_sub_ns(expire, lapic_timer_advance_ns); | 1403 | expire = ktime_sub_ns(expire, lapic_timer_advance_ns); |
1404 | hrtimer_start(&apic->lapic_timer.timer, | 1404 | hrtimer_start(&apic->lapic_timer.timer, |
1405 | expire, HRTIMER_MODE_ABS); | 1405 | expire, HRTIMER_MODE_ABS_PINNED); |
1406 | } else | 1406 | } else |
1407 | apic_timer_expired(apic); | 1407 | apic_timer_expired(apic); |
1408 | 1408 | ||
@@ -1868,7 +1868,7 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) | |||
1868 | apic->vcpu = vcpu; | 1868 | apic->vcpu = vcpu; |
1869 | 1869 | ||
1870 | hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, | 1870 | hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, |
1871 | HRTIMER_MODE_ABS); | 1871 | HRTIMER_MODE_ABS_PINNED); |
1872 | apic->lapic_timer.timer.function = apic_timer_fn; | 1872 | apic->lapic_timer.timer.function = apic_timer_fn; |
1873 | 1873 | ||
1874 | /* | 1874 | /* |
@@ -2003,7 +2003,7 @@ void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) | |||
2003 | 2003 | ||
2004 | timer = &vcpu->arch.apic->lapic_timer.timer; | 2004 | timer = &vcpu->arch.apic->lapic_timer.timer; |
2005 | if (hrtimer_cancel(timer)) | 2005 | if (hrtimer_cancel(timer)) |
2006 | hrtimer_start_expires(timer, HRTIMER_MODE_ABS); | 2006 | hrtimer_start_expires(timer, HRTIMER_MODE_ABS_PINNED); |
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | /* | 2009 | /* |
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 70e95d097ef1..1ff4dbb73fb7 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -557,8 +557,15 @@ static bool mmu_spte_update(u64 *sptep, u64 new_spte) | |||
557 | !is_writable_pte(new_spte)) | 557 | !is_writable_pte(new_spte)) |
558 | ret = true; | 558 | ret = true; |
559 | 559 | ||
560 | if (!shadow_accessed_mask) | 560 | if (!shadow_accessed_mask) { |
561 | /* | ||
562 | * We don't set page dirty when dropping non-writable spte. | ||
563 | * So do it now if the new spte is becoming non-writable. | ||
564 | */ | ||
565 | if (ret) | ||
566 | kvm_set_pfn_dirty(spte_to_pfn(old_spte)); | ||
561 | return ret; | 567 | return ret; |
568 | } | ||
562 | 569 | ||
563 | /* | 570 | /* |
564 | * Flush TLB when accessed/dirty bits are changed in the page tables, | 571 | * Flush TLB when accessed/dirty bits are changed in the page tables, |
@@ -605,7 +612,8 @@ static int mmu_spte_clear_track_bits(u64 *sptep) | |||
605 | 612 | ||
606 | if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) | 613 | if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) |
607 | kvm_set_pfn_accessed(pfn); | 614 | kvm_set_pfn_accessed(pfn); |
608 | if (!shadow_dirty_mask || (old_spte & shadow_dirty_mask)) | 615 | if (old_spte & (shadow_dirty_mask ? shadow_dirty_mask : |
616 | PT_WRITABLE_MASK)) | ||
609 | kvm_set_pfn_dirty(pfn); | 617 | kvm_set_pfn_dirty(pfn); |
610 | return 1; | 618 | return 1; |
611 | } | 619 | } |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 742d0f7d3556..0a2c70e43bc8 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -6095,12 +6095,10 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win) | |||
6095 | } | 6095 | } |
6096 | 6096 | ||
6097 | /* try to inject new event if pending */ | 6097 | /* try to inject new event if pending */ |
6098 | if (vcpu->arch.nmi_pending) { | 6098 | if (vcpu->arch.nmi_pending && kvm_x86_ops->nmi_allowed(vcpu)) { |
6099 | if (kvm_x86_ops->nmi_allowed(vcpu)) { | 6099 | --vcpu->arch.nmi_pending; |
6100 | --vcpu->arch.nmi_pending; | 6100 | vcpu->arch.nmi_injected = true; |
6101 | vcpu->arch.nmi_injected = true; | 6101 | kvm_x86_ops->set_nmi(vcpu); |
6102 | kvm_x86_ops->set_nmi(vcpu); | ||
6103 | } | ||
6104 | } else if (kvm_cpu_has_injectable_intr(vcpu)) { | 6102 | } else if (kvm_cpu_has_injectable_intr(vcpu)) { |
6105 | /* | 6103 | /* |
6106 | * Because interrupts can be injected asynchronously, we are | 6104 | * Because interrupts can be injected asynchronously, we are |
@@ -6569,10 +6567,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
6569 | if (inject_pending_event(vcpu, req_int_win) != 0) | 6567 | if (inject_pending_event(vcpu, req_int_win) != 0) |
6570 | req_immediate_exit = true; | 6568 | req_immediate_exit = true; |
6571 | /* enable NMI/IRQ window open exits if needed */ | 6569 | /* enable NMI/IRQ window open exits if needed */ |
6572 | else if (vcpu->arch.nmi_pending) | 6570 | else { |
6573 | kvm_x86_ops->enable_nmi_window(vcpu); | 6571 | if (vcpu->arch.nmi_pending) |
6574 | else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) | 6572 | kvm_x86_ops->enable_nmi_window(vcpu); |
6575 | kvm_x86_ops->enable_irq_window(vcpu); | 6573 | if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) |
6574 | kvm_x86_ops->enable_irq_window(vcpu); | ||
6575 | } | ||
6576 | 6576 | ||
6577 | if (kvm_lapic_enabled(vcpu)) { | 6577 | if (kvm_lapic_enabled(vcpu)) { |
6578 | update_cr8_intercept(vcpu); | 6578 | update_cr8_intercept(vcpu); |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 22ab246feed3..eeae401a2412 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -199,7 +199,7 @@ | |||
199 | #define unreachable() __builtin_unreachable() | 199 | #define unreachable() __builtin_unreachable() |
200 | 200 | ||
201 | /* Mark a function definition as prohibited from being cloned. */ | 201 | /* Mark a function definition as prohibited from being cloned. */ |
202 | #define __noclone __attribute__((__noclone__)) | 202 | #define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) |
203 | 203 | ||
204 | #endif /* GCC_VERSION >= 40500 */ | 204 | #endif /* GCC_VERSION >= 40500 */ |
205 | 205 | ||