diff options
| author | David Matlack <dmatlack@google.com> | 2016-12-16 17:30:36 -0500 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-01-12 08:33:17 -0500 |
| commit | cef84c302fe051744b983a92764d3fcca933415d (patch) | |
| tree | 86fc792e45f77560815fde5c000184647a5d1476 | |
| parent | b6416e61012429e0277bd15a229222fd17afc1c1 (diff) | |
KVM: x86: flush pending lapic jump label updates on module unload
KVM's lapic emulation uses static_key_deferred (apic_{hw,sw}_disabled).
These are implemented with delayed_work structs which can still be
pending when the KVM module is unloaded. We've seen this cause kernel
panics when the kvm_intel module is quickly reloaded.
Use the new static_key_deferred_flush() API to flush pending updates on
module unload.
Signed-off-by: David Matlack <dmatlack@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| -rw-r--r-- | arch/x86/kvm/lapic.c | 6 | ||||
| -rw-r--r-- | arch/x86/kvm/lapic.h | 1 | ||||
| -rw-r--r-- | arch/x86/kvm/x86.c | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 5fe290c1b7d8..2f6ef5121a4c 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c | |||
| @@ -2426,3 +2426,9 @@ void kvm_lapic_init(void) | |||
| 2426 | jump_label_rate_limit(&apic_hw_disabled, HZ); | 2426 | jump_label_rate_limit(&apic_hw_disabled, HZ); |
| 2427 | jump_label_rate_limit(&apic_sw_disabled, HZ); | 2427 | jump_label_rate_limit(&apic_sw_disabled, HZ); |
| 2428 | } | 2428 | } |
| 2429 | |||
| 2430 | void kvm_lapic_exit(void) | ||
| 2431 | { | ||
| 2432 | static_key_deferred_flush(&apic_hw_disabled); | ||
| 2433 | static_key_deferred_flush(&apic_sw_disabled); | ||
| 2434 | } | ||
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index e0c80233b3e1..ff8039d61672 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h | |||
| @@ -110,6 +110,7 @@ static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu) | |||
| 110 | 110 | ||
| 111 | int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); | 111 | int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); |
| 112 | void kvm_lapic_init(void); | 112 | void kvm_lapic_init(void); |
| 113 | void kvm_lapic_exit(void); | ||
| 113 | 114 | ||
| 114 | #define VEC_POS(v) ((v) & (32 - 1)) | 115 | #define VEC_POS(v) ((v) & (32 - 1)) |
| 115 | #define REG_POS(v) (((v) >> 5) << 4) | 116 | #define REG_POS(v) (((v) >> 5) << 4) |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2f22810a7e0c..a0ac6e0060fb 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -6045,6 +6045,7 @@ out: | |||
| 6045 | 6045 | ||
| 6046 | void kvm_arch_exit(void) | 6046 | void kvm_arch_exit(void) |
| 6047 | { | 6047 | { |
| 6048 | kvm_lapic_exit(); | ||
| 6048 | perf_unregister_guest_info_callbacks(&kvm_guest_cbs); | 6049 | perf_unregister_guest_info_callbacks(&kvm_guest_cbs); |
| 6049 | 6050 | ||
| 6050 | if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) | 6051 | if (!boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) |
